Closed jlucas91 closed 3 months ago
May be related to https://github.com/dbt-labs/dbt-core/issues/10139
@jlucas91 Thanks for opening - I think it's actually the same as:
This isn't Snowflake-specific, it would be relevant anywhere we're:
{{ relation }}
, as a stringshow
/describe
/etc) where we don't want to access the actual underlying dataI don't think that happens everywhere:
redshift__get_columns_in_relation
doesn't template out {{ relation }}
as a string, it decomposes it into database/schema/identifiercreate
/ drop
/ alter
statements don't tend to be used for the direct result of a ref/source callSo while on first read I was worried this was going to be an issue everywhere — I think we just need to do the work of combing through those call sites in our adapters. A reasonable lift, but it feels doable. In the meantime we can document this as a limitation.
Scope of this fix should also include adding tests to cover some of these edge cases, resolving https://github.com/dbt-labs/dbt-snowflake/issues/1033 and updating maintainer docs
Opened a new issue in dbt-labs/docs.getdbt.com: https://github.com/dbt-labs/docs.getdbt.com/issues/5734
Is this a new bug?
Current Behavior
When running the
--empty
flag introduced in DBT 1.8adapter.get_columns_in_relation
generates and runs an invalid DESCRIBE TABLE statement, halting the run. The statement looks roughly like:describe table (select * from TABLE_NAME_HERE where false limit 0)
Which generates the error:
Expected Behavior
adapter.get_columns_in_relation
should fallback to some reasonable default when running with the --empty flag, or alternatively throws a more intelligible error message.For our usages, I'm working around it by guarding calls to
adapter.get_columns_in_relation
behind a check on whether we're running in empty mode. However, this is cumbersome and a bit error prone.Steps To Reproduce
./dbt run --empty
on a model that usesadapter.get_columns_in_relation
Relevant log output
No response
Environment
Additional Context
No response