Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive, mail # user - INSERT INTO table with STRUCT, SELECT FROM


Copy link to this message
-
INSERT INTO table with STRUCT, SELECT FROM
Michael Malak 2013-02-13, 19:26
Is it possible to INSERT INTO TABLE t SELECT FROM where t has a column with a STRUCT?

Based on
http://grokbase.com/t/hive/user/109r87hh3e/insert-data-into-a-column-of-complex-type

I thought perhaps the following would work:

echo 1,2 >twovalues.csv
hive
CREATE TABLE tc (x INT, y INT) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';
LOAD DATA LOCAL INPATH 'twovalues.csv' INTO TABLE tc;
CREATE TABLE oc (z STRUCT<a: int, b: int>);
INSERT INTO TABLE oc SELECT struct(x,y) FROM tc;

but when I do the above I get:

FAILED: SemanticException [Error 10044]: Line 1:18 Cannot insert into target table because column number/types are different 'oc': Cannot convert column 0 from struct<col1:int,col2:int> to struct<a:int,b:int>.