diff --git a/dbt/include/snowflake/macros/catalog.sql b/dbt/include/snowflake/macros/catalog.sql index 8354d3c44..dbee4c2b6 100644 --- a/dbt/include/snowflake/macros/catalog.sql +++ b/dbt/include/snowflake/macros/catalog.sql @@ -95,9 +95,14 @@ {%- endmacro %} +{% macro snowflake__catalog_equals(field, value) %} + "{{ field }}" ilike '{{ value }}' and upper("{{ field }}") = upper('{{ value }}') +{% endmacro %} + + {% macro snowflake__get_catalog_schemas_where_clause_sql(schemas) -%} where ({%- for schema in schemas -%} - upper("table_schema") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%} + {{ snowflake__catalog_equals('table_schema', schema) }}{%- if not loop.last %} or {% endif -%} {%- endfor -%}) {%- endmacro %} @@ -107,12 +112,12 @@ {%- for relation in relations -%} {% if relation.schema and relation.identifier %} ( - upper("table_schema") = upper('{{ relation.schema }}') - and upper("table_name") = upper('{{ relation.identifier }}') + {{ snowflake__catalog_equals('table_schema', relation.schema) }} + and {{ snowflake__catalog_equals('table_name', relation.identifier) }} ) {% elif relation.schema %} ( - upper("table_schema") = upper('{{ relation.schema }}') + {{ snowflake__catalog_equals('table_schema', relation.schema) }} ) {% else %} {% do exceptions.raise_compiler_error(