datafusion_python/expr/
bool_expr.rs1use std::fmt::{self, Display, Formatter};
19
20use datafusion::logical_expr::Expr;
21use pyo3::prelude::*;
22
23use super::PyExpr;
24
25#[pyclass(frozen, name = "Not", module = "datafusion.expr", subclass)]
26#[derive(Clone, Debug)]
27pub struct PyNot {
28 expr: Expr,
29}
30
31impl PyNot {
32 pub fn new(expr: Expr) -> Self {
33 Self { expr }
34 }
35}
36
37impl Display for PyNot {
38 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
39 write!(
40 f,
41 "Not
42 Expr: {}",
43 &self.expr
44 )
45 }
46}
47
48#[pymethods]
49impl PyNot {
50 fn expr(&self) -> PyResult<PyExpr> {
51 Ok(self.expr.clone().into())
52 }
53}
54
55#[pyclass(frozen, name = "IsNotNull", module = "datafusion.expr", subclass)]
56#[derive(Clone, Debug)]
57pub struct PyIsNotNull {
58 expr: Expr,
59}
60
61impl PyIsNotNull {
62 pub fn new(expr: Expr) -> Self {
63 Self { expr }
64 }
65}
66
67impl Display for PyIsNotNull {
68 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
69 write!(
70 f,
71 "IsNotNull
72 Expr: {}",
73 &self.expr
74 )
75 }
76}
77
78#[pymethods]
79impl PyIsNotNull {
80 fn expr(&self) -> PyResult<PyExpr> {
81 Ok(self.expr.clone().into())
82 }
83}
84
85#[pyclass(frozen, name = "IsNull", module = "datafusion.expr", subclass)]
86#[derive(Clone, Debug)]
87pub struct PyIsNull {
88 expr: Expr,
89}
90
91impl PyIsNull {
92 pub fn new(expr: Expr) -> Self {
93 Self { expr }
94 }
95}
96
97impl Display for PyIsNull {
98 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
99 write!(
100 f,
101 "IsNull
102 Expr: {}",
103 &self.expr
104 )
105 }
106}
107
108#[pymethods]
109impl PyIsNull {
110 fn expr(&self) -> PyResult<PyExpr> {
111 Ok(self.expr.clone().into())
112 }
113}
114
115#[pyclass(frozen, name = "IsTrue", module = "datafusion.expr", subclass)]
116#[derive(Clone, Debug)]
117pub struct PyIsTrue {
118 expr: Expr,
119}
120
121impl PyIsTrue {
122 pub fn new(expr: Expr) -> Self {
123 Self { expr }
124 }
125}
126
127impl Display for PyIsTrue {
128 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
129 write!(
130 f,
131 "IsTrue
132 Expr: {}",
133 &self.expr
134 )
135 }
136}
137
138#[pymethods]
139impl PyIsTrue {
140 fn expr(&self) -> PyResult<PyExpr> {
141 Ok(self.expr.clone().into())
142 }
143}
144
145#[pyclass(frozen, name = "IsFalse", module = "datafusion.expr", subclass)]
146#[derive(Clone, Debug)]
147pub struct PyIsFalse {
148 expr: Expr,
149}
150
151impl PyIsFalse {
152 pub fn new(expr: Expr) -> Self {
153 Self { expr }
154 }
155}
156
157impl Display for PyIsFalse {
158 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
159 write!(
160 f,
161 "IsFalse
162 Expr: {}",
163 &self.expr
164 )
165 }
166}
167
168#[pymethods]
169impl PyIsFalse {
170 fn expr(&self) -> PyResult<PyExpr> {
171 Ok(self.expr.clone().into())
172 }
173}
174
175#[pyclass(frozen, name = "IsUnknown", module = "datafusion.expr", subclass)]
176#[derive(Clone, Debug)]
177pub struct PyIsUnknown {
178 expr: Expr,
179}
180
181impl PyIsUnknown {
182 pub fn new(expr: Expr) -> Self {
183 Self { expr }
184 }
185}
186
187impl Display for PyIsUnknown {
188 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
189 write!(
190 f,
191 "IsUnknown
192 Expr: {}",
193 &self.expr
194 )
195 }
196}
197
198#[pymethods]
199impl PyIsUnknown {
200 fn expr(&self) -> PyResult<PyExpr> {
201 Ok(self.expr.clone().into())
202 }
203}
204
205#[pyclass(frozen, name = "IsNotTrue", module = "datafusion.expr", subclass)]
206#[derive(Clone, Debug)]
207pub struct PyIsNotTrue {
208 expr: Expr,
209}
210
211impl PyIsNotTrue {
212 pub fn new(expr: Expr) -> Self {
213 Self { expr }
214 }
215}
216
217impl Display for PyIsNotTrue {
218 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
219 write!(
220 f,
221 "IsNotTrue
222 Expr: {}",
223 &self.expr
224 )
225 }
226}
227
228#[pymethods]
229impl PyIsNotTrue {
230 fn expr(&self) -> PyResult<PyExpr> {
231 Ok(self.expr.clone().into())
232 }
233}
234
235#[pyclass(frozen, name = "IsNotFalse", module = "datafusion.expr", subclass)]
236#[derive(Clone, Debug)]
237pub struct PyIsNotFalse {
238 expr: Expr,
239}
240
241impl PyIsNotFalse {
242 pub fn new(expr: Expr) -> Self {
243 Self { expr }
244 }
245}
246
247impl Display for PyIsNotFalse {
248 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
249 write!(
250 f,
251 "IsNotFalse
252 Expr: {}",
253 &self.expr
254 )
255 }
256}
257
258#[pymethods]
259impl PyIsNotFalse {
260 fn expr(&self) -> PyResult<PyExpr> {
261 Ok(self.expr.clone().into())
262 }
263}
264
265#[pyclass(frozen, name = "IsNotUnknown", module = "datafusion.expr", subclass)]
266#[derive(Clone, Debug)]
267pub struct PyIsNotUnknown {
268 expr: Expr,
269}
270
271impl PyIsNotUnknown {
272 pub fn new(expr: Expr) -> Self {
273 Self { expr }
274 }
275}
276
277impl Display for PyIsNotUnknown {
278 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
279 write!(
280 f,
281 "IsNotUnknown
282 Expr: {}",
283 &self.expr
284 )
285 }
286}
287
288#[pymethods]
289impl PyIsNotUnknown {
290 fn expr(&self) -> PyResult<PyExpr> {
291 Ok(self.expr.clone().into())
292 }
293}
294
295#[pyclass(frozen, name = "Negative", module = "datafusion.expr", subclass)]
296#[derive(Clone, Debug)]
297pub struct PyNegative {
298 expr: Expr,
299}
300
301impl PyNegative {
302 pub fn new(expr: Expr) -> Self {
303 Self { expr }
304 }
305}
306
307impl Display for PyNegative {
308 fn fmt(&self, f: &mut Formatter) -> fmt::Result {
309 write!(
310 f,
311 "Negative
312 Expr: {}",
313 &self.expr
314 )
315 }
316}
317
318#[pymethods]
319impl PyNegative {
320 fn expr(&self) -> PyResult<PyExpr> {
321 Ok(self.expr.clone().into())
322 }
323}