How can I add a timestamp column in hive

依然范特西╮ 提交于 2019-12-18 08:54:31

问题


I have 2 rows like below:

941 78 252 3008 86412 1718502 257796 2223252 292221 45514 114894

980 78 258 3064 88318 1785623 269374 2322408 305467 46305 116970

I want to insert current time stamp while inserting each row. finally in my hive table row should be like below:

941 78 252 3008 86412 1718502 257796 2223252 292221 45514 114894 2014-10-21

980 78 258 3064 88318 1785623 269374 2322408 305467 46305 116970 2014-10-22

Is there any way I can insert timestamp directly into hive without using pig script?


回答1:


You can use from_unixtime(unix_timestamp()) while inserting.

For example, suppose you have following tables:

create table t1(c1 String);
create table t2(c1 String, c2 timestamp);

Now you can populate table t2 from t1 with current timestamp:

insert into table t2 select *, from_unixtime(unix_timestamp()) from t1;


来源:https://stackoverflow.com/questions/26505586/how-can-i-add-a-timestamp-column-in-hive

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!