hive中array、map嵌套类型使用
作者:互联网
1、需求:业务中需要将发票开具明细作为发票开具表中一个字段,使用hive中array嵌套map解决该问题
2、创建hive表
1 CREATE TABLE `51fp_tmp`.`test`( 2 `fp_dm` string, 3 `mxList` array<map<string,string>> 4 ) 5 ROW FORMAT DELIMITED FIELDS TERMINATED BY '\0x01' 6 COLLECTION ITEMS TERMINATED BY ',' 7 MAP KEYS TERMINATED BY ':' 8 LINES TERMINATED BY '\n';
//ROW FORMAT DELIMITED FIELDS TERMINATED BY '\0x01' 字段分隔
//COLLECTION ITEMS TERMINATED BY array及map中一个字段各个item的分隔符
//MAP KEYS TERMINATED BY ':' key value分隔符
//LINES TERMINATED BY '\n' 行分隔符
3、hive中获取array嵌套map字段值
mxList字段值如下:
获取array中第二个map中的key="ggxh"的value
4、参考资料
hive中array嵌套map以及行转列的使用 https://www.cnblogs.com/30go/p/8328869.html
hive 存储,解析,处理json数据 https://www.cnblogs.com/qiaoyihang/p/8729368.html
hive array、map、struct使用 https://www.iteye.com/blog/daizj-2255031
标签:map,www,TERMINATED,hive,嵌套,array 来源: https://www.cnblogs.com/water-drop23/p/15771652.html