I have a hive table as follows:
0: jdbc:hive2://Desktop:10000> desc tb_test2;
+-------------+-------------------------+----------+
| col_name | data_type | comment |
+-------------+-------------------------+----------+
| name | string | |
| score_list | array<map<string,int>> | |
+-------------+-------------------------+----------+
I want to insert data like this:
A [{"math":100,"english":90,"history":85}]
B [{"math":95,"english":80,"history":100}]
C [{"math":80,"english":90,"histroy":100}]
I have tried like this:
0: jdbc:hive2://Desktop:10000> insert into tb_test2 values("A",Map("math":100,"english":90,"history":85));
but got the error:
Error: Error while compiling statement: FAILED: ParseException line 1:42 cannot recognize input near '"math"' ':' '100' in constant (state=42000,code=40000)
I think comma should be used, and you need to specify array too.
insert into tb_test2 select "A", array(map("math",100,"english",90,"history",85)) from (select 1) x;