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

Conversation

dbeatty10
Copy link
Contributor

@dbeatty10 dbeatty10 commented Nov 20, 2024

resolves #205
resolves #193

Problem

There's some code that adds quoted identifiers for bigquery in a hard-coded fashion. It doesn't handle when a column name in BigQuery needs to be quoted such as a reserved keyword or a column that starts with a number.

Solution

Use adapter.quote to create a case-sensitive quoted identifier for column names since it is designed precisely for this type of use-case.

🎩

From CI for BigQuery:

23:43:04  3 of 23 START test test_generate_base_models_case_sensitive .................... [RUN]


with source as (

    select * from {{ source('codegen_integration_tests__data_source_schema', 'codegen_integration_tests__data_source_table_case_sensitive') }}

),

renamed as (

    select
        `My_Integer_Col`,
        `My_Bool_Col`

    from source

)

select * from renamed

23:43:05  3 of 23 PASS test_generate_base_models_case_sensitive .......................... [PASS in 0.92s]

Checklist

@dbeatty10 dbeatty10 marked this pull request as ready for review November 20, 2024 23:46
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Nov 20, 2024
@dbeatty10 dbeatty10 changed the title Use adapter.quote to create a case-sensitive quoted identifier for column names Fix quoted identifiers in the generate_base_model macro for BigQuery Nov 21, 2024
@dbeatty10 dbeatty10 merged commit b444bf8 into main Nov 21, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quoted identifiers in the generate_base_model macro for BigQuery Use cross-database quoting macros
1 participant