Repository navigation
Remove partition statistics of removed snapshots - #4364
Open
ShivamSharma43 wants to merge 1 commit into
Open
ShivamSharma43 wants to merge 1 commit into
ShivamSharma43 wants to merge 1 commit into
Conversation
RemoveSnapshotsUpdate dropped the statistics files of removed snapshots but kept their partition statistics files, so expire_snapshots left partition-statistics entries that point at snapshots that no longer exist. Iceberg Java removes both in TableMetadata.Builder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012XPuJeHi7A5CeHSKHjHmwx
ebyhr
approved these changes
Nov 13, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
When a snapshot is removed (
RemoveSnapshotsUpdate, whichexpire_snapshotsuses), pyiceberg removes the snapshot's statistics files but keeps its partition statistics files. After expiring a snapshot, the table metadata still haspartition-statisticsentries pointing at a snapshot that is gone.Iceberg Java removes both in
TableMetadata.Builder.rewriteSnapshotsInternal:This adds the same removal for partition statistics, next to the existing one for statistics. A REST catalog server applies the update itself, so you mostly see this with catalogs where pyiceberg writes the metadata (SQL, Glue, Hive, DynamoDB). The test for #4201 works around the same gap by patching
commit_tableto drop these entries.I didn't find an existing issue for this.
Are these changes tested?
Yes. I added
test_update_remove_snapshots_with_partition_statisticstotests/table/test_expire_snapshots.py, next to the existing statistics test. It fails onmain(the partition statistics entry for the removed snapshot is still there) and passes with this change.prek runpasses on the changed files.Are there any user-facing changes?
After
expire_snapshots, table metadata no longer lists partition statistics for snapshots that were removed.AI disclosure
I used Claude Code (AI) to find this gap by comparing pyiceberg with Iceberg Java, and to write the fix and the test. I reviewed the change. One thing I'm not sure about: I kept the removal in the
RemoveSnapshotsUpdatehandler, applied as internalRemovePartitionStatisticsUpdates the same way the statistics removal already works. I did not add a matching cleanup of the partition statistics files on storage. That belongs with the file-cleanup work in #4201.🤖 Generated with Claude Code
https://claude.ai/code/session_012XPuJeHi7A5CeHSKHjHmwx