关于 hive 特殊字段的应用举例
建表
create table temp.jc_t_test_map_array ( id int, name string, hobby array<string>, -- array中元素为string类型 friend map<string,string>, -- map中键和值均为string类型 mark struct<math:int,english:int> -- struct中元素为int类型 ) row format delimited fields terminated by ',' -- 字段之间用','分隔 collection items terminated by '_' -- 集合中的元素用'_'分隔 map keys terminated by ':' -- map中键值对之间用':'分隔 lines terminated by '\n' ;-- 行之间用'\n'分隔
查看表结构.
desc temp.jc_t_test_map_array; id int name string hobby array<string> friend map<string,string> mark struct<math:int,english:int>
插入数据
insert into temp.jc_t_test_map_array select 2, 'xiaohua', array('basketball', 'read'), str_to_map('xiaoming:no,xiaohong:no'), named_struct('math', 90, 'english', 90);
数据展示
select id, name, hobby[0], --查询第一个hobby friend['xiaohong'], --查询map键为xiaohong的value mark.math --查询struct中math的值 from temp.jc_t_test_map_array;
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下