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