2016-06-16 216 views
1

嗨,我是Hive的新手,我想將當前時間戳與一行數據一起插入到我的表中。將時間戳插入Hive

這裏是我的表的例子:

team_id int 
fname string 
lname string 
time timestamp 

我已經看了一些其他的例子,How to insert timestamp into a Hive table?How can I add a timestamp column in hive並且似乎無法得到它的工作。 這就是我想:

insert into team values('101','jim','joe',from_unixtime(unix_timestamp())); 

我得到的錯誤是:

FAILED: SemanticException [Error 10293]: Unable to create temp file for insert values Expression of type TOK_FUNCTION not supported in insert/values 

如果有人可以幫助,那將是巨大的,非常感謝frostie

+0

插入不支持您已經使用過的日期UDF。 –

+0

有沒有解決你的問題? –

回答

5

可通過current_timestamp()實現,但只能通過select子句。在選擇的語句中甚至不需要from子句。

insert into team select '101','jim','joe',current_timestamp(); 

,或者如果你的蜂巢版本不支持留在from選擇statment

insert into team select '101','jim','joe',current_timestamp() from team limit 1; 
+1

我嘗試了以上,並得到以下錯誤: 'ParseException線1:65無法識別謂詞''。規則失敗:聲明中的'regularBody' –

+0

增加了一個查詢來獲得結果。 – syadav

+0

嗨@syadav這個工程,但沒有出現在表中,但如果我刪除了「限制1」,它可以工作,但輸入多個。任何原因爲什麼會發生這種情況或我該如何解決這個問題? –

0

如果你不已經有一個表至少一行,就可以完成所需的結果這樣。 插入團隊從(選擇'123')x選擇'101','jim','joe',current_timestamp()