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
In the default view and table materializations, dbt should rename old_relation to backup_relation, instead of renaming target_relation to backup_relation. The issue here is that, if old_relation.type != target_relation.type, dbt will run the wrong alter ... rename statement.
I think this is as simple as switching these to
{% if old_relation is not none %}
{{ adapter.rename_relation(old_relation, backup_relation) }}
{% endif %}
Steps To Reproduce
Create + run a view model
Change config to table + rerun
This does not break on any of the core adapters:
Redshift and Postgres use alter ... rename, but they support alter table for both tables + views
Snowflake and BigQuery don't use alter ... rename, they instead use create or replace
It does break on Presto, which distinguishes between alter view and alter table. dbt will attempt to run alter table (because target_relation.type is table) against an existing view and return an error.
Expected behavior
dbt should use the type of the old relation when it attempts to rename it.
The output of dbt --version:
dbt --version
installed version: 0.15.2
latest version: 0.15.2
Up to date!
The text was updated successfully, but these errors were encountered:
Thanks for the report @jtcohen6. We can get this fixed in a future release, but I'd advise addressing this in a materialization override in the presto plugin for the time being!
Describe the bug
In the default view and table materializations, dbt should rename
old_relation
tobackup_relation
, instead of renamingtarget_relation
tobackup_relation
. The issue here is that, ifold_relation.type != target_relation.type
, dbt will run the wrongalter ... rename
statement.I think this is as simple as switching these to
Steps To Reproduce
This does not break on any of the core adapters:
alter ... rename
, but they supportalter table
for both tables + viewsalter ... rename
, they instead usecreate or replace
It does break on Presto, which distinguishes between
alter view
andalter table
. dbt will attempt to runalter table
(becausetarget_relation.type
istable
) against an existing view and return an error.Expected behavior
dbt should use the type of the old relation when it attempts to rename it.
The output of
dbt --version
:The text was updated successfully, but these errors were encountered: