Repository navigation
GH-55369: [C++][IPC] Map V4 union child fields when subsetting - #55370
Open
professor-moody wants to merge 2 commits into
Open
professor-moody wants to merge 2 commits into
professor-moody wants to merge 2 commits into
Conversation
|
|
Collaborator
|
@professor-moody Could you follow the Arrow PR template and add AI disclosure checkbox in the PR desc. Thanks! |
Author
|
Thanks @Reranko05! Updated the PR description to follow the Arrow PR template and include the AI disclosure checkboxes. |
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
IpcReadOptions::included_fieldsis set, RecordBatchFileReader reads only the parts of a record batch body that the selected fields need.ReadFieldsSubsetincpp/src/arrow/ipc/message.ccobtains those ranges by running the fields loader against anIoRecordedRandomAccessFile, and that pass (LoadFieldsSubset in reader.cc) uses the default V5 buffer layout.The two layouts differ for unions: with V4 metadata a union array has a validity buffer slot, with V5 it does not. For a V4 message that contains a union column, the recorded ranges therefore belong to the wrong buffers. The batch is then loaded with the message's own V4 layout, from parts of the body buffer that
ReadFieldsSubsetdid not fill, so the selected union column does not hold the values stored in the file. This also affects Feather V2 files, since the Feather reader reads a column subset throughincluded_fields.What changes are included in this PR?
In
ReadFieldsSubset, when the message metadata version is older than V5, the whole body is read into the body buffer after the fields loader has run, instead of only the recorded ranges. V5 messages keep the selective reads.Are these changes tested?
Yes.
cpp/src/arrow/ipc/read_write_test.ccaddsReadFieldSubsetWithUnionsV4RoundTripandReadFieldSubsetWithUnionsV5RoundTripfor the stream reader, the file reader and the two file generator fixtures. Each writes a batch with a sparse union, a dense union and anint32column using the given metadata version, reads several field subsets, checksValidateFull()and compares the result with the expected columns. Without this changeTestFileFormat.ReadFieldSubsetWithUnionsV4RoundTripfails and the V5 tests pass.Are there any user-facing changes?
Reading a subset of fields from a V4 IPC file (or a Feather V2 file written with V4 metadata) that contains union columns now returns the stored values. For messages with pre-V5 metadata a subset read now reads the full message body.
This PR contains a "Critical Fix". Reading a subset of fields from such a file could return values that are not in the file.
Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
PR code and description written by:
Reviewed before submission by: