Skip to content

Commit

Permalink
Enable setting current value of dbt_valid_to
Browse files Browse the repository at this point in the history
  • Loading branch information
damian3031 committed Dec 18, 2024
1 parent b896295 commit 1438e6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changes/unreleased/Features-20241218-153349.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Features
body: Enable setting current value of dbt_valid_to
time: 2024-12-18T15:33:49.520897+01:00
custom:
Author: damian3031
Issue: ""
PR: "462"
7 changes: 6 additions & 1 deletion dbt/include/trino/macros/materializations/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
on DBT_INTERNAL_SOURCE.{{ columns.dbt_scd_id }} = DBT_INTERNAL_DEST.{{ columns.dbt_scd_id }}

when matched
and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null
{% if config.get("dbt_valid_to_current") %}
and (DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} = {{ config.get('dbt_valid_to_current') }} or
DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null)
{% else %}
and DBT_INTERNAL_DEST.{{ columns.dbt_valid_to }} is null
{% endif %}
and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')
then update
set {{ columns.dbt_valid_to }} = DBT_INTERNAL_SOURCE.{{ columns.dbt_valid_to }}
Expand Down

0 comments on commit 1438e6d

Please sign in to comment.