Hive支持的数据类型


数据类型:基本数据类型、集合数据类型

基本数据类型

集合数据类型

建表语句:

create table test(
name string,
friends array<string>,
children map<string, int>,
address struct<street:string, city:string>
)
row format delimited fields terminated by ','
collection items terminated by '_'
map keys terminated by ':'
lines terminated by '\n';

字段解析:

row format delimited fields terminated by ','  -- 列分隔符
collection items terminated by '_'  	--MAP STRUCT 和 ARRAY 的分隔符(数据分割符号)
map keys terminated by ':'				-- MAP中的key与value的分隔符
lines terminated by '\n';					-- 行分隔符

json数据结构:

test.txt文件:

嬴政,韩非_李斯,扶苏:28_胡亥:19,咸阳_关中
老王,安娜_丽丽,小王:18_小小王:19,深圳_广东

导入本地文本数据到测试表

hive (default)> load data local inpath ‘/opt/module/data/test.txt’into table test


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM