hive 双分区外部表 复合数据结构处理 json list map互相嵌套

本文详细介绍了如何在Hive中创建与管理外部表,并解析JSON数据结构,包括list、map和struct的对应关系,以及如何分区和设置行格式。通过具体实例和参考链接,帮助读者理解Hive数据处理的高级技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.youkuaiyun.com/jzy3711/article/details/84246075

https://blog.youkuaiyun.com/jzy3711/article/details/84257589

原数据样例下载:https://download.youkuaiyun.com/download/jzy3711/10794293

https://download.youkuaiyun.com/user/jzy3711/uploads

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值