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 6797529 commit ba7c611
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dbt/include/spark/macros/materializations/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


{% macro spark__snapshot_merge_sql(target, source, insert_cols) -%}
{%- 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() -%}

merge into {{ target }} as DBT_INTERNAL_DEST
{% if target.is_iceberg %}
Expand All @@ -22,12 +22,12 @@
{% else %}
using {{ source }} as DBT_INTERNAL_SOURCE
{% endif %}
on DBT_INTERNAL_SOURCE.{{ stcn.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ stcn.dbt_scd_id }}
on DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ columns.dbt_scd_id }}
when matched
and DBT_INTERNAL_DEST.{{ stcn.dbt_valid_to }} is null
and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null
and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')
then update
set {{ stcn.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ stcn.dbt_valid_to }}
set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }}

when not matched
and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'
Expand Down Expand Up @@ -135,9 +135,9 @@

{% else %}

{% 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() %}

{{ adapter.valid_snapshot_target(target_relation, stcn) }}
{{ adapter.valid_snapshot_target(target_relation, columns) }}

{% set staging_table = spark_build_snapshot_staging_table(strategy, sql, target_relation) %}

Expand Down

0 comments on commit ba7c611

Please sign in to comment.