pub fn list_contains(
array: &dyn Array,
value: &dyn Array,
) -> VortexResult<ArrayRef>Expand description
Compute a Bool-typed array the same length as array where elements is true if the list
item contains the value, false otherwise.
§Null scalar handling
If the value or array is null at any index the result at that index is null.
§Format semantics
list_contains(list, elem)
==> (!is_null(list) or NULL) and (!is_null(elem) or NULL) and any({elem = elem_i | elem_i in list}),§Example
let elements = VarBinArray::from_vec(
vec!["a", "a", "b", "a", "c"], DType::Utf8(false.into())).into_array();
let offsets = buffer![0u32, 1, 3].into_array();
let sizes = buffer![1u32, 2, 2].into_array();
let list_array =
ListViewArray::try_new(elements, offsets, sizes, Validity::NonNullable).unwrap();
let matches = compute::list_contains(
list_array.as_ref(),
ConstantArray::new(Scalar::from("b"),
list_array.len()).as_ref()
).unwrap();
let to_vec: Vec<bool> = matches.to_bool().boolean_buffer().iter().collect();
assert_eq!(to_vec, vec![false, true, false]);