Abbas Gadhia
Abbas Gadhia

Reputation: 15090

Apache Hive - Single Insert Date Value

I'm trying to insert a date into a date column using Hive. So far, here's what i've tried

INSERT INTO table1 (EmpNo, DOB)
VALUES ('Clerk#0008000', cast(substring(from_unixtime(unix_timestamp(cast('2016-01-01' as string), 'yyyy-MM-dd')),1,10) as date));

AND

INSERT INTO table table1 values('Clerk#0008000', cast(substring(from_unixtime(unix_timestamp(cast('2016-01-01' as string), 'yyyy-MM-dd')),1,10) as date));

AND

INSERT INTO table1 SELECT 
'Clerk#0008000', cast(substring(from_unixtime(unix_timestamp(cast('2016-01-01' as string), 'yyyy-MM-dd')),1,10) as date);

But i still get

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

OR

FAILED: ParseException line 2:186 Failed to recognize predicate '<EOF>'. Failed rule: 'regularBody' in statement

Hive ACID has been enabled on the ORC based table and simple inserts without dates are working.

I think i'm missing something really simple. But can't put my finger on it.

Upvotes: 3

Views: 11892

Answers (1)

Abbas Gadhia
Abbas Gadhia

Reputation: 15090

Ok. I found it. I feel like a doofus now.

It was as simple as

INSERT INTO table1 values ('Clerk#0008000', '2016-01-01');

Upvotes: 5

Related Questions