filter

Function filter 

pub fn filter(
    values: &dyn Array,
    predicate: &BooleanArray,
) -> Result<Arc<dyn Array>, ArrowError>
Expand description

Returns a filtered values Array where the corresponding elements of predicate are true.

If multiple arrays (or record batches) need to be filtered using the same predicate array, consider using FilterBuilder to create a single FilterPredicate and then calling FilterPredicate::filter_record_batch. In contrast to this function, it is then the responsibility of the caller to use FilterBuilder::optimize if appropriate.

§See also

§Example

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