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 (#1113)
  • Loading branch information
gshank authored Oct 15, 2024
1 parent e6e1e10 commit 805a08e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240927-133927.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:39:27.268886-04:00
custom:
Author: gshank
Issue: "1112"
7 changes: 6 additions & 1 deletion dbt/include/spark/macros/materializations/snapshot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
{% endif %}
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
6 changes: 5 additions & 1 deletion tests/functional/adapter/test_python_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def model(dbt, spark):


@pytest.mark.skip_profile(
"apache_spark", "spark_session", "databricks_sql_endpoint", "spark_http_odbc"
"apache_spark",
"spark_session",
"databricks_sql_endpoint",
"spark_http_odbc",
"databricks_http_cluster",
)
class TestChangingSchemaSpark:
"""
Expand Down

0 comments on commit 805a08e

Please sign in to comment.