From 282e7b4c69a5d81cbbdd6d01d03064dd2fc6af99 Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies <1781103+tustvold@users.noreply.github.com> Date: Fri, 4 Nov 2022 22:40:32 +1300 Subject: [PATCH] Add filter example (#3014) --- arrow/src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arrow/src/lib.rs b/arrow/src/lib.rs index 9cf66d5460e..7089c7152ee 100644 --- a/arrow/src/lib.rs +++ b/arrow/src/lib.rs @@ -197,6 +197,20 @@ //! * [`sort`](compute::kernels::sort::sort) //! * some string operators such as [`substring`](compute::kernels::substring::substring) and [`length`](compute::kernels::length::length) //! +//! ``` +//! # use arrow::compute::gt_scalar; +//! # use arrow_array::cast::as_primitive_array; +//! # use arrow_array::Int32Array; +//! # use arrow_array::types::Int32Type; +//! # use arrow_select::filter::filter; +//! let array = Int32Array::from_iter(0..100); +//! let predicate = gt_scalar(&array, 60).unwrap(); +//! let filtered = filter(&array, &predicate).unwrap(); +//! +//! let expected = Int32Array::from_iter(61..100); +//! assert_eq!(&expected, as_primitive_array::(&filtered)); +//! ``` +//! //! As well as some horizontal operations, such as: //! //! * [`min`](compute::kernels::aggregate::min) and [`max`](compute::kernels::aggregate::max)