Skip to content

Commit

Permalink
update replace macro dependent macros to align with naming standards
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Aug 31, 2023
1 parent 24ebc37 commit a7db607
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{%- macro get_backup_sql(relation) -%}
{{- log('Applying BACKUP to: ' ~ relation) -}}
{{- adapter.dispatch('get_backup_sql', 'dbt')(relation) -}}
{%- macro get_create_backup_sql(relation) -%}
{{- log('Applying CREATE BACKUP to: ' ~ relation) -}}
{{- adapter.dispatch('get_create_backup_sql', 'dbt')(relation) -}}
{%- endmacro -%}


{%- macro default__get_backup_sql(relation) -%}
{%- macro default__get_create_backup_sql(relation) -%}

-- get the standard backup name
{% set backup_relation = make_backup_relation(relation, relation.type) %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{%- macro get_stage_sql(relation, sql) -%}
{{- log('Applying STAGE to: ' ~ relation) -}}
{{- adapter.dispatch('get_stage_sql', 'dbt')(relation, sql) -}}
{%- macro get_create_intermediate_sql(relation, sql) -%}
{{- log('Applying CREATE INTERMEDIATE to: ' ~ relation) -}}
{{- adapter.dispatch('get_create_intermediate_sql', 'dbt')(relation, sql) -}}
{%- endmacro -%}


{%- macro default__get_stage_sql(relation, sql) -%}
{%- macro default__get_create_intermediate_sql(relation, sql) -%}

-- get the standard intermediate name
{% set intermediate_relation = make_intermediate_relation(relation) %}
Expand Down
14 changes: 0 additions & 14 deletions core/dbt/include/global_project/macros/relations/deploy_stage.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{%- macro get_rename_intermediate_sql(relation) -%}
{{- log('Applying RENAME INTERMEDIATE to: ' ~ relation) -}}
{{- adapter.dispatch('get_rename_intermediate_sql', 'dbt')(relation) -}}
{%- endmacro -%}


{%- macro default__get_rename_intermediate_sql(relation) -%}

-- get the standard intermediate name
{% set intermediate_relation = make_intermediate_relation(relation) %}

{{ get_rename_sql(intermediate_relation, relation.identifier) }}

{%- endmacro -%}
12 changes: 6 additions & 6 deletions core/dbt/include/global_project/macros/relations/replace.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@

{# /* create target_relation as an intermediate relation, then swap it out with the existing one using a backup */ #}
{%- if target_relation.can_be_renamed and existing_relation.can_be_renamed -%}
{{ get_stage_sql(target_relation, sql) }};
{{ get_backup_sql(existing_relation) }};
{{ get_deploy_stage_sql(target_relation) }};
{{ get_create_intermediate_sql(target_relation, sql) }};
{{ get_create_backup_sql(existing_relation) }};
{{ get_rename_intermediate_sql(target_relation) }};
{{ get_drop_backup_sql(existing_relation) }}

{# /* create target_relation as an intermediate relation, then swap it out with the existing one using drop */ #}
{%- elif target_relation.can_be_renamed -%}
{{ get_stage_sql(target_relation, sql) }};
{{ get_create_intermediate_sql(target_relation, sql) }};
{{ get_drop_sql(existing_relation) }};
{{ get_deploy_stage_sql(target_relation) }}
{{ get_rename_intermediate_sql(target_relation) }}

{# /* create target_relation in place by first backing up the existing relation */ #}
{%- elif existing_relation.can_be_renamed -%}
{{ get_backup_sql(existing_relation) }};
{{ get_create_backup_sql(existing_relation) }};
{{ get_create_sql(target_relation, sql) }};
{{ get_drop_backup_sql(existing_relation) }}

Expand Down

0 comments on commit a7db607

Please sign in to comment.