Skip to content

Commit

Permalink
Simplify logic for this by moving this away from a quoting situation.
Browse files Browse the repository at this point in the history
Columns that unquoted are capitalized regardless of the quoting ignore flag. So we let it be uppercase and then normalize it down to lowercase in Python.
  • Loading branch information
VersusFacit committed Nov 6, 2024
1 parent d515335 commit 2570641
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
5 changes: 5 additions & 0 deletions dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ def list_relations_without_caching(
# this can be collapsed once Snowflake adds is_iceberg to show objects
columns = ["database_name", "schema_name", "name", "kind", "is_dynamic"]
if self.behavior.enable_iceberg_materializations.no_warn:
# The QUOTED_IDENTIFIERS_IGNORE_CASE setting impacts column names like
# is_iceberg which is created by dbt, but it does not affect the case
# of column values in Snowflake's SHOW OBJECTS query! This
# normalization step ensures metadata queries are handled consistently.
schema_objects = schema_objects.rename(column_names={"IS_ICEBERG": "is_iceberg"})
columns.append("is_iceberg")

return [self._parse_list_relations_result(obj) for obj in schema_objects.select(columns)]
Expand Down
12 changes: 1 addition & 11 deletions dbt/include/snowflake/macros/adapters.sql
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,6 @@

{%- set max_total_results = max_results_per_iter * max_iter -%}
{%- set sql -%}
{# -- The QUOTED_IDENTIFIERS_IGNORE_CASE setting impacts column names like
-- is_iceberg which is created by dbt, but it does not affect the case
-- of column values in Snowflake's SHOW OBJECTS query! This session-only
-- alteration ensures the is_iceberg column is lowercase, juast if it
-- were a system-provided field.
--
-- This along with the behavior flag in general may be removed when
-- is_iceberg comes on show objects. #}
alter session set QUOTED_IDENTIFIERS_IGNORE_CASE = false;

{% if schema_relation is string %}
show objects in {{ schema_relation }} limit {{ max_results_per_iter }};
{% else %}
Expand All @@ -159,7 +149,7 @@
{# -- Gated for performance reason. If you don't want Iceberg, you shouldn't pay the
-- latency penalty. #}
{% if adapter.behavior.enable_iceberg_materializations.no_warn %}
select all_objects.*, is_iceberg as {{ adapter.quote('is_iceberg') }}
select all_objects.*, is_iceberg
from table(result_scan(last_query_id(-1))) all_objects
left join INFORMATION_SCHEMA.tables as all_tables
on all_tables.table_name = all_objects."name"
Expand Down

0 comments on commit 2570641

Please sign in to comment.