-
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
[CT-575] [Bug] 1.0.0 Cannot execute an empty query #5183
Comments
Seems related to #2439 but in reverse. |
@Fouad-Kichauat Thanks for opening, and for the clear reproduction case! This is due to the mismatched casing for your column name:
If you change your Better error?One straightforward change we could make: Check to ensure that
That would still result in the column comment not being persisted, but it would at least avoid the "can't execute an empty query" error. Instead, it would fail silently. Is that actually better...? Case-insensitive comparison?This just came up over on For databases that retain case-sensitive names, I think it's reasonable for dbt to expect users to match case as well. For instance, on Postgres, this is possible:
We could add case-insensitive comparison logic here, but then how could we handle the case above? Update docsMy inclination is to say, our best bet is to update the docs on |
Is it possible to warn when the |
Good question! Some past conversations on that theme: |
@jtcohen6 Thank for the fast reply! Using the prior example and matching the exact case of the source column solves the issue for the demo code. models/example/schema.sql
models/example/my_third_dbt_model.sql
EDIT: |
It all depends on whether you're quoting the column name or not. In Postgres, column names are lowercased by default, but they retain case-sensitivity if they're quoted. If you change your model to quote the column names, this should now work: select id as "Id",
'test' as "SecondColumn"
from {{ ref('my_second_dbt_model') }} models:
- name: my_third_dbt_model
description: "An additional starter dbt model"
columns:
- name: Id
quote: true # note this is necessary too
description: 'The primary key for this table'
tests:
- unique
- not_null
- name: SecondColumn
quote: true
description: 'Another column' To be clear, I don't recommend this. It's all much simpler if you lowercase (and snake case) column names across the board: models:
- name: my_third_dbt_model
description: "An additional starter dbt model"
columns:
- name: id
description: 'The primary key for this table'
tests:
- unique
- not_null
- name: second_column
|
Thank you for the many clarifications!! We can close the issue now. |
Is there an existing issue for this?
Current Behavior
dbt is errorring with cannot execute and empty query for a model that does have columns description in a schema.yml file, and having persist_docs: {columns: true} configured.
Database Error in model my_third_dbt_model (models/example/my_third_dbt_model.sql)
Expected Behavior
No response
Steps To Reproduce
Relevant log output
No response
Environment
What database are you using dbt with?
postgres
Additional Context
No response
The text was updated successfully, but these errors were encountered: