Skip to content

Commit 90c43ab

Browse files
committed
Cover null List take placeholders
Signed-off-by: Daniel King <dan@spiraldb.com>
1 parent 2f29140 commit 90c43ab

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
@@ -883,6 +883,7 @@ mod test {
883883
use crate::arrays::PiecewiseSequenceArray;
884884
use crate::arrays::PrimitiveArray;
885885
use crate::arrays::listview::ListViewArrayExt;
886+
use crate::assert_arrays_eq;
886887
use crate::compute::conformance::take::test_take_conformance;
887888
use crate::dtype::DType;
888889
use crate::dtype::Nullability;
@@ -971,6 +972,55 @@ mod test {
971972
);
972973
}
973974

975+
#[test]
976+
fn null_index_ignores_out_of_bounds_payload() {
977+
let mut ctx = array_session().create_execution_ctx();
978+
let list = ListArray::try_new(
979+
buffer![1i32, 2, 3, 4].into_array(),
980+
buffer![0u32, 2, 4].into_array(),
981+
Validity::NonNullable,
982+
)
983+
.unwrap()
984+
.into_array();
985+
986+
let idx = PrimitiveArray::new(
987+
buffer![1u32, 99, 0],
988+
Validity::from_iter([true, false, true]),
989+
)
990+
.into_array();
991+
let result = list.take(idx).unwrap();
992+
993+
let expected = ListArray::new(
994+
buffer![3i32, 4, 1, 2].into_array(),
995+
buffer![0u32, 2, 2, 4].into_array(),
996+
Validity::from_iter([true, false, true]),
997+
);
998+
assert_arrays_eq!(expected, result, &mut ctx);
999+
}
1000+
1001+
#[test]
1002+
fn null_source_row_ignores_invalid_offset_payload() {
1003+
let mut ctx = array_session().create_execution_ctx();
1004+
let list = unsafe {
1005+
ListArray::new_unchecked(
1006+
buffer![1i32, 2].into_array(),
1007+
buffer![0u32, 2, 999].into_array(),
1008+
Validity::from_iter([true, false]),
1009+
)
1010+
}
1011+
.into_array();
1012+
1013+
let idx = buffer![0u32, 1].into_array();
1014+
let result = list.take(idx).unwrap();
1015+
1016+
let expected = ListArray::new(
1017+
buffer![1i32, 2].into_array(),
1018+
buffer![0u32, 2, 2].into_array(),
1019+
Validity::from_iter([true, false]),
1020+
);
1021+
assert_arrays_eq!(expected, result, &mut ctx);
1022+
}
1023+
9741024
#[test]
9751025
fn change_validity() {
9761026
let list = ListArray::try_new(

0 commit comments

Comments
 (0)