For loading array into table please specify different delimiter other than "," so that hive can differentiate delimiter of column and array.
For example you can use below format
color1,red|blue|green
and you create table command would be like below
CREATE TABLE test(color_category STRING, colors ARRAY<STRING>)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ","
COLLECTION ITEMS TERMINATED BY "|"
Please note if you are not happy with the response on this ticket, please escalate it to escalations@edureka.in.
We assure you that we will get back to you within 24 hours
Regards,
Abhishek Tiwari
edureka! Support Team
On Sun, 3 Apr at 8:56 AM , Gpreethi13 <gpreethi13@gmail.com> wrote:'I have a data set as shown below (/some-path/a.txt):color1,red,blue,green
color2,red,orange,white
color3,black,green,blueI want it to be stored in a table of 2 fields, a STRING and an ARRAY<STRING> like below:color1,[red,blue,green]
color2,[red,orange,white,yellow,purple]
color3,[black,green]I created a table using the below CREATE & LOAD statements:CREATE TABLE test (color_category STRING, colors ARRAY<STRING>)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ,
COLLECTION ITEMS TERMINATED BY ,
LINES TERMINATED BY n
STORED AS TEXTFILE;LOAD DATA LOCAL INPATH /some-path/a.txt INTO TABLE test;But data is getting stored as below:color1,[red]
color2,[red]
color3,[black]Please guide me in storing the data set as I desired.Thanks for your help in advance'