From 8051de74e5f701b765d0c8a65be8d8480227fe44 Mon Sep 17 00:00:00 2001 From: Mila Page Date: Fri, 23 Feb 2024 18:54:13 -0800 Subject: [PATCH] Remove dispatch to stop excessive transaction bracing. --- dbt/include/redshift/macros/materializations/table.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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) %}