hive函数之collect_set/collect_list,concat_ws,array_contains 联合使用
1 表数据
select id,act_status from ods.ods_ta_task limit 6;
+----------------------+-------------+
| id | act_status |
+----------------------+-------------+
| 3499945599152603749 | TEMP |
| 3499945624922542181 | TEMP |
| 3499945633511348581 | TEMP |
| 3499945667872782181 | TEMP |
| 3499945689346313829 | ANSWER |
| 3499945766654782464 | GRADE |
+----------------------+-------------+
2 sql
--查看状态里包括’TEMP‘的id
select id,
array_contains(split(concat_ws(',',collect_set(act_status)),','),'TEMP')
from
ods.ods_ta_task
group by id
limit 5;
--返回值
+----------------------+--------+
| id | _c1 |
+----------------------+--------+
| 3499945667872782181 | true |
| 3499945766654782464 | true |
| 3499945766655250944 | true |
| 3499945766655834624 | true |
| 3499945766656443648 | true |
+----------------------+--------+
|