-
Notifications
You must be signed in to change notification settings - Fork 59
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
[ADAP-871] [Regression] Views referencing aliased tables of the same name cause build failure #595
Comments
@btello thanks for the write-up! this is indeed a bug. this isn't a use case we commonly see of aliasing models to correspond to other names of models, but it is certainly a valid one. Using version
dbt run -s foo; dbt run -s bar # works
dbt run # doesn't work
dbt run -s +bar # doesn't work the run will fail not on the model creation step, but rather when attempting to rename the pre-existing target relation to a backup so that the model that was just made can be renamed. The following SQL errors with: alter table "db"."dataders_downstream"."bar" rename to "bar__dbt_backup" This is the place in the view materialization (dbt-redshift, uses dbt-core's default version). What strange is that line only executes if dbt thinks the relation already exists simple reproducible exampletwo models
-- foo.sql
{{
config(
materialized='table',
schema='upstream',
alias='bar'
)
}}
SELECT 1 AS x -- bar.sql
{{
config(
materialized='view',
schema='downstream'
)
}}
SELECT x as id from {{ref('foo')}} theories
|
I fixed an intermittent test error in this area in the base view.sql for 1.6:
|
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. |
Is this a regression in a recent version of dbt-redshift?
Current Behavior
When I run a
dbt build
against the project in this demo repository https://github.com/btello/test_dbt_bug/tree/main I get the following error every other time I run it:What I've found is that any time I have a view model with name
x
and then query a table model with an alias to that same namex
(but in a different schema of course) I get this error.This problem is affecting my real production project as well but this super basic repro should be more clear. I applied minimal configuration to the project and there are only two models.
Expected/Previous Behavior
I did not have this error on 1.4.7 which is the version we use in production and I've tested all the way up to 1.5.8 which works fine.
Steps To Reproduce
Environment:
dbt-core = 1.6.1
dbt-redshift = 1.6.1
Python 3.11.4
OS: I've tested this on both Ubuntu (in the Docker container mcr.microsoft.com/devcontainers/universal:2) as well as Windows 11. It fails the same way on both OSs
To reproduce, point this project https://github.com/btello/test_dbt_bug/tree/main at a redshift database and run
dbt build
Relevant log output
Additional Context
No response
The text was updated successfully, but these errors were encountered: