如何将 array<map<string,int>> 插入到配置单元 table 中?
How to insert array<map<string,int>> into hive table?
我有一个蜂巢table如下:
0: jdbc:hive2://Desktop:10000> desc tb_test2;
+-------------+-------------------------+----------+
| col_name | data_type | comment |
+-------------+-------------------------+----------+
| name | string | |
| score_list | array<map<string,int>> | |
+-------------+-------------------------+----------+
我想插入这样的数据:
A [{"math":100,"english":90,"history":85}]
B [{"math":95,"english":80,"history":100}]
C [{"math":80,"english":90,"histroy":100}]
我试过这样:
0: jdbc:hive2://Desktop:10000> insert into tb_test2 values("A",Map("math":100,"english":90,"history":85));
但出现错误:
Error: Error while compiling statement: FAILED: ParseException line 1:42 cannot recognize input near '"math"' ':' '100' in constant (state=42000,code=40000)
我觉得应该用逗号,还要指定数组
insert into tb_test2 select "A", array(map("math",100,"english",90,"history",85)) from (select 1) x;
我有一个蜂巢table如下:
0: jdbc:hive2://Desktop:10000> desc tb_test2;
+-------------+-------------------------+----------+
| col_name | data_type | comment |
+-------------+-------------------------+----------+
| name | string | |
| score_list | array<map<string,int>> | |
+-------------+-------------------------+----------+
我想插入这样的数据:
A [{"math":100,"english":90,"history":85}]
B [{"math":95,"english":80,"history":100}]
C [{"math":80,"english":90,"histroy":100}]
我试过这样:
0: jdbc:hive2://Desktop:10000> insert into tb_test2 values("A",Map("math":100,"english":90,"history":85));
但出现错误:
Error: Error while compiling statement: FAILED: ParseException line 1:42 cannot recognize input near '"math"' ':' '100' in constant (state=42000,code=40000)
我觉得应该用逗号,还要指定数组
insert into tb_test2 select "A", array(map("math",100,"english",90,"history",85)) from (select 1) x;