3

Have a table with following schema:

CREATE TABLE `student_details`(
  `id_key` string, 
  `name` string, 
  `subjects` array<string>)
ROW FORMAT SERDE 
  'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' 
STORED AS INPUTFORMAT 
  'org.apache.hadoop.mapred.TextInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
  'path'

When trying to insert the values in the table getting an error message:

Tried:

INSERT INTO student_details  values ('AA87U','BRYAN',array('ENG','CAL_1','CAL_2','HST','MUS')); 

Error:

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

This doesn't make sense to me. Tried looking online and found a similar one: ExternalLink. The solution also not making any sense.

Any help please.

2 Answers 2

3

You can't insert a complex type directly in Hive.

Either you have to create a dummy table like below:

INSERT INTO student_details select 'AA87U','BRYAN', array('ENG','CAL_1','CAL_2','HST','MUS') from dummy; 

For Hive 2+, you can run without dummy table.

INSERT INTO student_details select 'AA87U','BRYAN', array('ENG','CAL_1','CAL_2','HST','MUS');
Sign up to request clarification or add additional context in comments.

1 Comment

insert into blablabla select array('a', 'b') doesn't work, when blablabla contains a single column of type array<string>.
0

You have to first create a dummy table with one row:

create table dummy(a int);
insert into dummy values (1);

then you can do this:

INSERT INTO student_details select 'AA87U','BRYAN', array('ENG','CAL_1','CAL_2','HST','MUS') from dummy; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.