标签:style blog color 使用 io strong 数据 for
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
标签:style blog color 使用 io strong 数据 for
原文地址:http://www.cnblogs.com/luogankun/p/3912386.html