Skip to content

Commit

Permalink
Surround in a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
VersusFacit committed Feb 24, 2024
1 parent 5c9a3fe commit 8c14348
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dbt/include/redshift/macros/materializations/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
{% if existing_relation.can_be_renamed %}
{{ adapter.rename_relation(existing_relation, backup_relation) }}
{% else %}
drop table if exists {{ existing_relation }} cascade;
alter table {{ intermediate_relation }} rename to {{ target_relation }}
BEGIN
drop table if exists {{ existing_relation }} cascade;
alter table {{ intermediate_relation }} rename to {{ target_relation }}
{{ adapter.commit() }}
{% endif %}
{% endif %}
{% endif %}
Expand Down

0 comments on commit 8c14348

Please sign in to comment.