Core: update manifest delete file size after rewrite table action#15470
Open
mbutrovich wants to merge 3 commits intoapache:mainfrom
Open
Core: update manifest delete file size after rewrite table action#15470mbutrovich wants to merge 3 commits intoapache:mainfrom
mbutrovich wants to merge 3 commits intoapache:mainfrom
Conversation
…ask, eliminating the separate `rewritePositionDeletes()` Spark job. Each manifest-writing task now also rewrites the delete files that manifest references, measures the actual size via `getLength()`, and records it in the manifest entry.
Comment on lines
+407
to
+414
| "1.10.0": | ||
| org.apache.iceberg:iceberg-api: | ||
| - code: "java.class.defaultSerializationChanged" | ||
| old: "class org.apache.iceberg.encryption.EncryptingFileIO" | ||
| new: "class org.apache.iceberg.encryption.EncryptingFileIO" | ||
| justification: "New method for Manifest List reading" | ||
| org.apache.iceberg:iceberg-core: | ||
| - code: "java.class.noLongerInheritsFromClass" |
Contributor
There was a problem hiding this comment.
Was this moved unintentionally?
| // Rewrite inline so the manifest records the actual file size, which changes because | ||
| // embedded data file paths are rewritten. The staging path is deterministic, so | ||
| // duplicates across manifests simply overwrite with identical content. | ||
| String staging = stagingPath(file.location(), sourcePrefix, stagingLocation); |
Contributor
There was a problem hiding this comment.
Nit: Maybe call the variable also stagingPath?
| throw new UncheckedIOException( | ||
| "Failed to rewrite position delete file " + file.location(), e); | ||
| } | ||
| long actualSize = io.newInputFile(staging).getLength(); |
Contributor
There was a problem hiding this comment.
getLength() is a HEAD call, isn't it? I'm wondering if we can get the length from PositionDeleteReaderWriter somehow so we don't need to use getLength().
| rewritePositionDeletes(deleteFiles); | ||
| int rewrittenDeleteFilesCount = | ||
| (int) | ||
| rewriteManifestResult.toRewrite().stream().filter(e -> e instanceof DeleteFile).count(); |
Contributor
There was a problem hiding this comment.
We may have to deduplicate the delete files before counting. Previously we used Collectors.toSet().
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.
Which issue does this PR close?
Closes #12554.
Rationale for this change
rewriteTablePathrewrites position delete files (updating embedded data file paths), which changes their size. The manifest was written before the delete files were rewritten, sofile_size_in_bytesin the manifest reflected the original size. Readers that trust this field (Trino, Impala, Comet, iceberg-rust) fail with errors like "end of stream not reached."What changes are included in this PR?
Moves position delete file rewriting into the manifest-writing Spark task, eliminating the separate
rewritePositionDeletes()Spark job. Each manifest-writing task now also rewrites the delete files that manifest references, measures the actual size viagetLength(), and records it in the manifest entry.This means:
file_size_in_bytesat manifest write time, no reconciliation neededTrade-off: if the same delete file appears in multiple manifests, it gets rewritten redundantly. The staging path is deterministic so the output is identical — wasted I/O, not incorrect. In practice this is rare.
How are these changes tested?
New test
testDeleteFileSizeInBytesAfterRewritecreates a table with position deletes using a deeply nested path (so the rewritten path differs in length), runsrewriteTablePath, copies the result, and asserts thatfile_size_in_bytesin the rewritten manifest matches the actual file size on disk.AI Usage
I am more familiar with the iceberg-rust codebase, so Claude helped me navigate the code, prototype a design, and draft the PR description (in DataFusion Comet's PR template). Claude also helped me with the API change failures in CI.