Skip to content

Commit

Permalink
Fix: Snapshot parsing during migration (#3022)
Browse files Browse the repository at this point in the history
  • Loading branch information
izeigerman authored Aug 18, 2024
1 parent a3e8b82 commit 1756ca0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions sqlmesh/core/state_sync/engine_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,10 +1325,17 @@ def _migrate_snapshot_rows(
) -> t.Dict[SnapshotId, SnapshotTableInfo]:
logger.info("Migrating snapshot rows...")
raw_snapshots = {
SnapshotId(name=name, identifier=identifier): json.loads(raw_snapshot)
SnapshotId(name=name, identifier=identifier): {
**json.loads(raw_snapshot),
"updated_ts": updated_ts,
"unpaused_ts": unpaused_ts,
"unrestorable": unrestorable,
}
for where in (self._snapshot_id_filter(snapshots) if snapshots is not None else [None])
for name, identifier, raw_snapshot in self._fetchall(
exp.select("name", "identifier", "snapshot")
for name, identifier, raw_snapshot, updated_ts, unpaused_ts, unrestorable in self._fetchall(
exp.select(
"name", "identifier", "snapshot", "updated_ts", "unpaused_ts", "unrestorable"
)
.from_(self.snapshots_table)
.where(where)
.lock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def migrate(state_sync, **kwargs): # type: ignore
"name": name,
"identifier": identifier,
"version": version,
"snapshot": snapshot,
"snapshot": json.dumps(parsed_snapshot),
"kind_name": kind_name,
"updated_ts": updated_ts,
"unpaused_ts": unpaused_ts,
Expand Down

0 comments on commit 1756ca0

Please sign in to comment.