-
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
DBT relationship test does not correctly support column quoting #2468
Comments
I followed the thread to here before losing where the relationship test may be held: |
Thanks for the detailed write-up @MarcelvanVliet!
Currently, dbt supports project-level quoting configurations for relation namespaces: database, schema, and identifier. (There are specially scoped overrides for sources and seeds.) There isn't a broad-purpose quoting configuration for columns; we tend to accomplish this in utility macros via We'd need to establish what exactly such a lift would get us, since (as you mention) there are workarounds available, albeit a bit funny looking. |
@jtcohen6 I caught up with @MarcelvanVliet about this on Slack. I think it would be really great if we could leverage the quoting configs from these .yml files directly in the So, this probably isn't something we'd hit in the immediate future, but I'd like to keep this issue open to track the change :) |
Ah ok! That makes sense. I missed it in my first read-through. |
I just tagged this a good first issue, as I think it'd be a fairly straightforward change. Hint: there's some prior work in #2733 that may be helpful :) |
Noting that this doesn't just fail with relationships requiring quoting, but fails in general with any sources in Postgres. |
@jordan8037310 Could you share the specific code snippet + error you're seeing? Not sure I follow fully |
When running Noting that the workaround does work, Error
Copy of generated sql for the test:
|
@jordan8037310 Did you specify sources:
- name: public
table: source_ip_whois
columns:
- name: ipAddress
quote: true
tests:
- unique ? |
@jtcohen6 - no, althought I just tested that and it works! Thanks. Here are some things I tried. I mainly assumed that if I did applied the settings at the dbt_project.yml level it persisted down. I tried putting it in at the dbt_project.yml for quoting with the following and it quoted everything in my project... except the sources.
After happening upon this thread, I saw that sources were handled differently so I tried:
To be honest I never once saw the
So perhaps this is more an issue of a EDIT: Added another link where |
Really fair point. I guess I could've hoped that you would've magically stumbled upon https://docs.getdbt.com/reference/resource-properties/quote/. Why do we call it
Oof, this is old. |
@jtcohen6 +1 normalization of the property names would have made this easier to search and find. |
There's also |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days. |
Describe the bug
When defining a relationship test (In this case between Person and Invitation) the generated DBT test does not link the relationship back to the destination table column definition. Hence, it does not recognise that a column in a relationship test may require quoting.
Steps To Reproduce
With a Source as follows:
The following test is generated, incorrectly leaving the quotes off the column named Id in the generated sql test.
The following error occurs:
Expected behavior
I would expect DBT to link the column with the definition and respect the quoting setting chosen.
For convenience, it may be useful to also add column quoting configuration at the model and source level.
Screenshots and log output
As above
System information
Which database are you using dbt with?
The output of
dbt --version
:The operating system you're using:
Mac
The output of
python --version
:Python 3.7.3
Additional context
A valid work-around (via Drew) is to quote the Id column manually in the relationships test. You’ll need to use two sets of quotes — one to denote that the value is a string (for yaml) and the next to be passed into the SQL query.
The text was updated successfully, but these errors were encountered: