Skip to content

Commit

Permalink
Change stcn to columns
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Sep 18, 2024
1 parent 1914c7c commit b8a7d1f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
{% macro postgres__snapshot_merge_sql(target, source, insert_cols) -%}
{%- set insert_cols_csv = insert_cols | join(', ') -%}

{%- set stcn = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() -%}
{%- set columns = config.get("snapshot_table_column_names") or get_snapshot_table_column_names() -%}

update {{ target }}
set {{ stcn.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ stcn.dbt_valid_to }}
set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }}
from {{ source }} as DBT_INTERNAL_SOURCE
where DBT_INTERNAL_SOURCE.{{ stcn.dbt_scd_id }}::text = {{ target }}.{{ stcn.dbt_scd_id }}::text
where DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }}::text = {{ target }}.{{ columns.dbt_scd_id }}::text
and DBT_INTERNAL_SOURCE.dbt_change_type::text in ('update'::text, 'delete'::text)
and {{ target }}.{{ stcn.dbt_valid_to }} is null;
and {{ target }}.{{ columns.dbt_valid_to }} is null;

insert into {{ target }} ({{ insert_cols_csv }})
select {% for column in insert_cols -%}
Expand Down

0 comments on commit b8a7d1f

Please sign in to comment.