Open ddresslerlegalplans opened 2 years ago
Thanks for opening @ddresslerlegalplans! I'm pretty sure this bug is related to persist_docs
. Could you confirm by checking to see if the persist_docs
config is enabled someone for your model / your project?
Set up a model as described:
-- models/table1.sql
select 1 as id
version: 2
models:
- name: table1
columns:
- name: does_not_exist
dbt run
succeeds just fine.
Now update the yaml config to switch on column-level persist_docs
:
version: 2
models:
- name: table1
config:
persist_docs:
columns: true
columns:
- name: does_not_exist
description: "This column does not exist"
$ dbt run
...
14:10:18 Completed with 1 error and 0 warnings:
14:10:18
14:10:18 Database Error in model table1 (models/table1.sql)
14:10:18 can't execute an empty query
14:10:18 compiled Code at target/run/my_gcpython_project/models/table1.sql
The bug (not new in v1.2): https://github.com/dbt-labs/dbt-core/blob/4d6208be6464a48a078dd8000ae6c29d8d7a42ce/core/dbt/include/global_project/macros/adapters/persist_docs.sql#L30-L32
If there are no legitimate columns to be commenting on, alter_column_comment
returns an empty query.
(Redshift has its own slight modifications, but they're functionally identical to the ones in dbt-core
+ dbt-postgres
.)
I think the fix here might look like:
alter_column_comment
— either a list of statements, or None
if there are no statements being templatedpersist_docs
macro, check to see if return value from alter_column_comment
is not None
/ not empty, before passing it into run_query
That shouldn't be too too tricky. It should also have a test case. (Unfortunately, our tests for persist_docs
haven't yet been converted to use the new testing framework.) Labelling this one help_wanted
accordingly.
@jtcohen6 thanks for the quick reply and digging into this. I can confirm we are using persist_doc:
models:
my_project:
+persist_docs:
relation: true
columns: true
Is it just a matter of doing this?:
somewhat new to jinja
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 comment on the issue or else it will be closed in 7 days.
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.
Reopening on behalf of customer :)
On Redshift - the error message is:
23:13:43 Runtime Error in model foo (models/foo.sql)
Tried to run invalid SQL: /* {"app": "dbt", "dbt_version": "1.6.9", "profile_name": "all", "target_name": "rs", "node_id": "model.my_dbt_project.foo"} */
on model.my_dbt_project.foo
23:13:43
Is this a new bug in dbt-core?
Current Behavior
When I run dbt run on table.sql and table.yml has a column and a test defined on a nonexistent column I get this error:
"can't execute an empty query"
Expected Behavior
An error message stating "Non-existent column in table.yml. Please remove the column "column1" from the yml file. "
Steps To Reproduce
with a table1.sql file with a simple select and a few ctes and with a table1.yml file with a non-existent column in table1.sql final select
Relevant log output
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response