Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
607 views
in Technique[技术] by (71.8m points)

hadoop - Hive inserting values to an array complex type column

I am unable to append data to tables that contain an array column using insert into statements; the data type is array < varchar(200) >

Using jodbc I am unable to insert values into an array column by values like :

INSERT INTO demo.table (codes) VALUES (['a','b']);

does not recognises the "[" or "{" signs.

Using the array function like ...

INSERT INTO demo.table (codes) VALUES (array('a','b'));

I get the following error using array function:

Unable to create temp file for insert values Expression of type TOK_FUNCTION not supported in insert/values

Tried the workaround...

INSERT into demo.table (codes) select array('a','b');

unsuccessfully:

Failed to recognize predicate '<EOF>'. Failed rule: 'regularBody' in statement

How can I load array data into columns using jdbc ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

My Table has two columns: a STRING, b ARRAY<STRING>.

When I use @Kishore Kumar Suthar's method, I got this:

FAILED: ParseException line 1:33 cannot recognize input near '(' 'a' ',' in statement

But I find another way, and it works for me:

INSERT INTO test.table 
SELECT "test1", ARRAY("123", "456", "789") 
FROM dummy LIMIT 1;

dummy is any table which has atleast one row.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...