Skip to content

Commit

Permalink
dbt-postgres 'microbatch' strategy (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk authored Sep 12, 2024
1 parent 6e4a8e3 commit a676c4e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240911-141416.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: 'Microbatch incremental strategy implementation: merge'
time: 2024-09-11T14:14:16.538536-04:00
custom:
Author: michelleark
Issue: "149"
2 changes: 1 addition & 1 deletion dbt/adapters/postgres/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def valid_incremental_strategies(self):
"""The set of standard builtin strategies which this adapter supports out-of-the-box.
Not used to validate custom strategies defined by end users.
"""
return ["append", "delete+insert", "merge"]
return ["append", "delete+insert", "merge", "microbatch"]

def debug_query(self):
self.execute("select 1 as id")
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
{% endif %}

{% endmacro %}


{% macro postgres__get_incremental_microbatch_sql(arg_dict) %}

{% if arg_dict["unique_key"] %}
{% do return(adapter.dispatch('get_incremental_merge_sql', 'dbt')(arg_dict)) %}
{% else %}
{{ exceptions.raise_compiler_error("dbt-postgres 'microbatch' requires a `unique_key` config") }}
{% endif %}

{% endmacro %}
7 changes: 7 additions & 0 deletions tests/functional/adapter/test_incremental_microbatch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from dbt.tests.adapter.incremental.test_incremental_microbatch import (
BaseMicrobatch,
)


class TestPostgresMicrobatch(BaseMicrobatch):
pass

0 comments on commit a676c4e

Please sign in to comment.