我使用hive创建了一个表,我希望过滤数据
create table student(
id bigint
,name string
, course array<string>)
ROW FORMAT DELIMiTED fields terminated by '\t'
collection items terminated by ','
STORED AS TEXTFILE;
和
之类的数据100 student1 java,.net,hadoop
101 student2 .net,hadoop
102 student3 java,hadoop
103 student4 .net,hadoop
104 student5 java,.net
105 student6 java,.net,hadoop
106 student7 .net,hadoop
适合这个数据基于cource = hadoop
请有人帮助我。
答案 0 :(得分:0)
select *
from student
where array_contains (course,'hadoop')
;
+-----+----------+--------------------------+
| id | name | course |
+-----+----------+--------------------------+
| 100 | student1 | ["java",".net","hadoop"] |
| 101 | student2 | [".net","hadoop"] |
| 102 | student3 | ["java","hadoop"] |
| 103 | student4 | [".net","hadoop"] |
| 105 | student6 | ["java",".net","hadoop"] |
| 106 | student7 | [".net","hadoop"] |
+-----+----------+--------------------------+