Skip to content

Commit 4472458

Browse files
authored
Fix: Include old snapshot into the previous versions of the migrated snapshot (#1732)
1 parent 2ddb103 commit 4472458

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

sqlmesh/core/state_sync/engine_adapter.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -899,9 +899,6 @@ def _migrate_rows(self) -> None:
899899
if new_snapshot.fingerprint == snapshot.fingerprint:
900900
logger.debug(f"{new_snapshot.snapshot_id} is unchanged.")
901901
continue
902-
if new_snapshot.snapshot_id in all_snapshots:
903-
logger.debug(f"{new_snapshot.snapshot_id} exists.")
904-
continue
905902

906903
new_snapshot_id = new_snapshot.snapshot_id
907904

@@ -919,23 +916,16 @@ def _migrate_rows(self) -> None:
919916
return
920917

921918
def map_data_versions(
922-
name: str, versions: t.Sequence[SnapshotDataVersion]
919+
name: str, versions: t.Tuple[SnapshotDataVersion, ...]
923920
) -> t.Tuple[SnapshotDataVersion, ...]:
924-
version_ids = ((version.snapshot_id(name), version) for version in versions)
925-
926-
return tuple(
927-
new_snapshots[snapshot_id_mapping[version_id]].data_version
928-
if version_id in snapshot_id_mapping
929-
else version
930-
for version_id, version in version_ids
931-
)
921+
if versions and versions[-1].snapshot_id(name) in snapshot_id_mapping:
922+
new_snapshot = new_snapshots[snapshot_id_mapping[versions[-1].snapshot_id(name)]]
923+
return new_snapshot.all_versions
924+
return versions
932925

933926
for from_snapshot_id, to_snapshot_id in snapshot_id_mapping.items():
934927
from_snapshot = all_snapshots[from_snapshot_id]
935928
to_snapshot = new_snapshots[to_snapshot_id]
936-
to_snapshot.previous_versions = map_data_versions(
937-
from_snapshot.name, from_snapshot.previous_versions
938-
)
939929
to_snapshot.indirect_versions = {
940930
name: map_data_versions(name, versions)
941931
for name, versions in from_snapshot.indirect_versions.items()

0 commit comments

Comments
 (0)