Skip to content

Commit 3c1ea09

Browse files
committed
Fix: Don't push seed records when migrating snapshot rows (#2535)
1 parent 4bf5e7a commit 3c1ea09

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

sqlmesh/core/state_sync/engine_adapter.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ def push_snapshots(self, snapshots: t.Iterable[Snapshot]) -> None:
207207
if snapshots:
208208
self._push_snapshots(snapshots)
209209

210-
def _push_snapshots(self, snapshots: t.Iterable[Snapshot], overwrite: bool = False) -> None:
210+
def _push_snapshots(
211+
self, snapshots: t.Iterable[Snapshot], overwrite: bool = False, push_seeds: bool = True
212+
) -> None:
211213
if overwrite:
212214
snapshots = tuple(snapshots)
213215
self.delete_snapshots(snapshots)
@@ -221,13 +223,14 @@ def _push_snapshots(self, snapshots: t.Iterable[Snapshot], overwrite: bool = Fal
221223
SnapshotChangeCategory.NON_BREAKING,
222224
):
223225
seed_model = t.cast(SeedModel, snapshot.node)
224-
seed_contents.append(
225-
{
226-
"name": snapshot.name,
227-
"version": snapshot.version,
228-
"content": seed_model.seed.content,
229-
}
230-
)
226+
if push_seeds:
227+
seed_contents.append(
228+
{
229+
"name": snapshot.name,
230+
"version": snapshot.version,
231+
"content": seed_model.seed.content,
232+
}
233+
)
231234
snapshot = snapshot.copy(update={"node": seed_model.to_dehydrated()})
232235
snapshots_to_store.append(snapshot)
233236

@@ -237,7 +240,7 @@ def _push_snapshots(self, snapshots: t.Iterable[Snapshot], overwrite: bool = Fal
237240
columns_to_types=self._snapshot_columns_to_types,
238241
)
239242

240-
if seed_contents:
243+
if push_seeds and seed_contents:
241244
self.engine_adapter.insert_append(
242245
self.seeds_table,
243246
pd.DataFrame(seed_contents),
@@ -1061,7 +1064,7 @@ def _push_new_snapshots() -> None:
10611064
]
10621065
if new_snapshots_to_push:
10631066
logger.info("Pushing %s migrated snapshots", len(new_snapshots_to_push))
1064-
self._push_snapshots(new_snapshots_to_push)
1067+
self._push_snapshots(new_snapshots_to_push, push_seeds=False)
10651068
new_snapshots.clear()
10661069
snapshot_id_mapping.clear()
10671070

0 commit comments

Comments
 (0)