question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DBT relationship test does not correctly support column quoting

See original GitHub issue

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: image

The following test is generated, incorrectly leaving the quotes off the column named Id in the generated sql test. image

The following error occurs: image

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?

  • [ x] postgres
  • redshift
  • bigquery
  • snowflake
  • other (specify: ____________)

The output of dbt --version:

installed version: 0.16.1
   latest version: 0.16.1

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. image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
beckjakecommented, Sep 15, 2020

There’s also quote_columns, which is a seed-only config item that lives on its own level but surely belongs inside the quoting config item (or will it be quote?!) as columns 😬

2reactions
jtcohen6commented, Sep 15, 2020

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 quoting for database/schema/identifier names, but then quote for column names? Adding this to my list of nomenclature we might make more consistent in advance of dbt v1.0.

On page 1 of google this links to a 404 and should probably be redirected: https://dbt.readme.io/v0.10/docs/configuring-quoting

Oof, this is old.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DBT relationship test does not correctly support column quoting
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...
Read more >
tests - dbt Developer Hub
This test validates that all of the values in a column are present in a supplied list of values . If any values...
Read more >
Tests - dbt Developer Hub
Out of the box, you can test whether a specified column in a model only contains non-null values, unique values, or values that...
Read more >
quote - dbt Developer Hub
Schema tests applied to this column may fail due to invalid SQL; Documentation may not render correctly, e.g. group and "group" may not...
Read more >
State of testing in dbt - In-Depth Discussions
Hello! My team and I have been thinking about testing lately and throughout this thinking I did a deep-dive into the current state...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found