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;

相关文章:

  • 2021-10-25
  • 2021-08-04
  • 2021-12-12
  • 2021-07-19
  • 2021-06-15
  • 2021-12-25
  • 2022-12-23
猜你喜欢
  • 2021-05-11
  • 2022-12-23
  • 2021-02-25
  • 2021-11-15
  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
相关资源
相似解决方案