You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by tu...@apache.org on 2022/11/04 09:40:38 UTC

[arrow-rs] branch master updated: Add filter example (#3014)

This is an automated email from the ASF dual-hosted git repository.

tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 282e7b4c6 Add filter example (#3014)
282e7b4c6 is described below

commit 282e7b4c69a5d81cbbdd6d01d03064dd2fc6af99
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Fri Nov 4 22:40:32 2022 +1300

    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 9cf66d546..7089c7152 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::<Int32Type>(&filtered));
+//! ```
+//!
 //! As well as some horizontal operations, such as:
 //!
 //! * [`min`](compute::kernels::aggregate::min) and [`max`](compute::kernels::aggregate::max)