Skip to content

Commit 77d37d8

Browse files
committed
Cover null List take placeholders
Signed-off-by: Daniel King <dan@spiraldb.com>
1 parent b39ef87 commit 77d37d8

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

  • vortex-array/src/arrays/list/compute

vortex-array/src/arrays/list/compute/take.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ mod test {
642642
use crate::arrays::ListViewArray;
643643
use crate::arrays::PiecewiseSequenceArray;
644644
use crate::arrays::PrimitiveArray;
645+
use crate::assert_arrays_eq;
645646
use crate::compute::conformance::take::test_take_conformance;
646647
use crate::dtype::DType;
647648
use crate::dtype::Nullability;
@@ -730,6 +731,55 @@ mod test {
730731
);
731732
}
732733

734+
#[test]
735+
fn null_index_ignores_out_of_bounds_payload() {
736+
let mut ctx = array_session().create_execution_ctx();
737+
let list = ListArray::try_new(
738+
buffer![1i32, 2, 3, 4].into_array(),
739+
buffer![0u32, 2, 4].into_array(),
740+
Validity::NonNullable,
741+
)
742+
.unwrap()
743+
.into_array();
744+
745+
let idx = PrimitiveArray::new(
746+
buffer![1u32, 99, 0],
747+
Validity::from_iter([true, false, true]),
748+
)
749+
.into_array();
750+
let result = list.take(idx).unwrap();
751+
752+
let expected = ListArray::new(
753+
buffer![3i32, 4, 1, 2].into_array(),
754+
buffer![0u32, 2, 2, 4].into_array(),
755+
Validity::from_iter([true, false, true]),
756+
);
757+
assert_arrays_eq!(expected, result, &mut ctx);
758+
}
759+
760+
#[test]
761+
fn null_source_row_ignores_invalid_offset_payload() {
762+
let mut ctx = array_session().create_execution_ctx();
763+
let list = unsafe {
764+
ListArray::new_unchecked(
765+
buffer![1i32, 2].into_array(),
766+
buffer![0u32, 2, 999].into_array(),
767+
Validity::from_iter([true, false]),
768+
)
769+
}
770+
.into_array();
771+
772+
let idx = buffer![0u32, 1].into_array();
773+
let result = list.take(idx).unwrap();
774+
775+
let expected = ListArray::new(
776+
buffer![1i32, 2].into_array(),
777+
buffer![0u32, 2, 2].into_array(),
778+
Validity::from_iter([true, false]),
779+
);
780+
assert_arrays_eq!(expected, result, &mut ctx);
781+
}
782+
733783
#[test]
734784
fn change_validity() {
735785
let list = ListArray::try_new(

0 commit comments

Comments
 (0)