`take` rejects a null index into an empty struct or fixed-size list whose child cannot hold a null
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 3.7k
- Fork
- 1.5k
- Merge medio
- 2g 16h
- PR unite (30g)
- 183
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/arrow-rs
-
parquet: `ArrowWriter::try_new` panics on a schema with a Union field instead of returning an errorAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
`RunArray::try_new` rejects run ends whose null buffer has no nullsForse già presa @Surajsuthar l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
apache/arrow-rs#12427 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Variant] `variant_get` string and binary cast errors show Rust builder type namesForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 61/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/arrow-rs
Issue simili
-
area:ui effort:medium enhancement P7 source:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
machine rename accepts a label already used by another machine, making --machine <label> ambiguousApertamaintainer-needed p2 remote triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug help wanted ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
userFRM/egui-charts#4605 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno