[英]How to create hive table with date format 'dd-MMM-yyyy'?
I,m trying to create a hive table for importing csv data into table where the date format in the csv file is 'dd-MMM-yyyy' (for example 20-Mar-2018). 我正在尝试创建一个配置单元表,用于将csv数据导入到表中,其中csv文件中的日期格式为'dd-MMM-yyyy'(例如20-Mar-2018)。 When i created table in hive it turns out the entire column of date into null values. 当我在蜂巢中创建表格时,它会将整个日期列转换为空值。 Can anyone suggest me how to figure out this? 谁能建议我如何解决这个问题?
My Query: 我的查询:
create external table new_stock (Symbol String,Series String,Dat date,Prev_Close float,Open_Price float,High_Price float,Low_Price float,Last_Price float,Close_Price float,Avg_Price float,Volume int,Turn_Over float,Trades int,Del_Qty int,DQPQ_Per float) row format delimited fields terminated by ',' stored as textfile LOCATION '/stock_details/'
Finally some help from @leftjoin, i solved the problem of converting string date with format (dd-MMM-yyyy) to (dd-MM-yyyy) by using select query. 最后来自@leftjoin的一些帮助,我解决了使用选择查询将字符串日期格式为(dd-MMM-yyyy)转换为(dd-MM-yyyy)的问题。 It would work fine. 会很好的。
select from_unixtime(unix_timestamp(columnname ,'dd-MMM-yyyy'), 'dd-MM-yyyy') from tablename;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.