Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 5cc5d22

Browse files
authored
Use timestamp_tz type in microbatch delete DDL (#1257)
1 parent 54999b2 commit 5cc5d22

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Use timestamp_tz type in microbatch `delete` DDL
3+
time: 2024-11-27T16:22:04.103212-05:00
4+
custom:
5+
Author: michelleark
6+
Issue: "1256"

dbt/include/snowflake/macros/materializations/merge.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@
5858

5959
{#-- Add additional incremental_predicates to filter for batch --#}
6060
{% if model.config.get("__dbt_internal_microbatch_event_time_start") -%}
61-
{% do incremental_predicates.append("DBT_INTERNAL_TARGET." ~ model.config.event_time ~ " >= TIMESTAMP '" ~ model.config.__dbt_internal_microbatch_event_time_start ~ "'") %}
61+
{% do incremental_predicates.append("DBT_INTERNAL_TARGET." ~ model.config.event_time ~ " >= to_timestamp_tz('" ~ model.config.__dbt_internal_microbatch_event_time_start ~ "')") %}
6262
{% endif %}
6363
{% if model.config.__dbt_internal_microbatch_event_time_end -%}
64-
{% do incremental_predicates.append("DBT_INTERNAL_TARGET." ~ model.config.event_time ~ " < TIMESTAMP '" ~ model.config.__dbt_internal_microbatch_event_time_end ~ "'") %}
64+
{% do incremental_predicates.append("DBT_INTERNAL_TARGET." ~ model.config.event_time ~ " < to_timestamp_tz('" ~ model.config.__dbt_internal_microbatch_event_time_end ~ "')") %}
6565
{% endif %}
6666
{% do arg_dict.update({'incremental_predicates': incremental_predicates}) %}
6767

tests/functional/adapter/test_incremental_microbatch.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
BaseMicrobatch,
44
)
55

6+
# Create input with UTC timestamps
7+
_input_model_sql = """
8+
{{ config(materialized='table', event_time='event_time') }}
9+
select 1 as id, to_timestamp_tz('2020-01-01 00:00:00-0') as event_time
10+
union all
11+
select 2 as id, to_timestamp_tz('2020-01-02 00:00:00-0') as event_time
12+
union all
13+
select 3 as id, to_timestamp_tz('2020-01-03 00:00:00-0') as event_time
14+
"""
15+
616

717
# No requirement for a unique_id for snowflake microbatch!
818
_microbatch_model_no_unique_id_sql = """
@@ -16,6 +26,10 @@ class TestSnowflakeMicrobatch(BaseMicrobatch):
1626
def microbatch_model_sql(self) -> str:
1727
return _microbatch_model_no_unique_id_sql
1828

29+
@pytest.fixture(scope="class")
30+
def input_model_sql(self) -> str:
31+
return _input_model_sql
32+
1933
@pytest.fixture(scope="class")
2034
def insert_two_rows_sql(self, project) -> str:
2135
test_schema_relation = project.adapter.Relation.create(

0 commit comments

Comments
 (0)