-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add microbatch strategy This work is basically in entirety a duplicate of the work done by MichelleArk in dbt-labs/dbt-snowflake#1179. I don't really expect this to work first try, but it might. I expect to need to do some edits, but who knows, maybe I'll get lucky. * Add changie doc * Add comment to microbatch macro to explain why we are re-implementing delete+insert * Add `begin` to microbatch config in test_incremental_microbatch.py * Cleanup predicates in microbatch materialization * Fix predicate/incremental predicate logic in microbatch macro * Remove unnecessary `if` in microbatch macro The `if` is unnecessary because predicates are guaranteed to exist, but the `if` was guarding against when there are no predicates. * Get batch start and end time in the same way * Remove unnecessary `target` specifications for columns of predicates in microbatch materialization The `target.` portion of `target.<column_name>` is unnecessary for the predicates in the microbatch materialization macro because the delete statement already ensures the "targeting` of `target` in the delete statement via the clause `delete from {{ target }}`. Said another way, there is no use of the word `using` in the delete clause, thus it is unambiguous what is being deleted from. --------- Co-authored-by: Michelle Ark <MichelleArk@users.noreply.github.com> Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
- Loading branch information
1 parent
1943ac5
commit fccbe2d
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Features | ||
body: Add microbatch strategy | ||
time: 2024-10-02T17:11:12.88725-05:00 | ||
custom: | ||
Author: QMalcolm | ||
Issue: "923" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/functional/adapter/incremental/test_incremental_microbatch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
from dbt.tests.adapter.incremental.test_incremental_microbatch import ( | ||
BaseMicrobatch, | ||
) | ||
|
||
|
||
# No requirement for a unique_id for redshift microbatch! | ||
_microbatch_model_no_unique_id_sql = """ | ||
{{ config(materialized='incremental', incremental_strategy='microbatch', event_time='event_time', batch_size='day', begin=modules.datetime.datetime(2020, 1, 1, 0, 0, 0)) }} | ||
select * from {{ ref('input_model') }} | ||
""" | ||
|
||
|
||
class TestSnowflakeMicrobatch(BaseMicrobatch): | ||
@pytest.fixture(scope="class") | ||
def microbatch_model_sql(self) -> str: | ||
return _microbatch_model_no_unique_id_sql | ||
|
||
@pytest.fixture(scope="class") | ||
def insert_two_rows_sql(self, project) -> str: | ||
test_schema_relation = project.adapter.Relation.create( | ||
database=project.database, schema=project.test_schema | ||
) | ||
return f"insert into {test_schema_relation}.input_model (id, event_time) values (4, '2020-01-04 00:00:00-0'), (5, '2020-01-05 00:00:00-0')" |