我有一个看起来像这样的配置单元查询:
select * from table_name where array_contains(field_name, '${some_variable}');
这没有任何问题,但区分大小写。我需要它不区分大小写,但两者都
select * from table_name where array_contains(lower(field_name), '${some_variable}');
和
select * from table_name where array_contains(lcase(field_name), '${some_variable}');
因空指针异常而失败。有没有办法使这个查询不区分大小写?
答案 0 :(得分:1)
with t as (select array('X','y','Z') as field_name, 'Y' as var)
select array_contains(split(lower(concat_ws('\u0001',field_name)),'\u0001'),lower(var))
from t
或
with t as (select array('X','y','Z') as field_name, 'Y' as var)
select concat_ws('\u0001',field_name) rlike concat('(?i)(^|\\x01)',var,'(\\x01|$)')
from t