简体   繁体   English

如何将带有时间(日期)类型的文件加载到Hive表中?

[英]How to load file with time (Date) type into Hive table?

I'm using hive to create and try to load file content into the table. 我正在使用配置单元来创建并尝试将文件内容加载到表中。 There's a column type "Date" and the date format in the file is dd/mm/yy, for example: 01/12/2013 列类型为“日期”,文件中的日期格式为dd / mm / yy,例如:01/12/2013

But when I trie to load the data into table from the file, the column values corresponding to the "Date" is always NULL, as if failed to load the date content. 但是当我从文件中将数据加载到表中时,对应于“Date”的列值始终为NULL,就好像无法加载日期内容一样。

I put the column content into a txt file and upload to the hdfs, so, the column may be: id, name, birthdate 我将列内容放入txt文件并上传到hdfs,因此,列可能是:id,name,birthdate

and corresponding value are: 1, "Joan", 04/05/1989 相应的值是:1,“Joan”,04/05/1989

But the "04/05/1989" seems can't be read into the table, always null. 但是“04/05/1989”似乎无法读入表中,始终为空。

Please tell me if the format in my txt file is wrong or I need some specific grammar when loading date type data into Hive table. 请告诉我,我的txt文件中的格式是否错误,或者在将日期类型数据加载到Hive表时需要一些特定的语法。

Thanks! 谢谢!

Date data type format is YYYY-MM-DD. 日期数据类型格式为YYYY-MM-DD。 You need to format field accordingly. 您需要相应地格式化字段。

More details on 更多细节

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-date https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types#LanguageManualTypes-date

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM