[core][spark]: support rewrite_manifest procedure - #9195
Draft
zhongyujiang wants to merge 1 commit into
Draft
Conversation
Add a rewrite_manifest Spark procedure that reads all manifest entries, sorts them globally by partition -> bucket -> level -> fileName (canceling ADD/DELETE pairs of the same file along the way) and writes them back as new manifest files so that ManifestFileMeta statistics become more compact for scan pruning. The sort runs distributed via a Spark sortByKey shuffle. - ManifestEntrySortKey: serializable sort key with byte[] partition for Kryo compatibility and lazy RecordComparator - FileStoreCommit#replaceManifest: optimistic-concurrency commit with conflict detection (containsAll) and concurrent delta preservation - RewriteManifestProcedure: distributed sortByKey + streaming ADD/DELETE cancellation + where clause + auto parallelism - FormatTableCommit: add unsupported replaceManifests - register rewrite_manifest in SparkProcedures - tests: ManifestEntrySortKeyTest (9), FileStoreCommitTest replaceManifest conflict scenarios (3), RewriteManifestProcedureTest (8) Co-Authored-By: Claude <noreply@anthropic.com>
zhongyujiang
marked this pull request as draft
August 12, 2026 12:51
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.
Motivation
Manifest entries are written in commit order, which can become unordered over time. This makes ManifestFileMeta statistics (partitionStats / minBucket / maxBucket / minLevel / maxLevel) loose, reducing manifest-level pruning during scan.
This PR adds a rewrite_manifest Spark procedure that reads all manifest entries, sorts them globally by partition -> bucket -> level -> fileName (canceling ADD/DELETE pairs of the same file), and writes them back as new manifest files with compact statistics.
Usage
An optional where clause restricts the rewrite to manifests whose partition stats may match the predicate; the remaining manifests are left untouched.
Implementation
Tests