Repository navigation
fix(arrow-data): account for sparse union parent offset in MutableArrayData - #11693
Merged
Merged
Conversation
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?
MutableArrayData::extendignores the offset of sparse unionArrayData#11686.Rationale for this change
MutableArrayData::extendon sparse unionArrayDatawith a nonzero offset took the type ids from the right rows but copied the children's values from the rows before the offset. So each type id was paired with the wrong value. A sparse union's children are not sliced by the parent's offset, andarray.buffer::<i8>(0)applies the offset only to the type ids.What changes are included in this PR?
build_extend_sparseinarrow-data/src/transform/union.rsaddsarray.offset()tostartbefore it extends the children, the same way #10934 did for structs and #11636 did for fixed size lists. The overflow checks match those two fixes. Dense unions are not changed, because their offsets buffer already gives each row's child index.Are these changes tested?
Yes.
test_extend_sparse_union_accounts_for_parent_offsetinarrow-data/src/data.rs(next to the struct and fixed size list tests) builds a sparse union with two children and offset 1, extends it, and checks the type ids and both children. Without the fix, childacomes back as[10, 20]instead of[20, 30].I also ran
cargo test -p arrow-data,cargo test -p arrow --test array_transform,cargo test -p arrow-select --libandcargo clippy -p arrow-data --all-targets -- -D warnings.Are there any significant user-facing changes?
No.
AI disclosure: I used an AI coding assistant to write the fix, the test and this description, and I reviewed all of it. The part worth a reviewer's look is that the type ids keep using the already offset buffer while only the children get the added offset.