标签:span lin seconds nat 定义 多个 etc 杂类 time
hive提供一种复合类型的数据
create table student_struct(id INT, info struct<name:STRING, age:INT>) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,‘ //指定表在加载数据时候的列分割符 COLLECTION ITEMS TERMINATED BY ‘:‘; //指定每个字段之间的item的分隔符
1,zhang:24 2,wang:23 3,feng:22 4,li:22 5,zhou:21 6,xing:20 7,cai:19 8,yi:18 9,lan:17
hive> select*from student_struct where info.age>20; OK 1 {"name":"zhang","age":24} 2 {"name":"wang","age":23} 3 {"name":"feng","age":22} 4 {"name":"li","age":22} 5 {"name":"zhou","age":21} Time taken: 2.31 seconds, Fetched: 5 row(s)
create table student_array(id INT, stuArray array<String>) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘,‘ COLLECTION ITEMS TERMINATED BY ‘:‘;
同 struct 数据
hive> select*from student_array where stuArray[1]>20; OK 1 ["zhang","24"] 2 ["wang","23"] 3 ["feng","22"] 4 ["li","22"] 5 ["zhou","21"] Time taken: 2.63 seconds, Fetched: 5 row(s)
create table student_map(id string, stuMap map<string, int>) ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t‘ COLLECTION ITEMS TERMINATED BY ‘,‘ MAP KEYS TERMINATED BY ‘:‘;
1 zhang:24,shangHai:100 2 wang:23,shangHai:200 3 feng:22,shangHai:1900 4 li:22,shangHai:2900 5 zhou:21,shangHai:1200 6 xing:20,shangHai:1200 7 cai:19,shangHai:600 8 yi:18,shangHai:7600 9 lan:17,shangHai:8000
hive> select * from student_map where stuMap[‘shangHai‘]=100; OK 1 {"zhang":24,"shangHai":100} Time taken: 0.944 seconds, Fetched: 1 row(s) hive>
标签:span lin seconds nat 定义 多个 etc 杂类 time
原文地址:http://www.cnblogs.com/zhangXingSheng/p/6223465.html