首页 > 其他 > 详细

Hive基础之Hive的复杂类型

时间:2014-08-14 15:56:58      阅读:311      评论:0      收藏:0      [点我收藏+]

Array

一组有序字段,字段的类型必须相同。Array(1,2)

create table hive_array(ip string, uid array<string>)
row format delimited 
fields terminated by ,
collection items terminated by |
stored as textfile;
load data local inpath "/home/spark/software/data/hive_array.txt" overwrite into table hive_array;

 

hive_array.txt

192.168.1.1,www.baidu.com|www.google.com|www.qq.com
192.168.1.2,www.baidu.com|www.sina.com|www.sohu.com
192.168.1.3,www.qq.com|www.163.com|www.youku.com
select * from hive_array;                                                                         
192.168.1.1     ["www.baidu.com","www.google.com","www.qq.com"]
192.168.1.2     ["www.baidu.com","www.sina.com","www.sohu.com"]
192.168.1.3     ["www.qq.com","www.163.com","www.youku.com"]

使用下标访问,下标从0开始:

select ip, uid[0] as id from hive_array;
192.168.1.1     www.baidu.com
192.168.1.2     www.baidu.com
192.168.1.3     www.qq.com

查看数据长度:

select size(uid) from hive_array;
3
3
3

数组查找:

select * from hive_array where array_contains(uid, "www.baidu.com");
192.168.1.1     ["www.baidu.com","www.google.com","www.qq.com"]
192.168.1.2     ["www.baidu.com","www.sina.com","www.sohu.com"]

 

 

Struts

 

Map

 

Hive基础之Hive的复杂类型,布布扣,bubuko.com

Hive基础之Hive的复杂类型

原文:http://www.cnblogs.com/luogankun/p/3912386.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!