diff --git a/dbt/include/redshift/macros/materializations/table.sql b/dbt/include/redshift/macros/materializations/table.sql index 907c83874..3e1d67894 100644 --- a/dbt/include/redshift/macros/materializations/table.sql +++ b/dbt/include/redshift/macros/materializations/table.sql @@ -38,15 +38,14 @@ {% set existing_relation = load_cached_relation(existing_relation) %} {% if existing_relation is not none %} {% if existing_relation.can_be_renamed %} - {{ adapter.rename_relation(existing_relation, backup_relation) }} - {% else %} - {{ drop_relation_if_exists(existing_relation) }} + {{ adapter.rename_relation_table(existing_relation, backup_relation) }} + {% else %} + drop table if exists {{ existing_relation }} cascade; {% endif %} {% endif %} {% endif %} - - {{ adapter.rename_relation(intermediate_relation, target_relation) }} + alter table {{ intermediate_relation }} rename to {{ target_relation }} {% do create_indexes(target_relation) %}