Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230211-163236.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Add merge as valid incremental strategy for postgres
time: 2023-02-11T16:32:36.2260502+01:00
custom:
Author: rainermensing
Issue: "1880"
2 changes: 1 addition & 1 deletion plugins/postgres/dbt/adapters/postgres/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,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"]
return ["append", "delete+insert", "merge"]

def debug_query(self):
self.execute("select 1 as id")
9 changes: 5 additions & 4 deletions tests/functional/materializations/test_incremental.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ def test_basic(project):
assert macro_func
assert type(macro_func).__name__ == "MacroGenerator"

# These two incremental strategies are not valid for Postgres
with pytest.raises(DbtRuntimeError) as excinfo:
macro_func = project.adapter.get_incremental_strategy_macro(context, "merge")
assert "merge" in str(excinfo.value)
# This incremental strategy only works for Postgres >= 15
macro_func = project.adapter.get_incremental_strategy_macro(context, "merge")
assert macro_func
assert type(macro_func).__name__ == "MacroGenerator"

# This incremental strategy is not valid for Postgres
with pytest.raises(DbtRuntimeError) as excinfo:
macro_func = project.adapter.get_incremental_strategy_macro(context, "insert_overwrite")
assert "insert_overwrite" in str(excinfo.value)