@@ -76,3 +76,183 @@ impl PartialEq<dyn Any> for BinaryExpr {
7676 . unwrap_or ( false )
7777 }
7878}
79+
80+ /// Create a new `BinaryExpr` using the `Eq` operator.
81+ ///
82+ /// ## Example usage
83+ ///
84+ /// ```
85+ /// use vortex_array::array::{BoolArray, PrimitiveArray };
86+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
87+ /// use vortex_array::validity::Validity;
88+ /// use vortex_buffer::buffer;
89+ /// use vortex_expr::{eq, ident, lit};
90+ ///
91+ /// let xs = PrimitiveArray::new(buffer![1i32, 2i32, 3i32], Validity::NonNullable).into_array();
92+ /// let result = eq(ident(), lit(3)).evaluate(&xs).unwrap();
93+ ///
94+ /// assert_eq!(
95+ /// result.into_bool().unwrap().boolean_buffer(),
96+ /// BoolArray::from_iter(vec![false, false, true]).boolean_buffer(),
97+ /// );
98+ /// ```
99+ pub fn eq ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
100+ BinaryExpr :: new_expr ( lhs, Operator :: Eq , rhs)
101+ }
102+
103+ /// Create a new `BinaryExpr` using the `NotEq` operator.
104+ ///
105+ /// ## Example usage
106+ ///
107+ /// ```
108+ /// use vortex_array::array::{BoolArray, PrimitiveArray };
109+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
110+ /// use vortex_array::validity::Validity;
111+ /// use vortex_buffer::buffer;
112+ /// use vortex_expr::{ident, lit, not_eq};
113+ ///
114+ /// let xs = PrimitiveArray::new(buffer![1i32, 2i32, 3i32], Validity::NonNullable).into_array();
115+ /// let result = not_eq(ident(), lit(3)).evaluate(&xs).unwrap();
116+ ///
117+ /// assert_eq!(
118+ /// result.into_bool().unwrap().boolean_buffer(),
119+ /// BoolArray::from_iter(vec![true, true, false]).boolean_buffer(),
120+ /// );
121+ /// ```
122+ pub fn not_eq ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
123+ BinaryExpr :: new_expr ( lhs, Operator :: NotEq , rhs)
124+ }
125+
126+ /// Create a new `BinaryExpr` using the `Gte` operator.
127+ ///
128+ /// ## Example usage
129+ ///
130+ /// ```
131+ /// use vortex_array::array::{BoolArray, PrimitiveArray };
132+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
133+ /// use vortex_array::validity::Validity;
134+ /// use vortex_buffer::buffer;
135+ /// use vortex_expr::{gt_eq, ident, lit};
136+ ///
137+ /// let xs = PrimitiveArray::new(buffer![1i32, 2i32, 3i32], Validity::NonNullable).into_array();
138+ /// let result = gt_eq(ident(), lit(3)).evaluate(&xs).unwrap();
139+ ///
140+ /// assert_eq!(
141+ /// result.into_bool().unwrap().boolean_buffer(),
142+ /// BoolArray::from_iter(vec![false, false, true]).boolean_buffer(),
143+ /// );
144+ /// ```
145+ pub fn gt_eq ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
146+ BinaryExpr :: new_expr ( lhs, Operator :: Gte , rhs)
147+ }
148+
149+ /// Create a new `BinaryExpr` using the `Gt` operator.
150+ ///
151+ /// ## Example usage
152+ ///
153+ /// ```
154+ /// use vortex_array::array::{BoolArray, PrimitiveArray };
155+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
156+ /// use vortex_array::validity::Validity;
157+ /// use vortex_buffer::buffer;
158+ /// use vortex_expr::{gt, ident, lit};
159+ ///
160+ /// let xs = PrimitiveArray::new(buffer![1i32, 2i32, 3i32], Validity::NonNullable).into_array();
161+ /// let result = gt(ident(), lit(2)).evaluate(&xs).unwrap();
162+ ///
163+ /// assert_eq!(
164+ /// result.into_bool().unwrap().boolean_buffer(),
165+ /// BoolArray::from_iter(vec![false, false, true]).boolean_buffer(),
166+ /// );
167+ /// ```
168+ pub fn gt ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
169+ BinaryExpr :: new_expr ( lhs, Operator :: Gt , rhs)
170+ }
171+
172+ /// Create a new `BinaryExpr` using the `Lte` operator.
173+ ///
174+ /// ## Example usage
175+ ///
176+ /// ```
177+ /// use vortex_array::array::{BoolArray, PrimitiveArray };
178+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
179+ /// use vortex_array::validity::Validity;
180+ /// use vortex_buffer::buffer;
181+ /// use vortex_expr::{ident, lit, lt_eq};
182+ ///
183+ /// let xs = PrimitiveArray::new(buffer![1i32, 2i32, 3i32], Validity::NonNullable).into_array();
184+ /// let result = lt_eq(ident(), lit(2)).evaluate(&xs).unwrap();
185+ ///
186+ /// assert_eq!(
187+ /// result.into_bool().unwrap().boolean_buffer(),
188+ /// BoolArray::from_iter(vec![true, true, false]).boolean_buffer(),
189+ /// );
190+ /// ```
191+ pub fn lt_eq ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
192+ BinaryExpr :: new_expr ( lhs, Operator :: Lte , rhs)
193+ }
194+
195+ /// Create a new `BinaryExpr` using the `Lt` operator.
196+ ///
197+ /// ## Example usage
198+ ///
199+ /// ```
200+ /// use vortex_array::array::{BoolArray, PrimitiveArray };
201+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
202+ /// use vortex_array::validity::Validity;
203+ /// use vortex_buffer::buffer;
204+ /// use vortex_expr::{ident, lit, lt};
205+ ///
206+ /// let xs = PrimitiveArray::new(buffer![1i32, 2i32, 3i32], Validity::NonNullable).into_array();
207+ /// let result = lt(ident(), lit(3)).evaluate(&xs).unwrap();
208+ ///
209+ /// assert_eq!(
210+ /// result.into_bool().unwrap().boolean_buffer(),
211+ /// BoolArray::from_iter(vec![true, true, false]).boolean_buffer(),
212+ /// );
213+ /// ```
214+ pub fn lt ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
215+ BinaryExpr :: new_expr ( lhs, Operator :: Lt , rhs)
216+ }
217+
218+ /// Create a new `BinaryExpr` using the `Or` operator.
219+ ///
220+ /// ## Example usage
221+ ///
222+ /// ```
223+ /// use vortex_array::array::BoolArray;
224+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
225+ /// use vortex_expr::{ ident, lit, or};
226+ ///
227+ /// let xs = BoolArray::from_iter(vec![true, false, true]).into_array();
228+ /// let result = or(ident(), lit(false)).evaluate(&xs).unwrap();
229+ ///
230+ /// assert_eq!(
231+ /// result.into_bool().unwrap().boolean_buffer(),
232+ /// BoolArray::from_iter(vec![true, false, true]).boolean_buffer(),
233+ /// );
234+ /// ```
235+ pub fn or ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
236+ BinaryExpr :: new_expr ( lhs, Operator :: Or , rhs)
237+ }
238+
239+ /// Create a new `BinaryExpr` using the `And` operator.
240+ ///
241+ /// ## Example usage
242+ ///
243+ /// ```
244+ /// use vortex_array::array::BoolArray;
245+ /// use vortex_array::{IntoArrayData, IntoArrayVariant};
246+ /// use vortex_expr::{and, ident, lit};
247+ ///
248+ /// let xs = BoolArray::from_iter(vec![true, false, true]).into_array();
249+ /// let result = and(ident(), lit(true)).evaluate(&xs).unwrap();
250+ ///
251+ /// assert_eq!(
252+ /// result.into_bool().unwrap().boolean_buffer(),
253+ /// BoolArray::from_iter(vec![true, false, true]).boolean_buffer(),
254+ /// );
255+ /// ```
256+ pub fn and ( lhs : ExprRef , rhs : ExprRef ) -> ExprRef {
257+ BinaryExpr :: new_expr ( lhs, Operator :: And , rhs)
258+ }
0 commit comments