Skip to content

Validate interleave indices before dispatch#10175

Open
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix-interleave-index-validation
Open

Validate interleave indices before dispatch#10175
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix-interleave-index-validation

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

What changed

interleave(values, indices) now validates every user-provided (array_idx, row_idx) before dispatching to specialized implementations. It returns ArrowError::InvalidArgumentError when an index references a missing input array or a row past the selected array length.

The regression tests cover an out-of-bounds array index, an out-of-bounds row index, and the StringViewArray specialized path that previously could reach direct view indexing.

Why

interleave is a public API, and invalid external indices should be reported as Arrow errors instead of reaching specialized kernels that can panic while indexing arrays or byte views.

Validation

  • cargo fmt --package arrow-select
  • cargo test -p arrow-select out_of_bounds

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jun 21, 2026
return Ok(new_empty_array(data_type));
}

validate_interleave_indices(values, indices)?;

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 think the cost of this separate pass will be quite high, other kernels don't do this (or make it optional).

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.

That makes sense. Would you prefer making this optional, similar to take bounds checking, or keeping the fast path unchanged and documenting that invalid indices may panic?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants