Skip to content

fix: account for offsets in runarrays when using extend for MutableArrayData - #11546

Merged
Jefffrey merged 2 commits into
apache:mainfrom
Jefffrey:run-extend-offsets
Oct 15, 2026
Merged

Jefffrey merged 2 commits into
apache:mainfrom
Jefffrey:run-extend-offsets

Conversation

@Jefffrey

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

None

Rationale for this change

Correctness edge case when using RunArrays in MutableArrayData

What changes are included in this PR?

  • Account for ArrayData offset of RunArrays when extending MutableArrayData
  • Checked conversion of usize length to Run index type to avoid wrapping

Are these changes tested?

Yes

Are there any significant user-facing changes?

No

@Jefffrey Jefffrey added the bug Squash those bugs label Oct 14, 2026
@github-actions github-actions Bot added the arrow-core Core crates related to representing arrow data label Oct 14, 2026
($run_end_type:ty) => {{
let last_run_end = get_last_run_end::<$run_end_type>(&mutable.child_data[0]);
let new_value = last_run_end
.checked_add(<$run_end_type as ArrowNativeType>::usize_as(len))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

len is a usize, if it is > i16::MAX and the run index type is i16 the this could wrap to negative

swapping in from_usize which can chain into checked_add and share the same ok_or_else flow

macro_rules! build_and_process_impl {
($run_end_type:ty) => {{
let source_buffer = &source_buffer.typed_data()
[source_buffer_offset..source_buffer_offset + source_buffer_len];

@Jefffrey Jefffrey Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in practice it would be uncommon to have a runarray hit this case, of having a runs child arraydata with an offset as it requires manual construction via arraydata

@alamb alamb 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.

Thank you -- makes sense to me @Jefffrey

}

#[test]
fn test_extend_nulls_overflow() {

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.

I verified this fails as expected without this change

---- transform::run::tests::test_extend_accounts_for_offset stdout ----

thread 'transform::run::tests::test_extend_accounts_for_offset' (57027272) panicked at arrow-data/src/transform/run.rs:112:53:
called `Option::unwrap()` on a `None` value

---- transform::run::tests::test_extend_nulls_overflow stdout ----

thread 'transform::run::tests::test_extend_nulls_overflow' (57027278) panicked at arrow-data/src/transform/run.rs:722:67:
called `Result::unwrap_err()` on an `Ok` value: ()

@alamb
alamb added this pull request to the merge queue Oct 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 14, 2026
@Jefffrey
Jefffrey added this pull request to the merge queue Oct 15, 2026
@Jefffrey

Copy link
Copy Markdown
Contributor Author

thanks @alamb

@etseidl

etseidl commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@Jefffrey you might want to merge from main before adding this to the queue...all the queued jobs today failed on audit. The fix for this just merged in #11562.

@Jefffrey

Copy link
Copy Markdown
Contributor Author

@Jefffrey you might want to merge from main before adding this to the queue...all the queued jobs today failed on audit. The fix for this just merged in #11562.

i thought merge queue would merge up from main when running the CI 🤔

@etseidl

etseidl commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Guess we'll see...I wasn't sure so I've been merging before re-queuing. Maybe that's not necessary 🤷

Looks like you're right...audit check is passing now. TIL

Merged via the queue into apache:main with commit 2e26ab4 Oct 15, 2026
34 checks passed
@Jefffrey
Jefffrey deleted the run-extend-offsets branch October 15, 2026 04:17
Jefffrey added a commit that referenced this pull request Oct 21, 2026
…end for MutableArrayData (#11671)

- Backport #11546
- For inclusion in #11664

Cherry-pick of
2e26ab4

---------

Co-authored-by: Andrew Lamb <[email protected]>
alamb pushed a commit that referenced this pull request Oct 22, 2026
…end for MutableArrayData (#11761)

- Backport #11546
- For inclusion in #11665

Cherry-pick of
2e26ab4
alamb pushed a commit that referenced this pull request Oct 22, 2026
…end for MutableArrayData (#11815)

- Backport #11546
- For inclusion in #11666

Cherry-pick of
2e26ab4
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.

3 participants