Skip to content

Commit ac65e8a

Browse files
committed
Fix: Remove ensure no forward-only revert check
1 parent 4773947 commit ac65e8a

File tree

2 files changed

+0
-70
lines changed

2 files changed

+0
-70
lines changed

sqlmesh/core/plan/builder.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ def build(self) -> Plan:
267267
self._ensure_no_new_snapshots_with_restatements()
268268
self._ensure_new_env_with_changes()
269269
self._ensure_valid_date_range()
270-
self._ensure_no_forward_only_revert()
271270
self._ensure_no_broken_references()
272271

273272
self._apply_effective_from()
@@ -795,27 +794,6 @@ def _ensure_valid_date_range(self) -> None:
795794
f"Plan end date: '{time_like_to_str(end)}' cannot be in the future (execution time: '{time_like_to_str(self.execution_time)}')"
796795
)
797796

798-
def _ensure_no_forward_only_revert(self) -> None:
799-
"""Ensures that a previously superseded breaking / non-breaking snapshot is not being
800-
used again to replace an existing forward-only snapshot with the same version.
801-
802-
In other words there is no going back to the original non-forward-only snapshot with
803-
the same version once a forward-only change for that version has been introduced.
804-
"""
805-
for name, (candidate, promoted) in self._context_diff.modified_snapshots.items():
806-
if (
807-
candidate.snapshot_id not in self._context_diff.new_snapshots
808-
and candidate.is_model
809-
and not candidate.model.forward_only
810-
and promoted.is_forward_only
811-
and not promoted.is_paused
812-
and not candidate.is_no_rebuild
813-
and promoted.version == candidate.version
814-
):
815-
raise PlanError(
816-
f"Attempted to revert to an unrevertable version of model '{name}'. Run `sqlmesh plan` again to mitigate the issue."
817-
)
818-
819797
def _ensure_no_broken_references(self) -> None:
820798
for snapshot in self._context_diff.snapshots.values():
821799
broken_references = {

tests/core/test_plan.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
from sqlmesh.utils.dag import DAG
3838
from sqlmesh.utils.date import (
3939
now,
40-
now_timestamp,
4140
to_date,
4241
to_datetime,
4342
to_timestamp,
@@ -1097,53 +1096,6 @@ def test_end_validation(make_snapshot, mocker: MockerFixture):
10971096
assert restatement_prod_plan_builder.build().end == "2022-01-04"
10981097

10991098

1100-
def test_forward_only_revert_not_allowed(make_snapshot, mocker: MockerFixture):
1101-
snapshot = make_snapshot(SqlModel(name="a", query=parse_one("select 1, ds")))
1102-
snapshot.categorize_as(SnapshotChangeCategory.BREAKING)
1103-
assert not snapshot.is_forward_only
1104-
1105-
forward_only_snapshot = make_snapshot(SqlModel(name="a", query=parse_one("select 2, ds")))
1106-
forward_only_snapshot.categorize_as(SnapshotChangeCategory.BREAKING, forward_only=True)
1107-
forward_only_snapshot.version = snapshot.version
1108-
forward_only_snapshot.unpaused_ts = now_timestamp()
1109-
assert forward_only_snapshot.is_forward_only
1110-
1111-
context_diff = ContextDiff(
1112-
environment="test_environment",
1113-
is_new_environment=True,
1114-
is_unfinalized_environment=False,
1115-
normalize_environment_name=True,
1116-
create_from="prod",
1117-
create_from_env_exists=True,
1118-
added=set(),
1119-
removed_snapshots={},
1120-
modified_snapshots={snapshot.name: (snapshot, forward_only_snapshot)},
1121-
snapshots={snapshot.snapshot_id: snapshot},
1122-
new_snapshots={},
1123-
previous_plan_id=None,
1124-
previously_promoted_snapshot_ids=set(),
1125-
previous_finalized_snapshots=None,
1126-
previous_gateway_managed_virtual_layer=False,
1127-
gateway_managed_virtual_layer=False,
1128-
environment_statements=[],
1129-
)
1130-
1131-
with pytest.raises(
1132-
PlanError,
1133-
match=r"Attempted to revert to an unrevertable version of model.*",
1134-
):
1135-
PlanBuilder(context_diff, forward_only=True).build()
1136-
1137-
# Make sure the plan can be created if a new snapshot version was enforced.
1138-
new_version_snapshot = make_snapshot(
1139-
SqlModel(name="a", query=parse_one("select 1, ds"), stamp="test_stamp")
1140-
)
1141-
snapshot.categorize_as(SnapshotChangeCategory.BREAKING)
1142-
context_diff.modified_snapshots = {snapshot.name: (new_version_snapshot, forward_only_snapshot)}
1143-
context_diff.new_snapshots = {new_version_snapshot.snapshot_id: new_version_snapshot}
1144-
PlanBuilder(context_diff, forward_only=True).build()
1145-
1146-
11471099
def test_forward_only_plan_seed_models(make_snapshot, mocker: MockerFixture):
11481100
snapshot_a = make_snapshot(
11491101
SeedModel(

0 commit comments

Comments
 (0)