Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quoted identifiers in the generate_base_model macro for BigQuery #199

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration_tests/macros/operations/create_source_table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ set enable_case_sensitive_identifier to true;
{% set create_table_sql_case_sensitive %}
create table {{ target_schema }}.codegen_integration_tests__data_source_table_case_sensitive as (
select
1 as {% if target.type == "bigquery" %}My_Integer_Col{% else %}"My_Integer_Col"{% endif %},
true as {% if target.type == "bigquery" %}My_Bool_Col{% else %}"My_Bool_Col"{% endif %}
1 as {{ adapter.quote("My_Integer_Col") }},
true as {{ adapter.quote("My_Bool_Col") }}
)
{% endset %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ with source as (
renamed as (

select
{% if target.type == "bigquery" %}My_Integer_Col{% else %}"My_Integer_Col"{% endif %}
, {% if target.type == "bigquery" %}My_Bool_Col{% else %}"My_Bool_Col"{% endif %}
{{ adapter.quote("My_Integer_Col") }}
, {{ adapter.quote("My_Bool_Col") }}

from source

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ with source as (
renamed as (

select
{% if target.type == "bigquery" %}My_Integer_Col{% else %}"My_Integer_Col"{% endif %},
{% if target.type == "bigquery" %}My_Bool_Col{% else %}"My_Bool_Col"{% endif %}
{{ adapter.quote("My_Integer_Col") }},
{{ adapter.quote("My_Bool_Col") }}

from source

Expand Down
4 changes: 2 additions & 2 deletions macros/generate_base_model.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ renamed as (
select
{%- if leading_commas -%}
{%- for column in column_names %}
{{", " if not loop.first}}{% if not case_sensitive_cols %}{{ column | lower }}{% elif target.type == "bigquery" %}{{ column }}{% else %}{{ "\"" ~ column ~ "\"" }}{% endif %}
{{", " if not loop.first}}{% if not case_sensitive_cols %}{{ column | lower }}{% else %}{{ adapter.quote(column) }}{% endif %}
{%- endfor %}
{%- else -%}
{%- for column in column_names %}
{% if not case_sensitive_cols %}{{ column | lower }}{% elif target.type == "bigquery" %}{{ column }}{% else %}{{ "\"" ~ column ~ "\"" }}{% endif %}{{"," if not loop.last}}
{% if not case_sensitive_cols %}{{ column | lower }}{% else %}{{ adapter.quote(column) }}{% endif %}{{"," if not loop.last}}
{%- endfor -%}
{%- endif %}

Expand Down
Loading