雪花 Where 子句不过滤?
Snowflake Where Clause Not Filtering?
我是运行雪花中的这个查询:
select *
from my_database.information_schema.tables
where
table_schema NOT LIKE '%information%';
当我查看记录时,其中一些 INFORMATION_SCHEMA
作为 table_schema.
为什么我的过滤器不起作用?
LIKE is case sensitive, where-as ILIKE 不区分大小写。你的两个字符串是不同的情况。所以我建议你换成ILIKE
SELECT 'a' LIKE 'A' as "a_like_A", 'a' ILIKE 'A' as "a_ilike_A";
给出:
a_like_A a_ilike_A
FALSE TRUE
When I look at the records, some of them have INFORMATION_SCHEMA as the table_schema.
When an identifier is unquoted, it is stored and resolved in uppercase.
问题是您正在比较不同的大写字符串和小写字符串。
where table_schema LIKE '%information%'; -- this comparison will not work
其他比较方式:
where table_schema LIKE UPPER('%information%');
值得注意的是 SHOW TABLES LIKE '<patern>'
在设计上是不区分大小写的,并且 return 将匹配以下内容,而不管使用的版本如何:
SHOW TABLES LIKE '%information%';
SHOW TABLES LIKE '%INFORMATION%';
SHOW TABLES LIKE '%Information%';
我是运行雪花中的这个查询:
select *
from my_database.information_schema.tables
where
table_schema NOT LIKE '%information%';
当我查看记录时,其中一些 INFORMATION_SCHEMA
作为 table_schema.
为什么我的过滤器不起作用?
LIKE is case sensitive, where-as ILIKE 不区分大小写。你的两个字符串是不同的情况。所以我建议你换成ILIKE
SELECT 'a' LIKE 'A' as "a_like_A", 'a' ILIKE 'A' as "a_ilike_A";
给出:
a_like_A a_ilike_A
FALSE TRUE
When I look at the records, some of them have INFORMATION_SCHEMA as the table_schema.
When an identifier is unquoted, it is stored and resolved in uppercase.
问题是您正在比较不同的大写字符串和小写字符串。
where table_schema LIKE '%information%'; -- this comparison will not work
其他比较方式:
where table_schema LIKE UPPER('%information%');
值得注意的是 SHOW TABLES LIKE '<patern>'
在设计上是不区分大小写的,并且 return 将匹配以下内容,而不管使用的版本如何:
SHOW TABLES LIKE '%information%';
SHOW TABLES LIKE '%INFORMATION%';
SHOW TABLES LIKE '%Information%';