Skip to content

Commit

Permalink
Enable setting dbt_valid_to snapshot column to new setting dbt_valid_…
Browse files Browse the repository at this point in the history
…to_current (#152)

Co-authored-by: Kshitij Aranke <kshitij@aranke.org>
  • Loading branch information
gshank and aranke authored Oct 10, 2024
1 parent cb4a953 commit ed94c0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240927-133708.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Enable setting current value of dbt_valid_to
time: 2024-09-27T13:37:08.808843-04:00
custom:
Author: gshank
Issue: "151"
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from {{ source }} as DBT_INTERNAL_SOURCE
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 }}.{{ columns.dbt_valid_to }} is null;
{% if config.get("dbt_valid_to_current") %}
and ({{ target }}.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }} or {{ target }}.{{ columns.dbt_valid_to }} is null);
{% else %}
and {{ target }}.{{ columns.dbt_valid_to }} is null;
{% endif %}


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

0 comments on commit ed94c0d

Please sign in to comment.