nevi-me commented on a change in pull request #8364:
URL: https://github.com/apache/arrow/pull/8364#discussion_r506979066
##########
File path: rust/arrow/src/compute/kernels/filter.rs
##########
@@ -733,4 +909,53 @@ mod tests {
assert_eq!("hello", d.value(0));
assert_eq!("world", d.value(1));
}
+
+ #[test]
+ fn test_filter_list_array() {
+ let value_data = ArrayData::builder(DataType::Int32)
+ .len(8)
+ .add_buffer(Buffer::from(&[0, 1, 2, 3, 4, 5, 6,
7].to_byte_slice()))
+ .build();
+
+ let value_offsets = Buffer::from(&[0, 3, 6, 8, 8].to_byte_slice());
+
+ let list_data_type = DataType::List(Box::new(DataType::Int32));
+ let list_data = ArrayData::builder(list_data_type)
+ .len(4)
+ .add_buffer(value_offsets)
+ .add_child_data(value_data)
+ .null_bit_buffer(Buffer::from([0b00000111]))
+ .build();
+
+ // a = [[0, 1, 2], [3, 4, 5], [6, 7], null]
+ let a = ListArray::from(list_data);
+ let b = BooleanArray::from(vec![false, true, false, true]);
+ let c = filter(&a, &b).unwrap();
+ let d = c.as_ref().as_any().downcast_ref::<ListArray>().unwrap();
+
+ assert_eq!(DataType::Int32, d.value_type());
+
+ // result should be [[3, 4, 5], null]
+ assert_eq!(2, d.len());
+ assert_eq!(1, d.null_count());
+ assert_eq!(true, d.is_null(1));
+
+ assert_eq!(0, d.value_offset(0));
+ assert_eq!(3, d.value_length(0));
+ assert_eq!(3, d.value_offset(1));
Review comment:
I suppose it's a function of how much we can accept as working vs what
additional functionality we want to test; e.g. we've tested in list arrays that
null offsets behave correctly.
My preference would be to forego some of the assertions that for example a
value that should be null is null, if the functionality isn't expected to
change such behaviour.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]