本文所需环境如下:
操作系统:CentOS 7.2 64位
Hive版本:2.1.1
JDK版本:jdk1.8.0_131
Hadoop版本:2.8.1
IDE: IntelliJ IDEA 2017.2.2
创建数据
创建数据
数组类型
数组类型
hive> create external table a1(vals array<int>) row format delimited fields
terminated by ' ' collection items terminated by ',' location '/a1';
查看每一行数据大小
image.png
创建2列,1列数字,1列字符串
创建2列
创建外部表,查询数据
创建外部表,查询数据
hive> create external table t4(v1 array<int>, v2 array<string>) row format
delimited fields terminated by ' ' collection items terminated by ',' location '/a2';
map类型
image.png
在hive中创建map,如果是map类型,列分隔符必须是\t
image.png
hive> create external table m1 (vals map<string,int>) row format delimited
fields terminated by '\t' map keys terminated by ',' location '/m1';
查看键值对
image.png
统计tom浏览的网址
统计tom浏览的网址
在hive中用map查看
在hive中用map查看
使用distinct去重
hive> select distinct(vals['tom']) from tom where vals['tom'] is not null;
struct类型,不常用
struct类型
在hive中查看
在hive中查看