Skip to content

fix(arrow-data): account for sparse union parent offset in MutableArrayData - #11693

Merged
Jefffrey merged 1 commit into
apache:mainfrom
ump45nose:fix/mutable-sparse-union-offset
Oct 19, 2026
Merged

Jefffrey merged 1 commit into
apache:mainfrom
ump45nose:fix/mutable-sparse-union-offset

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

MutableArrayData::extend on sparse union ArrayData with 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, and array.buffer::<i8>(0) applies the offset only to the type ids.

What changes are included in this PR?

build_extend_sparse in arrow-data/src/transform/union.rs adds array.offset() to start before 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_offset in arrow-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, child a comes 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 --lib and cargo 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.

@github-actions github-actions Bot added the arrow-core Core crates related to representing arrow data label Oct 18, 2026

@Jefffrey Jefffrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@Jefffrey Jefffrey added the bug Squash those bugs label Oct 19, 2026
@Jefffrey
Jefffrey added this pull request to the merge queue Oct 19, 2026
Merged via the queue into apache:main with commit 3327fbe Oct 19, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow-core Core crates related to representing arrow data bug Squash those bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MutableArrayData::extend ignores the offset of sparse union ArrayData

2 participants