hive復雜數據類型struct


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;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM