Skip to content

Commit

Permalink
Update test_unpivot_quote_identifiers.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
GtheSheep committed Dec 31, 2022
1 parent 5380e40 commit eaa3a7a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions integration_tests/.env/postgres.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POSTGRES_TEST_HOST=localhost
POSTGRES_TEST_USER=postgres
POSTGRES_TEST_USER=root
POSTGRES_TEST_PASS=''
POSTGRES_TEST_PORT=5444
POSTGRES_TEST_DBNAME=GtheSheep
POSTGRES_TEST_PORT=5432
POSTGRES_TEST_DBNAME=circle_test
2 changes: 2 additions & 0 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ seeds:

data_unpivot_quote_identifiers:
+quote_columns: true
data_unpivot_quote_identifiers_expected:
+quote_columns: true

schema_tests:
data_test_sequential_timestamps:
Expand Down
14 changes: 7 additions & 7 deletions integration_tests/models/sql/test_unpivot_quote_identifiers.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
select
customer_id,
created_at,
prop,
val
"customer_id",
"created_at",
"prop",
"val"

from (
{{ dbt_utils.unpivot(
Expand All @@ -15,6 +15,6 @@ from (
) }}
) as sbq
order by
customer_id asc,
created_at asc,
prop asc
"customer_id" asc,
"created_at" asc,
"prop" asc
6 changes: 3 additions & 3 deletions macros/sql/unpivot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ Arguments:
{% set column_identifier = adapter.quote(col.column) if quote_identifiers else col.column %}
select
{%- for exclude_col in exclude %}
{{ exclude_col }},
{{ adapter.quote(exclude_col) if quote_identifiers else exclude_col }},
{%- endfor %}

cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ field_name }},
cast('{{ col.column }}' as {{ dbt.type_string() }}) as {{ adapter.quote(field_name) if quote_identifiers else field_name }},
cast( {% if col.data_type == 'boolean' %}
{{ dbt.cast_bool_to_text(col.column) }}
{% else %}
{{ column_identifier }}
{% endif %}
as {{ cast_to }}) as {{ value_name }}
as {{ cast_to }}) as {{ adapter.quote(value_name) if quote_identifiers else value_name }}

from {{ relation }}

Expand Down

0 comments on commit eaa3a7a

Please sign in to comment.