Search code examples
hadoophiveapache-hive

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


Solution

  • 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;