Skip to content

Drop deleted-only parent manifests in _OverwriteFiles - #4631

Open
faisal37990 wants to merge 1 commit into
apache:mainfrom
faisal37990:fix/overwrite-drop-deleted-only-manifests
Open

faisal37990 wants to merge 1 commit into
apache:mainfrom
faisal37990:fix/overwrite-drop-deleted-only-manifests

Conversation

@faisal37990

Copy link
Copy Markdown

Closes #4165.

Summary

  • Skip parent manifests with no live entries (not (has_added_files() or has_existing_files() or added_snapshot_id == self._snapshot_id)) in _OverwriteFiles._existing_manifests, matching _FastAppendFiles._existing_manifests and Java Iceberg's MergingSnapshotProducer.apply.
  • Skip deleted-only parent manifests in _OverwriteFiles._deleted_entries (_get_entries) before partition evaluation and Avro entry reads so prior delete manifests are neither retained nor re-opened on subsequent overwrites.
  • Preserves v1 manifests with unknown (None) file counts since has_added_files() / has_existing_files() return True when counts are None, and drops prior deleted-only manifests even across unrelated partitions by filtering before partition evaluation.

Testing

  • Added 3 regression tests in tests/table/test_snapshots.py:
    • test_overwrite_drops_previous_deleted_only_manifests (5 sequential explicit overwrites keep manifest count bounded at 2 instead of growing linearly)
    • test_overwrite_drops_deleted_only_manifests_across_partitions (verifies prior deleted-only manifest from partition a is dropped when overwriting partition b while preserving a's live manifest)
    • test_overwrite_skips_reading_deleted_only_manifests (verifies prior deleted-only manifests are never fetched during subsequent overwrites)
  • Verified locally: pytest tests/table/test_snapshots.py (61 passed), pytest tests/table/test_commit_retry.py (all passed), ruff check, and ruff format --check.

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix @faisal37990! Verified the predicate matches Java, where MergingSnapshotProducer.apply keeps manifests with hasAddedFiles() || hasExistingFiles() || snapshotId == snapshotId(). Good test coverage for the cross-partition case too. LGTM 🚀

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overwrite keeps deleted-only manifests, so the manifest list grows by one on every overwrite

2 participants