Skip to content

Commit 08cd4eb

Browse files
authored
Fix: Fetch full environment object one a time to prevent loading all of them at once during restatement (#4768)
1 parent 9a732ae commit 08cd4eb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sqlmesh/core/plan/evaluator.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,13 @@ def _restatement_intervals_across_all_environments(
400400

401401
snapshots_to_restate: t.Dict[SnapshotId, t.Tuple[SnapshotTableInfo, Interval]] = {}
402402

403-
for env in self.state_sync.get_environments():
403+
for env_summary in self.state_sync.get_environments_summary():
404+
# Fetch the full environment object one at a time to avoid loading all environments into memory at once
405+
env = self.state_sync.get_environment(env_summary.name)
406+
if not env:
407+
logger.warning("Environment %s not found", env_summary.name)
408+
continue
409+
404410
keyed_snapshots = {s.name: s.table_info for s in env.snapshots}
405411

406412
# We dont just restate matching snapshots, we also have to restate anything downstream of them

0 commit comments

Comments
 (0)