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/14 19:31:02 UTC
[I] take_run panics when given empty indicies [arrow-rs]
thorfour opened a new issue, #9179:
URL: https://github.com/apache/arrow-rs/issues/9179
**Describe the bug**
`index out of bounds: the len is 0 but the index is 18446744073709551615`
**To Reproduce**
```rust
#[test]
fn test_take_run_empty_indices() {
let mut builder = PrimitiveRunBuilder::<Int32Type, Int32Type>::new();
builder.extend([Some(1), Some(1), Some(2), Some(2)]);
let run_array = builder.finish();
let logical_indices: PrimitiveArray<Int32Type> = PrimitiveArray::from(Vec::<i32>::new());
let result = take_run(&run_array, &logical_indices);
assert!(matches!(result, Err(ArrowError::InvalidArgumentError(_))));
}
```
**Expected behavior**
I would expect either an empty array returned or an invalid argument error.
**Additional context**
We have a call to `take_record_batch` that is somehow causing `take_run` to be called with an empty indices array and causing this panic. Note that our call to `take_record_batch` does not use an empty indices array.
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] take_run panics when given empty indicies [arrow-rs]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey closed issue #9179: take_run panics when given empty indicies
URL: https://github.com/apache/arrow-rs/issues/9179
--
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: [I] take_run panics when given empty indicies [arrow-rs]
Posted by "thorfour (via GitHub)" <gi...@apache.org>.
thorfour commented on issue #9179:
URL: https://github.com/apache/arrow-rs/issues/9179#issuecomment-3752448094
```rust
#[test]
#[should_panic(expected = "attempt to subtract with overflow")]
fn test_take_record_batch_list_of_struct_with_ree_multiple_empty_lists_fails() {
use arrow::array::builder::{ListBuilder, StringBuilder, StringRunBuilder, StructBuilder};
use arrow::compute::take_record_batch;
let ree_field = Field::new(
"value",
DataType::RunEndEncoded(
Arc::new(Field::new("run_ends", DataType::Int32, false)),
Arc::new(Field::new("values", DataType::Utf8, true)),
),
true,
);
let struct_fields = vec![Field::new("name", DataType::Utf8, true), ree_field.clone()];
let struct_builder = StructBuilder::new(
struct_fields.clone(),
vec![
Box::new(StringBuilder::new()),
Box::new(StringRunBuilder::<Int32Type>::new()),
],
);
let mut list_builder = ListBuilder::new(struct_builder);
// Row 0: empty list
list_builder.append(true);
// Row 1: list with 1 struct element
{
let struct_builder = list_builder.values();
struct_builder
.field_builder::<StringBuilder>(0)
.unwrap()
.append_value("item_a");
struct_builder
.field_builder::<StringRunBuilder<Int32Type>>(1)
.unwrap()
.append_value("ree_value_1");
struct_builder.append(true);
}
list_builder.append(true);
// Row 2: empty list
list_builder.append(true);
// Row 3: empty list
list_builder.append(true);
let list_array = list_builder.finish();
let schema = Arc::new(Schema::new(vec![Field::new(
"data",
list_array.data_type().clone(),
true,
)]));
let batch = RecordBatch::try_new(schema, vec![Arc::new(list_array)]).unwrap();
println!("Batch: {batch:?}");
// Taking multiple empty list rows (indices 0, 2, 3) - all empty lists
// Even though we have 3 indices, they all point to empty lists, so
// take_value_indices_from_list returns an empty values array
let indices = UInt32Array::from(vec![0, 2, 3]);
let _ = take_record_batch(&batch, &indices);
}
```
Was able to create a unit test that exacerbates this behavior. Taking from a list array with empty element in the list.
--
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