You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "thorfour (via GitHub)" <gi...@apache.org> on 2026/01/15 01:54:42 UTC
[PR] fix: take_run return empty array instead of panic. [arrow-rs]
thorfour opened a new pull request, #9182:
URL: https://github.com/apache/arrow-rs/pull/9182
If empty indices were passed into take_run it would panic with an index out of bounds error. Instead of panicing return an invalid argument error.
This was happening when a list array with empty entries were taken.
# Which issue does this PR close?
- Closes #9179.
# Rationale for this change
Causing unexpected panics to occur and is different behavior than `take_impl` for other types.
# What changes are included in this PR?
Check to return an empty run array if no indices are given for take, and a unit test that validates this behavior.
# Are these changes tested?
Yes
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
# Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
If there are any breaking changes to public APIs, please call them out.
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on code in PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#discussion_r2698802705
##########
arrow-select/src/take.rs:
##########
@@ -214,6 +214,10 @@ fn take_impl<IndexType: ArrowPrimitiveType>(
values: &dyn Array,
indices: &PrimitiveArray<IndexType>,
) -> Result<ArrayRef, ArrowError> {
+ if indices.is_empty() {
+ let data = ArrayData::new_empty(values.data_type());
+ return Ok(Arc::new(make_array(data)));
Review Comment:
Oh thanks! Will add
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#discussion_r2694345723
##########
arrow-select/src/take.rs:
##########
@@ -786,6 +786,11 @@ fn take_run<T: RunEndIndexType, I: ArrowPrimitiveType>(
run_array: &RunArray<T>,
logical_indices: &PrimitiveArray<I>,
) -> Result<RunArray<T>, ArrowError> {
+ if logical_indices.is_empty() {
Review Comment:
I agree with @Jefffrey it would be great to move this check up into `take`
However, given this PR is better than what is on main, I think we could also merge it as is
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#issuecomment-3755250554
Okay, expanded the unit test to validate the run array created. Added a fix for the empty null run array case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#issuecomment-3755186730
I actually hit another bug with this. The run array that it creates is invalid.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey merged PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#issuecomment-3764069826
Thanks also @Jefffrey for helping with reviews in arrow-rs -- there seems to be a really large number of PRs recently. And as fast as we review and merge them, they keep coming
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#issuecomment-3762641024
Thanks @thorfour & @alamb
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#discussion_r2696370697
##########
arrow-select/src/take.rs:
##########
@@ -214,6 +214,10 @@ fn take_impl<IndexType: ArrowPrimitiveType>(
values: &dyn Array,
indices: &PrimitiveArray<IndexType>,
) -> Result<ArrayRef, ArrowError> {
+ if indices.is_empty() {
+ let data = ArrayData::new_empty(values.data_type());
+ return Ok(Arc::new(make_array(data)));
Review Comment:
Can use `new_empty_array` here
- https://docs.rs/arrow/latest/arrow/array/fn.new_empty_array.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on code in PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#discussion_r2694437627
##########
arrow-select/src/take.rs:
##########
@@ -786,6 +786,11 @@ fn take_run<T: RunEndIndexType, I: ArrowPrimitiveType>(
run_array: &RunArray<T>,
logical_indices: &PrimitiveArray<I>,
) -> Result<RunArray<T>, ArrowError> {
+ if logical_indices.is_empty() {
Review Comment:
I'm happy to move the check up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#issuecomment-3752799517
This seems like something we should check once in `take_impl` instead of having it inside `take_run` specifically 🤔
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: take_run return empty array instead of panic. [arrow-rs]
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on code in PR #9182:
URL: https://github.com/apache/arrow-rs/pull/9182#discussion_r2694454721
##########
arrow-select/src/take.rs:
##########
@@ -786,6 +786,11 @@ fn take_run<T: RunEndIndexType, I: ArrowPrimitiveType>(
run_array: &RunArray<T>,
logical_indices: &PrimitiveArray<I>,
) -> Result<RunArray<T>, ArrowError> {
+ if logical_indices.is_empty() {
Review Comment:
Moved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org