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;

原文地址:https://www.cnblogs.com/lucas-zhao/p/11901883.html