Skip to content

Commit 7634b79

Browse files
committed
Fix get_fixture_sql which always leads to a compliation error if column_name_to_data_types is not falsy
1 parent e76e838 commit 7634b79

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Fix get_fixture_sql which always leads to a compliation error if column_name_to_data_types is not falsy
3+
time: 2025-11-19T14:38:59.834685+01:00
4+
custom:
5+
Author: darkclouder
6+
Issue: none

dbt-adapters/src/dbt/include/global_project/macros/unit_test_sql/get_fixture_sql.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
{%- set columns_in_relation = adapter.get_columns_in_relation(this_or_defer_relation) -%}
99

1010
{%- set column_name_to_data_types = {} -%}
11-
{%- set column_name_to_quoted = {} -%}
1211
{%- for column in columns_in_relation -%}
1312

1413
{#-- This needs to be a case-insensitive comparison --#}
1514
{%- do column_name_to_data_types.update({column.name|lower: column.data_type}) -%}
16-
{%- do column_name_to_quoted.update({column.name|lower: column.quoted}) -%}
1715
{%- endfor -%}
1816
{%- endif -%}
1917

@@ -32,7 +30,7 @@
3230
{%- set default_row_copy = default_row.copy() -%}
3331
{%- do default_row_copy.update(formatted_row) -%}
3432
select
35-
{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ column_name_to_quoted[column_name] }}{% if not loop.last -%}, {%- endif %}
33+
{%- for column_name, column_value in default_row_copy.items() %} {{ column_value }} as {{ adapter.quote(column_name) }}{% if not loop.last -%}, {%- endif %}
3634
{%- endfor %}
3735
{%- if not loop.last %}
3836
union all
@@ -41,7 +39,7 @@ union all
4139

4240
{%- if (rows | length) == 0 -%}
4341
select
44-
{%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ column_name_to_quoted[column_name] }}{% if not loop.last -%},{%- endif %}
42+
{%- for column_name, column_value in default_row.items() %} {{ column_value }} as {{ adapter.quote(column_name) }}{% if not loop.last -%},{%- endif %}
4543
{%- endfor %}
4644
limit 0
4745
{%- endif -%}

0 commit comments

Comments
 (0)