Hive学习(三)-集合数据类型
来源:互联网 发布:fifo和lifo存货的算法 编辑:程序博客网 时间:2024/06/14 17:47
Hive中的列支持使用struct,map,array三种集合数据类型。
(
Number string,
Deductions map<string,float>,
Subordinates array<string>,
Address struct<street:string,city:string,pro:string>
)
row format delimited
fields terminated by ','
collection items terminated by '_'
map keys terminated by ':';
将下面的数据上传到employees表中:
1001,salary:20020_insurance:205_accumulation:170,John_Aaron_Abbott_Abel,1 Micheigan Ave_Chicago_IL
1002,maternity:120_accumulation:170,Beau_Beck,2 Broush_Chicago_IL
1003,salary:11020_insurance:275_accumulation:210,Benedict_Benjamin_Bill,Yosef 12A_Mulans_Texas
1004,salary:7420_insurance:505_accumulation:580,Bowen,Hanan_Andal_Texas
该数据保存在文件filemacsn.txt当中。文件位于用户主目录。
hive>load data local inpath 'filemacsn.txt' into table employees;
Loading data to table default.employees
OK
Time taken: 0.733 seconds
hive>
1.查询完整数据:
hive> select * from employees;
OK
1001 {"salary":20020.0,"insurance":205.0,"accumulation":170.0}["John","Aaron","Abbott","Abel"] {"street":"1 Micheigan Ave","city":"Chicago","pro":"IL"}
1002 {"maternity":120.0,"accumulation":170.0}["Beau","Beck"] {"street":"2 Broush","city":"Chicago","pro":"IL"}
1003 {"salary":11020.0,"insurance":275.0,"accumulation":210.0}["Benedict","Benjamin","Bill"] {"street":"Yosef 12A","city":"Mulans","pro":"Texas"}
1004 {"salary":7420.0,"insurance":505.0,"accumulation":580.0}["Bowen"] {"street":"Hanan","city":"Andal","pro":"Texas"}
Time taken: 1.117 seconds, Fetched: 4 row(s)
hive>
2.查询所有street:
hive> select address.street from employees;
OK
1 Micheigan Ave
2 Broush
Yosef 12A
Hanan
Time taken: 2.64 seconds, Fetched: 4 row(s)
hive>
3.查询编号为1001的salary:
hive> select deductions['salary'] from employees where number='1001';
OK
20020.0
Time taken: 1.962 seconds, Fetched: 1 row(s)
hive>
- Hive学习(三)-集合数据类型
- Hive集合数据类型
- 读书笔记:Hive中的集合数据类型
- Hive学习之Hive数据类型
- hive学习 hive中的数据类型
- Hive学习之Hive数据类型
- hive学习1-数据类型
- Hive集合数据类型(Struct,Map,Array)
- Hive学习笔记 --- Hive的数据类型
- Hive学习笔记 2 Hive的数据类型
- hive学习笔记之-数据类型
- Hive学习三
- Hive语言手册之三:数据类型
- Hive编程(三)【数据类型和文件格式】
- python基础学习-集合数据类型
- Hive数据类型-集合类型(Array-Map-Struct)的尝试
- Hive 学习笔记(三)
- hive 学习(1) 内置函数以及数据类型
- C++常成员
- 《JavaScript面向对象编程》笔记1(函数)
- Java进阶--从源码理解Math.ceil()、Math.floor()、Math.round()
- 二叉树的层次遍历
- sublime text 3 + python配置,完整搭建及常用插件安装
- Hive学习(三)-集合数据类型
- Problem E: 编写函数:Swap (I) (Append Code)
- 拦截器 Interceptor
- u-boot中mkimage工具的具体使用
- 关于javax.validation.Validator校验的使用
- json的另外一种写法
- nginx端口占用,启动报错:bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way f
- qt 类型装换
- 【转载】从Fiddler抓包到Jmeter接口测试(简单的思路)