Open JBExcoffier opened 1 week ago
Thanks for opening this @JBExcoffier !
This appears related to https://github.com/dbt-labs/dbt-adapters/issues/124 and https://github.com/dbt-labs/dbt-adapters/pull/179.
Transferring to the dbt-postgres
repo for further triage.
Is this a new bug in dbt-core?
Current Behavior
I have a simple model that fails to create using the
--empty
flag in arun
when there is a reference to another (simple) model and aAS
statement.Expected Behavior
Using the
--empty
flag in the run command should not have any impact in this case.Steps To Reproduce
bug.sql
file inmodels
dir :that depends on the
somemodel.sql
file inmodels
dir :dbt run --empty
produces the following error :I think that the problem comes from the auto generation of the underlying SQL request in the
target/run
directory :Indeed an automatic table name is added (
_dbt_limit_subq_somemodel
). And as there is already aAS
statement, it makes the whole request fails.The bug is no more presen when a full run (i.e. without the
--empty
flag) is performed, as it creates a correct request as follow (target/run
) :Moreover, the problem is not present, with or without the
--empty
flag, when there is no model dependence. For example as with the following model namednobug.sql
:It produces a correct request file in the
target/run
dir (same file generated with or without the--empty
flag) :Relevant log output
No response
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
It seems to fail with either a
ref
or asource
dependence.