hive數據類型struct,結構體,類似類里面的很多屬性
假如有以下數據:
1,zhangsan,18:male:深圳
2,lisi,28:female:北京
3,wangwu,38:male:廣州
4,趙六,26:female:上海
5,錢琪,35:male:杭州
6,王八,48:female:南京
建表
drop table if exists t_user;
create table t_user(id int, name string, info struct<age:int, sex:string, addr:string>)
row format delimited fields terminated by ','
collection items terminated by ':';
導入數據
load data local inpath '/home/struct.txt' into table t_user;
查詢每個人的id name和addr
select id,name,info.age as age,info.sex as sex,info.addr as addr from t_user;