如何创建日期格式为"dd-MMM-yyyy"的蜂巢表?



我正在尝试创建一个配置单元表,用于将 csv 数据导入表中,其中 csv 文件中的日期格式为"dd-MMM-yyyy"(例如 20-Mar-2018(。当我在 hive 中创建表时,结果是将整个日期列转换为空值。谁能建议我如何弄清楚这一点?

我的查询:

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/' 
最后,

在@leftjoin的一些帮助下,我解决了使用选择查询将格式为 (dd-MMM-yyyy( 的字符串日期转换为 (dd-MMM-yyyy( 的问题。它会正常工作。

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

最新更新