Frostie_the_snowman
Frostie_the_snowman

Reputation: 699

Insert timestamp into Hive

Hi i'm new to Hive and I want to insert the current timestamp into my table along with a row of data.

Here is an example of my team table :

team_id int
fname   string
lname   string
time    timestamp

I have looked at some other examples, How to insert timestamp into a Hive table?, How can I add a timestamp column in hive and can't seem to get it to work. This is what I am trying:

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

The error I get is:

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

If anyone could help, that would be great, many thanks frostie

Upvotes: 9

Views: 27108

Answers (2)

Kevin
Kevin

Reputation: 61

If you don't already have a table with at least one row, you can accomplish the desired result as such.

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

Upvotes: 3

sumitya
sumitya

Reputation: 2691

Can be achieved through current_timestamp() , but only via select clause. don't even require from clause in select statment.

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

or if your hive version doesn't support leaving from in select statment

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

Upvotes: 12

Related Questions