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
18 changes: 11 additions & 7 deletions sqlmesh/dbt/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,6 @@ def model_kind(self, context: DbtContext) -> ModelKind:
if field_val is not None:
incremental_by_kind_kwargs[field] = field_val

disable_restatement = self.disable_restatement
if disable_restatement is None:
disable_restatement = (
not self.full_refresh if self.full_refresh is not None else False
)
incremental_kind_kwargs["disable_restatement"] = disable_restatement

if self.time_column:
strategy = self.incremental_strategy or target.default_incremental_strategy(
IncrementalByTimeRangeKind
Expand All @@ -277,11 +270,20 @@ def model_kind(self, context: DbtContext) -> ModelKind:

return IncrementalByTimeRangeKind(
time_column=self.time_column,
disable_restatement=(
self.disable_restatement if self.disable_restatement is not None else False
),
auto_restatement_intervals=self.auto_restatement_intervals,
**incremental_kind_kwargs,
**incremental_by_kind_kwargs,
)

disable_restatement = self.disable_restatement
if disable_restatement is None:
disable_restatement = (
not self.full_refresh if self.full_refresh is not None else False
)

if self.unique_key:
strategy = self.incremental_strategy or target.default_incremental_strategy(
IncrementalByUniqueKeyKind
Expand All @@ -307,6 +309,7 @@ def model_kind(self, context: DbtContext) -> ModelKind:

return IncrementalByUniqueKeyKind(
unique_key=self.unique_key,
disable_restatement=disable_restatement,
**incremental_kind_kwargs,
**incremental_by_kind_kwargs,
)
Expand All @@ -316,6 +319,7 @@ def model_kind(self, context: DbtContext) -> ModelKind:
)
return IncrementalUnmanagedKind(
insert_overwrite=strategy in INCREMENTAL_BY_TIME_STRATEGIES,
disable_restatement=disable_restatement,
**incremental_kind_kwargs,
)
if materialization == Materialization.EPHEMERAL:
Expand Down
2 changes: 1 addition & 1 deletion tests/dbt/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def test_model_kind():
incremental_strategy="merge",
full_refresh=False,
).model_kind(context) == IncrementalByTimeRangeKind(
time_column="foo", dialect="duckdb", forward_only=True, disable_restatement=True
time_column="foo", dialect="duckdb", forward_only=True, disable_restatement=False
)

assert ModelConfig(
Expand Down