Skip to content

Commit

Permalink
fix: backup table would be deleted, even if it doesnt exist (#562)
Browse files Browse the repository at this point in the history
Co-authored-by: Spencer horton <[email protected]>
  • Loading branch information
octiva and spencer-horton-wcq authored Jan 15, 2024
1 parent e28c991 commit 3e64216
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
{%- set old_tmp_relation = adapter.get_relation(identifier=identifier ~ '__ha',
schema=schema,
database=database) -%}
{%- set old_bkp_relation = adapter.get_relation(identifier=identifier ~ '__bkp',
schema=schema,
database=database) -%}
{%- set is_ha = config.get('ha', default=false) -%}
{%- set s3_data_dir = config.get('s3_data_dir', default=target.s3_data_dir) -%}
{%- set s3_data_naming = config.get('s3_data_naming', default='table_unique') -%}
Expand Down Expand Up @@ -92,8 +95,8 @@
-- afterwards, therefore we are in weird state. The easiest and cleanest should be to remove
-- the backup relation. It won't have an impact because since we are in the else condition,
-- that means that old relation exists therefore no downtime yet.
{%- if old_relation_bkp is not none -%}
{%- do drop_relation(old_relation_bkp) -%}
{%- if old_bkp_relation is not none -%}
{%- do drop_relation(old_bkp_relation) -%}
{%- endif -%}

{% set query_result = safe_create_table_as(False, tmp_relation, sql, force_batch) %}
Expand Down

0 comments on commit 3e64216

Please sign in to comment.