Open siljamardla opened 2 months ago
Thanks for reporting this @siljamardla !
To align with the corresponding solutions for dbt-bigquery, dbt-snowflake, dbt-redshift, etc, I think the solution would be to add require_alias: bool = False
here rather than changing the default value here.
Here are some reference implementations:
Is this a new bug in dbt-core?
Current Behavior
If you have a dbt model that uses the
{{ref...}}
or{{source..}}
macro together with an alias, for example:and you try to run it with the
--empty
flag then the compiled SQL will have double aliasing, resulting in broken SQLExpected Behavior
The alias should not be changed as to not alter the script
Steps To Reproduce
Create a dbt model with a
{{ref...}}
macro and try to compile its code with the--empty
flag.Relevant log output
No response
Environment
Which database adapter are you using with dbt?
spark
Additional Context
There are 2 workarounds.
Write all your dbt models with CTEs so that there are no aliases right after the macros, something like
Update the BaseRelation class to have
require_alias
beFalse
by default. It's in the .venv/lib/python3.11/site-packages/dbt/adapters/base/relation.py
file, line 51