Skip to content

fix(arrow-data): account for struct parent offsets - #10934

Merged
Jefffrey merged 2 commits into
apache:mainfrom
jaideeppyne:fix/struct-arraydata-parent-offset
Sep 2, 2026
Merged

Jefffrey merged 2 commits into
apache:mainfrom
jaideeppyne:fix/struct-arraydata-parent-offset

Conversation

@jaideeppyne

Copy link
Copy Markdown
Contributor

Closes #10933.

Struct ArrayData parent offsets compose with child offsets, but a few paths were still treating child data as if parent offset were always zero. This updates:

  • struct child validation to require offset + len child elements
  • struct equality to compare child values at parent_offset + logical_start
  • struct MutableArrayData extension to copy from the parent-offset-adjusted child range

The regression tests cover the concrete cases from #10933: validation, equality, and MutableArrayData::try_extend.

Validation run locally:

cargo test -p arrow-data --lib
cargo fmt --check
cargo clippy -p arrow-data --lib --tests -- -D warnings

@github-actions github-actions Bot added arrow Changes to the arrow crate arrow-data labels Sep 1, 2026

@Rich-T-kid Rich-T-kid 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.

This PR seems to have introduces a bug in test_struct_array_from_data_with_offset_and_length_error

@jaideeppyne
jaideeppyne force-pushed the fix/struct-arraydata-parent-offset branch from bbd1db5 to 79b9203 Compare September 1, 2026 14:59
@jaideeppyne

Copy link
Copy Markdown
Contributor Author

Fixed in 79b9203. I updated the struct ArrayData offset/length regression expectation so it now asserts the new validation error instead of expecting the old late panic. Local validation passed (cargo test -p arrow-array test_struct_array_from_data_with_offset_and_length_error --lib, cargo test -p arrow-data --lib, cargo fmt --check), and the GitHub checks are now green.

@Rich-T-kid Rich-T-kid 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.

looks good to me.

@jaideeppyne

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

Comment thread arrow-array/src/array/struct_array.rs Resolved
Comment thread arrow-data/src/data.rs Resolved
@Jefffrey Jefffrey added the bug Squash those bugs label Sep 2, 2026
@Jefffrey
Jefffrey merged commit 027b45f into apache:main Sep 2, 2026
40 checks passed
@Jefffrey

Jefffrey commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

thanks @jaideeppyne & @Rich-T-kid

Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 18, 2026
Closes apache#10933.

Struct `ArrayData` parent offsets compose with child offsets, but a few
paths were still treating child data as if parent offset were always
zero. This updates:

- struct child validation to require `offset + len` child elements
- struct equality to compare child values at `parent_offset +
logical_start`
- struct `MutableArrayData` extension to copy from the
parent-offset-adjusted child range

The regression tests cover the concrete cases from apache#10933: validation,
equality, and `MutableArrayData::try_extend`.

Validation run locally:

```
cargo test -p arrow-data --lib
cargo fmt --check
cargo clippy -p arrow-data --lib --tests -- -D warnings
```
Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Sep 21, 2026
Closes apache#10933.

Struct `ArrayData` parent offsets compose with child offsets, but a few
paths were still treating child data as if parent offset were always
zero. This updates:

- struct child validation to require `offset + len` child elements
- struct equality to compare child values at `parent_offset +
logical_start`
- struct `MutableArrayData` extension to copy from the
parent-offset-adjusted child range

The regression tests cover the concrete cases from apache#10933: validation,
equality, and `MutableArrayData::try_extend`.

Validation run locally:

```
cargo test -p arrow-data --lib
cargo fmt --check
cargo clippy -p arrow-data --lib --tests -- -D warnings
```
haohuaijin pushed a commit to haohuaijin/arrow-rs that referenced this pull request Oct 17, 2026
…rayData (apache#11636)

# Which issue does this PR close?

- Closes apache#11588.

# Rationale for this change

`MutableArrayData::extend` on a `FixedSizeList` with a nonzero parent
offset copied the child values from the start of the child instead of
from the offset.

# What changes are included in this PR?

`build_extend` in `transform/fixed_size_list.rs` adds `array.offset()`
to `start` before computing the child range, the same way apache#10934 did for
structs.

# Are these changes tested?

Yes, `test_extend_fixed_size_list_accounts_for_parent_offset` in
`arrow-data/src/data.rs` (next to the struct test from apache#10934). It fails
without the fix.

# Are there any significant user-facing changes?

No.

AI use: I used Claude Code to find the cause and write the fix and test.
I reviewed the change and checked that the test fails without the fix.
starpact pushed a commit to starpact/arrow-rs that referenced this pull request Oct 19, 2026
…ayData (apache#11693)

# Which issue does this PR close?

- Closes apache#11686.

# 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
apache#10934 did for structs and apache#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate arrow-array arrow-data bug Squash those bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

struct arraydata edge cases when offsets != 0

3 participants