Skip to content

Commit

Permalink
Update to use is_list filter
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Oct 1, 2024
1 parent 19abd41 commit c2c1f76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@
snapshotted_data as (

select *,
{% if strategy.unique_key is iterable and strategy.unique_key is not string and strategy.unique_key is not mapping %}
{{ log("strategy.unique_key is list...." ~ strategy.unique_key, info=true) }}
{% if strategy.unique_key | is_list %}
{% for key in strategy.unique_key %}
{{ key }} as dbt_unique_key_{{ loop.index }}
{%- if not loop.last %} , {%- endif %}
{% endfor %}
{% else %}
{{ log("strategy.unique_key is NOT list...." ~ strategy.unique_key, info=true) }}
{{ strategy.unique_key }} as dbt_unique_key
{% endif %}

Expand All @@ -70,7 +68,7 @@

select
*,
{% if strategy.unique_key is iterable and strategy.unique_key is not string and strategy.unique_key is not mapping %}
{% if strategy.unique_key | is_list %}
{% for key in strategy.unique_key %}
{{ key }} as dbt_unique_key_{{ loop.index }},
{% endfor %}
Expand All @@ -89,7 +87,7 @@

select
*,
{% if strategy.unique_key is iterable and strategy.unique_key is not string and strategy.unique_key is not mapping %}
{% if strategy.unique_key | is_list %}
{% for key in strategy.unique_key %}
{{ key }} as dbt_unique_key_{{ loop.index }},
{% endfor %}
Expand All @@ -109,7 +107,7 @@

select
*,
{% if strategy.unique_key is iterable and strategy.unique_key is not string and strategy.unique_key is not mapping %}
{% if strategy.unique_key | is_list %}
{% for key in strategy.unique_key %}
{{ key }} as dbt_unique_key_{{ loop.index }}
{%- if not loop.last %} , {%- endif %}
Expand All @@ -129,7 +127,7 @@

from insertions_source_data as source_data
left outer join snapshotted_data on
{% if strategy.unique_key is iterable and strategy.unique_key is not string and strategy.unique_key is not mapping %}
{% if strategy.unique_key | is_list %}
{% for key in strategy.unique_key %}
snapshotted_data.dbt_unique_key_{{ loop.index }} = source_data.dbt_unique_key_{{ loop.index }}
{%- if not loop.last %} and {%- endif %}
Expand Down Expand Up @@ -163,7 +161,7 @@

from updates_source_data as source_data
join snapshotted_data on
{% if strategy.unique_key is iterable and strategy.unique_key is not string and strategy.unique_key is not mapping %}
{% if strategy.unique_key | is_list %}
{% for key in strategy.unique_key %}
snapshotted_data.dbt_unique_key_{{ loop.index }} = source_data.dbt_unique_key_{{ loop.index }}
{%- if not loop.last %} and {%- endif %}
Expand Down Expand Up @@ -191,7 +189,7 @@

from snapshotted_data
left join deletes_source_data as source_data on
{% if strategy.unique_key is iterable and strategy.unique_key is not string and strategy.unique_key is not mapping %}
{% if strategy.unique_key | is_list %}
{% for key in strategy.unique_key %}
snapshotted_data.dbt_unique_key_{{ loop.index }} = source_data.dbt_unique_key_{{ loop.index }}
{%- if not loop.last %} and {%- endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
to_relation=target_relation) %}

{% set remove_columns = ['dbt_change_type', 'DBT_CHANGE_TYPE', 'dbt_unique_key', 'DBT_UNIQUE_KEY'] %}
{% if unique_key is sequence and unique_key is not mapping and unique_key is not string %}
{% if unique_key | is_list %}
{% for key in strategy.unique_key %}
{{ remove_columns.append('dbt_unique_key_' + loop.index|string) }}
{{ remove_columns.append('DBT_UNIQUE_KEY_' + loop.index|string) }}
Expand Down

0 comments on commit c2c1f76

Please sign in to comment.