datafusion_python/expr/
bool_expr.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use datafusion::logical_expr::Expr;
19use pyo3::prelude::*;
20use std::fmt::{self, Display, Formatter};
21
22use super::PyExpr;
23
24#[pyclass(name = "Not", module = "datafusion.expr", subclass)]
25#[derive(Clone, Debug)]
26pub struct PyNot {
27    expr: Expr,
28}
29
30impl PyNot {
31    pub fn new(expr: Expr) -> Self {
32        Self { expr }
33    }
34}
35
36impl Display for PyNot {
37    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
38        write!(
39            f,
40            "Not
41            Expr: {}",
42            &self.expr
43        )
44    }
45}
46
47#[pymethods]
48impl PyNot {
49    fn expr(&self) -> PyResult<PyExpr> {
50        Ok(self.expr.clone().into())
51    }
52}
53
54#[pyclass(name = "IsNotNull", module = "datafusion.expr", subclass)]
55#[derive(Clone, Debug)]
56pub struct PyIsNotNull {
57    expr: Expr,
58}
59
60impl PyIsNotNull {
61    pub fn new(expr: Expr) -> Self {
62        Self { expr }
63    }
64}
65
66impl Display for PyIsNotNull {
67    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
68        write!(
69            f,
70            "IsNotNull
71            Expr: {}",
72            &self.expr
73        )
74    }
75}
76
77#[pymethods]
78impl PyIsNotNull {
79    fn expr(&self) -> PyResult<PyExpr> {
80        Ok(self.expr.clone().into())
81    }
82}
83
84#[pyclass(name = "IsNull", module = "datafusion.expr", subclass)]
85#[derive(Clone, Debug)]
86pub struct PyIsNull {
87    expr: Expr,
88}
89
90impl PyIsNull {
91    pub fn new(expr: Expr) -> Self {
92        Self { expr }
93    }
94}
95
96impl Display for PyIsNull {
97    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
98        write!(
99            f,
100            "IsNull
101            Expr: {}",
102            &self.expr
103        )
104    }
105}
106
107#[pymethods]
108impl PyIsNull {
109    fn expr(&self) -> PyResult<PyExpr> {
110        Ok(self.expr.clone().into())
111    }
112}
113
114#[pyclass(name = "IsTrue", module = "datafusion.expr", subclass)]
115#[derive(Clone, Debug)]
116pub struct PyIsTrue {
117    expr: Expr,
118}
119
120impl PyIsTrue {
121    pub fn new(expr: Expr) -> Self {
122        Self { expr }
123    }
124}
125
126impl Display for PyIsTrue {
127    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
128        write!(
129            f,
130            "IsTrue
131            Expr: {}",
132            &self.expr
133        )
134    }
135}
136
137#[pymethods]
138impl PyIsTrue {
139    fn expr(&self) -> PyResult<PyExpr> {
140        Ok(self.expr.clone().into())
141    }
142}
143
144#[pyclass(name = "IsFalse", module = "datafusion.expr", subclass)]
145#[derive(Clone, Debug)]
146pub struct PyIsFalse {
147    expr: Expr,
148}
149
150impl PyIsFalse {
151    pub fn new(expr: Expr) -> Self {
152        Self { expr }
153    }
154}
155
156impl Display for PyIsFalse {
157    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
158        write!(
159            f,
160            "IsFalse
161            Expr: {}",
162            &self.expr
163        )
164    }
165}
166
167#[pymethods]
168impl PyIsFalse {
169    fn expr(&self) -> PyResult<PyExpr> {
170        Ok(self.expr.clone().into())
171    }
172}
173
174#[pyclass(name = "IsUnknown", module = "datafusion.expr", subclass)]
175#[derive(Clone, Debug)]
176pub struct PyIsUnknown {
177    expr: Expr,
178}
179
180impl PyIsUnknown {
181    pub fn new(expr: Expr) -> Self {
182        Self { expr }
183    }
184}
185
186impl Display for PyIsUnknown {
187    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
188        write!(
189            f,
190            "IsUnknown
191            Expr: {}",
192            &self.expr
193        )
194    }
195}
196
197#[pymethods]
198impl PyIsUnknown {
199    fn expr(&self) -> PyResult<PyExpr> {
200        Ok(self.expr.clone().into())
201    }
202}
203
204#[pyclass(name = "IsNotTrue", module = "datafusion.expr", subclass)]
205#[derive(Clone, Debug)]
206pub struct PyIsNotTrue {
207    expr: Expr,
208}
209
210impl PyIsNotTrue {
211    pub fn new(expr: Expr) -> Self {
212        Self { expr }
213    }
214}
215
216impl Display for PyIsNotTrue {
217    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
218        write!(
219            f,
220            "IsNotTrue
221            Expr: {}",
222            &self.expr
223        )
224    }
225}
226
227#[pymethods]
228impl PyIsNotTrue {
229    fn expr(&self) -> PyResult<PyExpr> {
230        Ok(self.expr.clone().into())
231    }
232}
233
234#[pyclass(name = "IsNotFalse", module = "datafusion.expr", subclass)]
235#[derive(Clone, Debug)]
236pub struct PyIsNotFalse {
237    expr: Expr,
238}
239
240impl PyIsNotFalse {
241    pub fn new(expr: Expr) -> Self {
242        Self { expr }
243    }
244}
245
246impl Display for PyIsNotFalse {
247    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
248        write!(
249            f,
250            "IsNotFalse
251            Expr: {}",
252            &self.expr
253        )
254    }
255}
256
257#[pymethods]
258impl PyIsNotFalse {
259    fn expr(&self) -> PyResult<PyExpr> {
260        Ok(self.expr.clone().into())
261    }
262}
263
264#[pyclass(name = "IsNotUnknown", module = "datafusion.expr", subclass)]
265#[derive(Clone, Debug)]
266pub struct PyIsNotUnknown {
267    expr: Expr,
268}
269
270impl PyIsNotUnknown {
271    pub fn new(expr: Expr) -> Self {
272        Self { expr }
273    }
274}
275
276impl Display for PyIsNotUnknown {
277    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
278        write!(
279            f,
280            "IsNotUnknown
281            Expr: {}",
282            &self.expr
283        )
284    }
285}
286
287#[pymethods]
288impl PyIsNotUnknown {
289    fn expr(&self) -> PyResult<PyExpr> {
290        Ok(self.expr.clone().into())
291    }
292}
293
294#[pyclass(name = "Negative", module = "datafusion.expr", subclass)]
295#[derive(Clone, Debug)]
296pub struct PyNegative {
297    expr: Expr,
298}
299
300impl PyNegative {
301    pub fn new(expr: Expr) -> Self {
302        Self { expr }
303    }
304}
305
306impl Display for PyNegative {
307    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
308        write!(
309            f,
310            "Negative
311            Expr: {}",
312            &self.expr
313        )
314    }
315}
316
317#[pymethods]
318impl PyNegative {
319    fn expr(&self) -> PyResult<PyExpr> {
320        Ok(self.expr.clone().into())
321    }
322}