with your_data as
( --Test dataset, replace it with your table
select stack(5, --5 tuples
'aa\\;bb\\;cc',
'dd\\;cc\\;ff',
'ww\\;xx\\;yy',
'ww\\;aa\\;yy',
'pp\\;bb\\;qq'
) as App
),
test_string as
( --This can be also a dataset, or replace it with string parameter
--according to your requirements
select "'aa','bb','cc'" as str2 --contains values in single quotes delimited by comma
)
select App from
(
select App, split(App, '\\;') AppArray,
split(regexp_replace(t.str2,"'",''),',') as TestArray2 --remove single quotes and split
from your_data
cross join test_string t
--cross join here. This is one string example only. Rewrite join according to your dataset.
)s
where array_contains(AppArray, TestArray2[0]) or --First element exists
array_contains(AppArray, TestArray2[1]) or --second
array_contains(AppArray, TestArray2[2]) --third
;
结果:
OK
aa;bb;cc
dd;cc;ff
ww;aa;yy
pp;bb;qq
Time taken: 41.853 seconds, Fetched: 4 row(s)
1条答案
按热度按时间ee7vknir1#
如果测试字符串的元素数量有限,可以拆分它,并使用array\u contains()检查应用程序中是否存在每个元素。
演示:
结果: