Skip to content

Commit

Permalink
Set parent_snapshot_id to None
Browse files Browse the repository at this point in the history
  • Loading branch information
grihabor committed Jan 23, 2025
1 parent 818f771 commit 9b31690
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyiceberg/table/update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ def _(update: RemoveSnapshotsUpdate, base_metadata: TableMetadata, context: _Tab
if not any(s.snapshot_id == remove_snapshot_id for s in base_metadata.snapshots):
raise ValueError(f"Snapshot with snapshot id {remove_snapshot_id} does not exist: {base_metadata.snapshots}")

snapshots = [s for s in base_metadata.snapshots if s.snapshot_id not in update.snapshot_ids]
snapshots = [
(s.model_copy(update={"parent_snapshot_id": None}) if s.parent_snapshot_id in update.snapshot_ids else s)
for s in base_metadata.snapshots
if s.snapshot_id not in update.snapshot_ids
]
context.add_update(update)
return base_metadata.model_copy(update={"snapshots": snapshots})

Expand Down

0 comments on commit 9b31690

Please sign in to comment.