-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Bug] Data tests do not quote columns names when mixed case #10477
Comments
I implemented a local fix by overriding the test macros to wrap |
final macro changes that work (though needs a new quote parameter added to the main test definition)
This allows this to work models:
-name: myModel
data_tests:
- unique:
quote: False
column_name: |
"myColumn" || ':' || "myOtherColumn"
columns:
- name: myColumn
data_tests:
- unique |
Did you try the |
This properly quoted for me when I used the
select null as "Id"
models:
- name: my_model
columns:
- name: Id
quote: true
data_tests:
- not_null Here's the SQL in select "Id"
from "db"."my_schema"."my_model"
where "Id" is null |
@jeremyyeo i hunted all through the docs and source and could only find quote_columns (for seeds!). Is there a way to turn that quote setting on for ALL columns in a model? (or even all models in a project?) And I'll try that right now to see if it works. |
@jeremyyeo that does indeed work and gets the columns quoted. It would be nice to be able to set it for the whole project. (e.g. a new key here? https://docs.getdbt.com/reference/project-configs/quoting ) and/or some per-model setting |
🎉
Yeah! 🤩 We're imagining adding the following new config to quote:
database: true|false # or `project` on dbt-bigquery
schema: true|false # or `dataset` on dbt-bigquery
identifier: true|false
columns: true|false Since the quote property allows for quoting columns in data tests and #2986 proposes a way to apply similar quoting project-wide, I'm going to close this issue. But please feel free to reach out if you have any other feedback or ideas. |
Is this a new bug in dbt-core?
Current Behavior
We have models that use mixed-case column names (and table names), however when defining column tests the generated SQL does not quote the column names thus the queries fail on postgres (and other DBs that are case sensitive)
Expected Behavior
DB Columns to be quoted so case is handled correctly.
Steps To Reproduce
Model definition yml
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
No response
The text was updated successfully, but these errors were encountered: