pub fn filter(array: &dyn Array, filter: &BooleanArray) -> Result<Box<dyn Array>>
Available on crate feature compute_filter only.
Expand description

Filters an Array, returning elements matching the filter (i.e. where the values are true).

Note that the nulls of filter are interpreted as false will lead to these elements being masked out.

Example

let array = PrimitiveArray::from_slice([5, 6, 7, 8, 9]);
let filter_array = BooleanArray::from_slice(&vec![true, false, false, true, false]);
let c = filter(&array, &filter_array)?;
let c = c.as_any().downcast_ref::<Int32Array>().unwrap();
assert_eq!(c, &PrimitiveArray::from_slice(vec![5, 8]));