From 457c361a8453d7e4c09ce9033f872a651646fd6c Mon Sep 17 00:00:00 2001 From: Michelle Ark Date: Thu, 5 Dec 2024 16:42:45 -0500 Subject: [PATCH] [Refactor] use new model.batch context vars (#1258) --- .changes/unreleased/Under the Hood-20241205-144036.yaml | 6 ++++++ dbt/include/snowflake/macros/materializations/merge.sql | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20241205-144036.yaml diff --git a/.changes/unreleased/Under the Hood-20241205-144036.yaml b/.changes/unreleased/Under the Hood-20241205-144036.yaml new file mode 100644 index 000000000..aedcb4ce1 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20241205-144036.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Use new `batch` context variables over `node.config.__dbt_internal` ones +time: 2024-12-05T14:40:36.373637-05:00 +custom: + Author: michelleark + Issue: "1263" diff --git a/dbt/include/snowflake/macros/materializations/merge.sql b/dbt/include/snowflake/macros/materializations/merge.sql index 716a325c1..7515f6010 100644 --- a/dbt/include/snowflake/macros/materializations/merge.sql +++ b/dbt/include/snowflake/macros/materializations/merge.sql @@ -57,10 +57,10 @@ {%- set incremental_predicates = [] if arg_dict.get('incremental_predicates') is none else arg_dict.get('incremental_predicates') -%} {#-- Add additional incremental_predicates to filter for batch --#} - {% if model.config.get("__dbt_internal_microbatch_event_time_start") -%} + {% if model.batch and model.batch.event_time_start -%} {% do incremental_predicates.append("DBT_INTERNAL_TARGET." ~ model.config.event_time ~ " >= to_timestamp_tz('" ~ model.config.__dbt_internal_microbatch_event_time_start ~ "')") %} {% endif %} - {% if model.config.__dbt_internal_microbatch_event_time_end -%} + {% if model.batch and model.batch.event_time_end -%} {% do incremental_predicates.append("DBT_INTERNAL_TARGET." ~ model.config.event_time ~ " < to_timestamp_tz('" ~ model.config.__dbt_internal_microbatch_event_time_end ~ "')") %} {% endif %} {% do arg_dict.update({'incremental_predicates': incremental_predicates}) %}