Sorry, I didnβt quite understand this. What do you mean by with some UDF or inline function ? If you want to insert into the table with the Map , it is similar to any other data type. For instance:
I have a table called complex1 created as follows:
CREATE TABLE complex1(c1 array<string>, c2 map<int,string> ) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' COLLECTION ITEMS TERMINATED BY '-' MAP KEYS TERMINATED BY ':' LINES TERMINATED BY '\n';
I also have a file called com.txt that contains the following: Mohammad-Tariq, 007: Bond
Now I will load this data into the table created above:
load inpath data '/inputs/com.txt' into table complex1;
So this table contains:
select * from complex1;
Ok
["Mohammad", "Tariq"] {7: "Bond"}
Time: 0.062 seconds
I have another table called complex2:
CREATE TABLE complex2(c1 map<int,string>);
Now, to select the data from complex1 and paste into complex2, I will do the following:
Insert into table complex2 select c2 from complex1;
Scan the table for cross-validation:
select * from complex2;
Ok
{7: Bond}
Time: 0.062 seconds
NTN
Tariq source share