feat(scan): [3/N] read and apply V3 deletion vectors - #3035
Merged
Conversation
Add referenced_data_file, content_offset, and content_size_in_bytes to FileScanTaskDeleteFile, populated from the delete file's manifest entry. These locate a deletion-vector blob and scope it to its data file, which the delete loader needs to read and apply V3 deletion vectors. Refs apache#2792.
# Conflicts: # crates/iceberg/src/delete_file_index.rs
3 tasks
# Conflicts: # crates/iceberg/src/delete_file_index.rs # crates/iceberg/src/scan/task.rs
mbutrovich
marked this pull request as ready for review
August 27, 2026 15:01
CTTY
approved these changes
Sep 3, 2026
CTTY
left a comment
Collaborator
There was a problem hiding this comment.
LGTM! I have some smaller comments and would be happy if we could address them in a follow up!
| // V3 deletion vectors, keyed by the data file they apply to (referenced_data_file). At most | ||
| // one exists per data file per snapshot, and when one applies it supersedes any position | ||
| // delete files for that data file, partition-scoped or path-scoped alike. | ||
| dvs_by_referenced_data_file: HashMap<String, Arc<DeleteFileContext>>, |
Collaborator
There was a problem hiding this comment.
nit: we can improve the naming consistency here by updating pos_deletes_by_path to pos_deletes_by_referenced_data_file
| /// to fail against, so a bad coordinate would otherwise decode silently into the wrong (or | ||
| /// no) deletes, per the same corrupted-blob concern Iceberg-Java validates in | ||
| /// `BitmapPositionDeleteIndex.deserializeBitmap`. | ||
| fn validate_deletion_vector_task( |
Collaborator
There was a problem hiding this comment.
We should validate this when building FileScanTaskDeleteFile.
isDv == FileScanTaskDeleteFile.content_type == PosDel && FileScanTaskDeleteFile.file_format == puffin
fn build() {
if (isDv) { validate_deletion_vector_task() }
}
Comment on lines
+221
to
+241
| let Some(path) = data_file.referenced_data_file() else { | ||
| return Err(Error::new( | ||
| ErrorKind::DataInvalid, | ||
| format!( | ||
| "deletion vector {} is missing referenced_data_file", | ||
| arc_ctx.manifest_entry.file_path() | ||
| ), | ||
| )); | ||
| }; | ||
|
|
||
| if data_file.content_offset().is_none() | ||
| || data_file.content_size_in_bytes().is_none() | ||
| { | ||
| return Err(Error::new( | ||
| ErrorKind::DataInvalid, | ||
| format!( | ||
| "deletion vector {} is missing content_offset or content_size_in_bytes", | ||
| arc_ctx.manifest_entry.file_path() | ||
| ), | ||
| )); | ||
| } |
Collaborator
There was a problem hiding this comment.
These validations should be moved to FileScanTaskDeleteFile::builder()::build()
I think it would be good to include this in 0.11 and would be happy if we can address this in a follow up
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?
deletion-vector-v1Puffin blobs) #2792.What changes are included in this PR?
Task 3 of the deletion-vector read epic: reading and applying V3 deletion vectors during a scan. Follows #2868, now merged, so this is based on
main.CachingDeleteFileLoaderreads a deletion vector'sdeletion-vector-v1blob directly from its Puffin file by byte range (content_offset/content_size_in_bytes), decrypting first viaEncryptedInputFilewhen the entry carries key metadata.record_count, matching the check Iceberg-Java does inBitmapPositionDeleteIndex.deserializeBitmap. A mismatch is aDataInvaliderror, not a silent wrong result.DeleteFileIndexindexes deletion vectors byreferenced_data_fileand applies them ahead of position delete files, since a DV supersedes any position deletes for the same data file per spec.FileScanTaskDeleteFilegains afile_formatfield, populated from the manifest entry. Both the index and the loader now identify a deletion vector as aPositionDeletesentry stored asPuffin, rather than by the presence ofcontent_offset, per @CTTY's review feedback on feat(scan): [2/N] carry deletion-vector coordinates on FileScanTaskDeleteFile #2868.referenced_data_file,content_offset,content_size_in_bytes, orrecord_count, all of which the spec requiresDeleteVector::deserialize(from feat(delete-vector): [1/N] decode deletion-vector-v1 puffin blobs #2866) is wired in, and its#[allow(dead_code)]removed.The data file read path is unchanged outside of deletion vectors, as is existing position delete and equality delete handling.
Are these changes tested?
Yes.
delete_file_index.rs: DV supersedes partition-scoped and path-scoped position deletes, DV coexists with equality deletes, and rejection of a DV that is missingreferenced_data_fileor its Puffin coordinates, duplicated for one data file, or carrying a mismatched partition or stale sequence number.caching_delete_file_loader.rs: reading and applying a DV, reading an encrypted DV, rejecting a cardinality mismatch, and the coordinate and cardinality validation helpers against each missing or negative field.positional_deletes.rsreading a Parquet data file with a DV applied throughArrowReader, including the cardinality mismatch failure path through the full read.AI Disclosure
Developed with the help of Claude Code, but I understand and support these changes.