Arrays 配置单元中数组内的查询

Arrays 配置单元中数组内的查询,arrays,hadoop,hive,hdfs,Arrays,Hadoop,Hive,Hdfs,我已经看到了,但它对我的数据不起作用 我有以下数据: 1, John, a@com;b@com2,32 2, Jack, ab@com;c@com2,33 并通过以下方式将其加载到蜂箱: create table t7(id int,name string, email Array<string>, age int) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' COLLECTION items terminated by ';'

我已经看到了,但它对我的数据不起作用

我有以下数据:

 1, John, a@com;b@com2,32
 2, Jack, ab@com;c@com2,33
并通过以下方式将其加载到蜂箱:

create table t7(id int,name string, email Array<string>, age int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
COLLECTION items terminated by ';'
STORED AS textfile;
Load data inpath '/user/maria_dev/7.txt' into table t7;
创建表t7(id int、名称字符串、电子邮件数组、年龄int)
行格式分隔
以“,”结尾的字段
集合项目以“;”结尾
存储为文本文件;
将路径“/user/maria_dev/7.txt”中的数据加载到表t7中;
和选择输出

但我无法在数组中搜索特定值


那么,我遗漏了什么呢?

您的不起作用的原因是在第一个元素之前有空格,所以必须使用trim

select * from t7 where trim(email[0]) like "%a@%";
创建表`t7`(
`id`int,
`name`string,
`电子邮件`数组,
`年龄(整数)
行格式分隔
以“,”结尾的字段
以“\;”结尾的集合项
配置单元>从t7中选择*,其中修剪(电子邮件[0])=”a@com";
好啊
1约翰[”a@com","b@com2"]     32
配置单元>从t7横向视图分解(电子邮件)分解表中选择*作为id_电子邮件,其中id_电子邮件类似“%com2%”;
好啊
1约翰[”a@com","b@com2"]     32      b@com2
2千斤顶[”ab@com","c@com2"]    33      c@com2

谢谢,你为什么用“\;”而不是“;”?我的很好用,有什么具体原因吗对我来说工作不正常,请使用“\\;”相反
CREATE TABLE `t7`(
  `id` int,
  `name` string,
  `email` array<string>,
  `age` int)
ROW FORMAT DELIMITED
  FIELDS TERMINATED BY ','
  COLLECTION ITEMS TERMINATED BY '\;'

hive> select * from t7 where trim(email[0])="a@com";
OK
1        John   [" a@com","b@com2"]     32

hive> select * from t7 LATERAL VIEW explode(email) exploded_table as id_email where id_email like "%com2%";
OK
1        John   [" a@com","b@com2"]     32      b@com2
2        Jack   [" ab@com","c@com2"]    33      c@com2