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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]