You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
When running (or building) a materialized_view model a first time creates correctly, running the same view a second time with no changes generates an error:
"cms_mv_test" is not a view
indeed, when looking at the target/compiled code for the second dbt i can see this:
dropview if exists "<db>"."<schema>"."cms_mv_test" cascade;
create materialized view "<db>"."<schema>"."cms_mv_test"
the database is correctly returning an error as it expects this first line to read:
drop materialized view if exists "<db>"."<schema>"."cms_mv_test";
but this behaviour was true for all values of on_configuration_change and auto_refresh, and regardless of if i made a change to the model file or not, or presence of the --full-refresh flag.
Expected Behavior
To cite docs here for convenience:
Materialized views are implemented following this "drop through" life cycle:
If an object does not exist, create a materialized view
If an object exists, other than a materialized view, that object is dropped and replaced with a materialized view
If --full-refresh is supplied, replace the materialized view regardless of changes and the on_configuration_change setting
If there are no configuration changes, refresh the materialized view
At this point there are configuration changes, proceed according to the on_configuration_change setting
Disclaimer: i am aware of the existing issues #621 and #565 i think this is technically different hence why i'm raising it. I won't take issue if this is rolled into those as i expect the required code changes might be the same.
Similarly if this is a user error i'm happy to humbly walk away with a learning on how to work this correctly.
The text was updated successfully, but these errors were encountered:
github-actionsbot
changed the title
[Bug] Materialized Views not correctly dropping
[ADAP-953] [Bug] Materialized Views not correctly dropping
Oct 21, 2023
Is this a new bug in dbt-redshift?
Current Behavior
When running (or
build
ing) amaterialized_view
model a first time creates correctly, running the same view a second time with no changes generates an error:"cms_mv_test" is not a view
indeed, when looking at the
target/compiled
code for the second dbt i can see this:the database is correctly returning an error as it expects this first line to read:
I do notice the files dbt/include/redshift/macros/relations/view/drop.sql and dbt/include/redshift/macros/relations/materialized_view/drop.sql appear correct (to my untrained eye) so presumably this some mapping error? Perhaps in the
dbt-core
layer?i used the following config:
but this behaviour was true for all values of
on_configuration_change
andauto_refresh
, and regardless of if i made a change to the model file or not, or presence of the--full-refresh
flag.Expected Behavior
To cite docs here for convenience:
https://docs.getdbt.com/docs/build/materializations
is relevance here is step 2, following a second
dbt run
should complete without error, by running the following sql:Steps To Reproduce
models/demo/cms_mv_test.sql
:Relevant log output
Environment
Additional Context
Disclaimer: i am aware of the existing issues #621 and #565 i think this is technically different hence why i'm raising it. I won't take issue if this is rolled into those as i expect the required code changes might be the same.
Similarly if this is a user error i'm happy to humbly walk away with a learning on how to work this correctly.
The text was updated successfully, but these errors were encountered: