如何在Hive中添加时间戳列

Ama*_*man 3 hive hiveql

我有2行,如下所示:

941 78 252 3008 86412 1718502 257796 2223252 292221 45514 114894

980 78 258 3064 88318 1785623 269374 2322408 305467 46305 116970
Run Code Online (Sandbox Code Playgroud)

我要在插入每一行时插入当前时间戳。最后,在我的蜂巢表中,行应如下所示:

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

有什么方法可以在不使用Pig脚本的情况下将时间戳直接插入到Hive中?

arg*_*ype 6

您可以from_unixtime(unix_timestamp())在插入时使用。

例如,假设您有以下表格:

create table t1(c1 String);
create table t2(c1 String, c2 timestamp);
Run Code Online (Sandbox Code Playgroud)

现在您可以使用当前时间戳从t1填充表t2:

insert into table t2 select *, from_unixtime(unix_timestamp()) from t1;
Run Code Online (Sandbox Code Playgroud)