hive 双分区外部表 复合数据结构处理 json list map互相嵌套
api="TopicHeatTrend"
hadoop dfs -mkdir /jzytest/hive${api}/
hive -e 'create external table if not exists jzy'$api'json
(
distribute map<string,map<string,int>>,
heatTrend array<struct<channel:string,heat:int,list:array<struct<heat:int,time:string>>>>,
topData map<string,array<struct<list:array<map<string,string>>,source:string>>>
)
partitioned by (topic_id string,dt string)
row format serde "org.apache.hive.hcatalog.data.JsonSerDe"
LOCATION "hdfs:///jzytest/hive'$api'/";'
原数据格式:



结果:




总结:
1.list对应array,map对应map,json对应struct
2.使用struct时要注意key对应
参考:https://blog.csdn.net/jzy3711/article/details/84246075
https://blog.csdn.net/jzy3711/article/details/84257589
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐


所有评论(0)