Skip to content

Commit b63e751

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

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
@@ -616,6 +616,7 @@ mod test {
616616
use crate::arrays::ListViewArray;
617617
use crate::arrays::PiecewiseSequenceArray;
618618
use crate::arrays::PrimitiveArray;
619+
use crate::assert_arrays_eq;
619620
use crate::compute::conformance::take::test_take_conformance;
620621
use crate::dtype::DType;
621622
use crate::dtype::Nullability;
@@ -704,6 +705,55 @@ mod test {
704705
);
705706
}
706707

708+
#[test]
709+
fn null_index_ignores_out_of_bounds_payload() {
710+
let mut ctx = array_session().create_execution_ctx();
711+
let list = ListArray::try_new(
712+
buffer![1i32, 2, 3, 4].into_array(),
713+
buffer![0u32, 2, 4].into_array(),
714+
Validity::NonNullable,
715+
)
716+
.unwrap()
717+
.into_array();
718+
719+
let idx = PrimitiveArray::new(
720+
buffer![1u32, 99, 0],
721+
Validity::from_iter([true, false, true]),
722+
)
723+
.into_array();
724+
let result = list.take(idx).unwrap();
725+
726+
let expected = ListArray::new(
727+
buffer![3i32, 4, 1, 2].into_array(),
728+
buffer![0u32, 2, 2, 4].into_array(),
729+
Validity::from_iter([true, false, true]),
730+
);
731+
assert_arrays_eq!(expected, result, &mut ctx);
732+
}
733+
734+
#[test]
735+
fn null_source_row_ignores_invalid_offset_payload() {
736+
let mut ctx = array_session().create_execution_ctx();
737+
let list = unsafe {
738+
ListArray::new_unchecked(
739+
buffer![1i32, 2].into_array(),
740+
buffer![0u32, 2, 999].into_array(),
741+
Validity::from_iter([true, false]),
742+
)
743+
}
744+
.into_array();
745+
746+
let idx = buffer![0u32, 1].into_array();
747+
let result = list.take(idx).unwrap();
748+
749+
let expected = ListArray::new(
750+
buffer![1i32, 2].into_array(),
751+
buffer![0u32, 2, 2].into_array(),
752+
Validity::from_iter([true, false]),
753+
);
754+
assert_arrays_eq!(expected, result, &mut ctx);
755+
}
756+
707757
#[test]
708758
fn change_validity() {
709759
let list = ListArray::try_new(

0 commit comments

Comments
 (0)