如何创建日期格式为'dd-MMM-yyyy'的hive表?

时间:2018-03-20 09:46:12

标签: string date hive hiveql

我试图创建一个用于将csv数据导入到表中的hive表,其中csv文件中的日期格式为'dd-MMM-yyyy'(例如20-Mar-2018)。当我在配置单元中创建表时,它将整个日期列转换为空值。任何人都可以建议我如何解决这个问题吗?

我的查询:

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/' 

1 个答案:

答案 0 :(得分:0)

最后来自@leftjoin的帮助,我解决了使用select查询将字符串日期格式化(dd-MMM-yyyy)转换为(dd-MM-yyyy)的问题。它会工作正常。

select from_unixtime(unix_timestamp(columnname ,'dd-MMM-yyyy'), 'dd-MM-yyyy') from tablename;
相关问题