Skip to content

Commit

Permalink
fix: respect disable restate dev unpaused snapshots (#3840)
Browse files Browse the repository at this point in the history
  • Loading branch information
eakmanrq authored and izeigerman committed Feb 14, 2025
1 parent 56990fe commit 70ddf0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sqlmesh/core/plan/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def is_restateable_snapshot(snapshot: Snapshot) -> bool:
if not snapshot:
raise PlanError(f"Cannot restate model '{model_fqn}'. Model does not exist.")
if not forward_only_preview_needed:
if not self._is_dev and snapshot.disable_restatement:
if (not self._is_dev or not snapshot.is_paused) and snapshot.disable_restatement:
# This is a warning but we print this as error since the Console is lacking API for warnings.
self._console.log_error(
f"Cannot restate model '{model_fqn}'. "
Expand Down
6 changes: 6 additions & 0 deletions tests/core/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,12 @@ def test_disable_restatement(make_snapshot, mocker: MockerFixture):
snapshot.snapshot_id: (to_timestamp(plan.start), to_timestamp(to_date("today")))
}

# We don't want to restate a disable_restatement model if it is unpaused since that would be mean we are violating
# the model kind property
snapshot.unpaused_ts = 9999999999
plan = PlanBuilder(context_diff, schema_differ, is_dev=True, restate_models=['"a"']).build()
assert plan.restatements == {}


def test_revert_to_previous_value(make_snapshot, mocker: MockerFixture):
"""
Expand Down

0 comments on commit 70ddf0c

Please sign in to comment.