Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 780
Abbas Gadhia Avatar asked Jul 02 '26 01:07

Abbas Gadhia


1 Answers

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

It was as simple as

INSERT INTO table1 values ('Clerk#0008000', '2016-01-01');
like image 93
Abbas Gadhia Avatar answered Jul 04 '26 20:07

Abbas Gadhia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!