`take` rejects a null index into an empty struct or fixed-size list whose child cannot hold a null
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start in arrow-select/src/take.rs: take_masked_child (around lines 519-537) hands an empty child to take_impl with null indices intact, and test_take_null_indices_masked_by_parent (around lines 3436-3451) currently asserts the error. Compare it with take_sparse_union_child (around lines 503-514), which builds a null array and drops its null buffer for the same empty case. Run the reproducer from the issue, then the arrow-select take tests; done means the three failing calls return Ok(1) and the empty union-with-no-fields error still stands.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
#12365 fixed #11608 for a non-empty parent. A null index into a struct or fixed-size list of length 0 still fails when a child is run-end encoded with a non-nullable values field, or is a union with no nullable field. A parent sliced to length 0 fails the same way. take of a null index from an empty Int32Array returns one null row, and the parent's validity can hold that null here too.
take_masked_child passes an empty child to take_impl with the null indices unchanged, because it has no value to use as a dummy. test_take_null_indices_masked_by_parent checks that error.
To Reproduce
use std::sync::Arc;
use arrow_array::types::Int32Type;
use arrow_array::{make_array, Array, ArrayRef, FixedSizeListArray, Int32Array, PrimitiveArray, StructArray};
use arrow_buffer::NullBuffer;
use arrow_data::ArrayDataBuilder;
use arrow_schema::{DataType, Field, Fields};
use arrow_select::take::take;
fn main() {
let ree_type = DataType::RunEndEncoded(
Arc::new(Field::new("run_ends", DataType::Int32, false)),
Arc::new(Field::new("values", DataType::Int32, false)),
);
let ree = |run_ends: Vec<i32>, values: Vec<i32>| -> ArrayRef {
let len = run_ends.last().copied().unwrap_or(0) as usize;
make_array(
ArrayDataBuilder::new(ree_type.clone())
.len(len)
.add_child_data(Int32Array::from(run_ends).into_data())
.add_child_data(Int32Array::from(values).into_data())
.build()
.unwrap(),
)
};
let strukt = |child: ArrayRef| -> ArrayRef {
let n = child.len();
Arc::new(StructArray::new(Fields::from(vec![Field::new("c", ree_type.clone(), true)]), vec![child], Some(NullBuffer::new_valid(n))))
};
let null = PrimitiveArray::<Int32Type>::from(vec![None]);
println!("{:?}", take(&strukt(ree(vec![1, 2], vec![10, 20])), &PrimitiveArray::<Int32Type>::from(vec![Some(1), None]), None).map(|a| a.null_count()));
// Ok(1)
println!("{:?}", take(&strukt(ree(vec![], vec![])), &null, None).map(|a| a.null_count()));
// Err(ComputeError("Cannot take null indices from a RunEndEncoded array with a non-nullable values field"))
println!("{:?}", take(&strukt(ree(vec![1, 2], vec![10, 20])).slice(1, 0), &null, None).map(|a| a.null_count()));
// Err(ComputeError("Cannot take null indices from a RunEndEncoded array with a non-nullable values field"))
let fsl = FixedSizeListArray::new(Arc::new(Field::new("item", ree_type.clone(), true)), 1, ree(vec![], vec![]), Some(NullBuffer::new_valid(0)));
println!("{:?}", take(&fsl, &null, None).map(|a| a.null_count()));
// Err(ComputeError("Cannot take null indices from a RunEndEncoded array with a non-nullable values field"))
println!("{:?}", take(&Int32Array::from(Vec::<i32>::new()), &null, None).map(|a| a.null_count()));
// Ok(1)
}
A struct of length 0 over a union with one non-nullable Int32 field fails the same way, with "Cannot take null indices from a union with no field that can represent nulls".
Expected behavior
Ok(1) for the three failing calls: one null row, held in the parent's validity.
Additional context
Could take_masked_child build an empty child's result the way take_sparse_union_child does for the same case, with new_null_array and its null buffer removed? A union with no fields has no value of any kind, so the error would stay for that case only.
Found with property-based tests that build arrays in every physical layout the Arrow format allows, on main at 6a3f719f. The take, take_record_batch, coalesce, and take-composition properties all reach it, usually through an empty or zero-length sliced struct.
- Lenguaje dominante
- Rust
- Estrellas
- 3.7k
- Forks
- 1.5k
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 183
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/arrow-rs
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
`RunArray::try_new` rejects run ends whose null buffer has no nullsPosiblemente ocupada @Surajsuthar la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/arrow-rs#12427 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Variant] `variant_get` string and binary cast errors show Rust builder type namesQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 61/100
Los mantenedores suelen responder en 1 día
Todos los issues de apache/arrow-rs
Issues similares
-
area:ui effort:medium enhancement P7 source:agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
marketing
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousAbiertomaintainer-needed p2 remote triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug help wanted ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
userFRM/egui-charts#4605 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día