Skip to content

Commit 8fbf26c

Browse files
authored
Fix: Revert "Fix: Use merge when updating auto restatements (#5016)" (#5108)
1 parent 49b5574 commit 8fbf26c

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

sqlmesh/core/state_sync/db/snapshot.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,31 +373,25 @@ def update_auto_restatements(
373373
Args:
374374
next_auto_restatement_ts: A dictionary of snapshot name version to the next auto restatement timestamp.
375375
"""
376-
next_auto_restatement_ts_deleted = []
377-
next_auto_restatement_ts_filtered = {}
378-
for k, v in next_auto_restatement_ts.items():
379-
if v is None:
380-
next_auto_restatement_ts_deleted.append(k)
381-
else:
382-
next_auto_restatement_ts_filtered[k] = v
383-
384376
for where in snapshot_name_version_filter(
385377
self.engine_adapter,
386-
next_auto_restatement_ts_deleted,
378+
next_auto_restatement_ts,
387379
column_prefix="snapshot",
388380
alias=None,
389381
batch_size=self.SNAPSHOT_BATCH_SIZE,
390382
):
391383
self.engine_adapter.delete_from(self.auto_restatements_table, where=where)
392384

385+
next_auto_restatement_ts_filtered = {
386+
k: v for k, v in next_auto_restatement_ts.items() if v is not None
387+
}
393388
if not next_auto_restatement_ts_filtered:
394389
return
395390

396-
self.engine_adapter.merge(
391+
self.engine_adapter.insert_append(
397392
self.auto_restatements_table,
398393
_auto_restatements_to_df(next_auto_restatement_ts_filtered),
399394
columns_to_types=self._auto_restatement_columns_to_types,
400-
unique_key=(exp.column("snapshot_name"), exp.column("snapshot_version")),
401395
)
402396

403397
def count(self) -> int:

0 commit comments

Comments
 (0)