Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bool expr bindings #223

Merged
merged 6 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions datafusion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
ScalarVariable,
Sort,
TableScan,
Not,
IsNotNull,
IsTrue,
IsFalse,
IsUnknown,
IsNotTrue,
IsNotFalse,
IsNotUnknown,
Negative,
)

__version__ = importlib_metadata.version(__name__)
Expand Down Expand Up @@ -81,6 +90,15 @@
"SimilarTo",
"ScalarVariable",
"Alias",
"Not",
"IsNotNull",
"IsTrue",
"IsFalse",
"IsUnknown",
"IsNotTrue",
"IsNotFalse",
"IsNotUnknown",
"Negative",
]


Expand Down
18 changes: 18 additions & 0 deletions datafusion/tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
SimilarTo,
ScalarVariable,
Alias,
Not,
IsNotNull,
IsTrue,
IsFalse,
IsUnknown,
IsNotTrue,
IsNotFalse,
IsNotUnknown,
Negative,
)


Expand Down Expand Up @@ -87,6 +96,15 @@ def test_class_module_is_datafusion():
SimilarTo,
ScalarVariable,
Alias,
Not,
IsNotNull,
IsTrue,
IsFalse,
IsUnknown,
IsNotTrue,
IsNotFalse,
IsNotUnknown,
Negative,
]:
assert klass.__module__ == "datafusion.expr"

Expand Down
25 changes: 25 additions & 0 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ use crate::expr::literal::PyLiteral;
use datafusion::scalar::ScalarValue;

use self::alias::PyAlias;
use self::bool_expr::{
PyIsFalse, PyIsNotFalse, PyIsNotNull, PyIsNotTrue, PyIsNotUnknown, PyIsNull, PyIsTrue,
PyIsUnknown, PyNegative, PyNot,
};
use self::like::{PyILike, PyLike, PySimilarTo};
use self::scalar_variable::PyScalarVariable;

Expand All @@ -38,6 +42,7 @@ pub mod aggregate_expr;
pub mod alias;
pub mod analyze;
pub mod binary_expr;
pub mod bool_expr;
pub mod column;
pub mod empty_relation;
pub mod filter;
Expand Down Expand Up @@ -81,6 +86,16 @@ impl PyExpr {
}
Expr::Literal(value) => Ok(PyLiteral::from(value.clone()).into_py(py)),
Expr::BinaryExpr(expr) => Ok(PyBinaryExpr::from(expr.clone()).into_py(py)),
Expr::Not(expr) => Ok(PyNot::new(*expr.clone()).into_py(py)),
Expr::IsNotNull(expr) => Ok(PyIsNotNull::new(*expr.clone()).into_py(py)),
Expr::IsNull(expr) => Ok(PyIsNull::new(*expr.clone()).into_py(py)),
Expr::IsTrue(expr) => Ok(PyIsTrue::new(*expr.clone()).into_py(py)),
Expr::IsFalse(expr) => Ok(PyIsFalse::new(*expr.clone()).into_py(py)),
Expr::IsUnknown(expr) => Ok(PyIsUnknown::new(*expr.clone()).into_py(py)),
Expr::IsNotTrue(expr) => Ok(PyIsNotTrue::new(*expr.clone()).into_py(py)),
Expr::IsNotFalse(expr) => Ok(PyIsNotFalse::new(*expr.clone()).into_py(py)),
Expr::IsNotUnknown(expr) => Ok(PyIsNotUnknown::new(*expr.clone()).into_py(py)),
Expr::Negative(expr) => Ok(PyNegative::new(*expr.clone()).into_py(py)),
Expr::AggregateFunction(expr) => {
Ok(PyAggregateFunction::from(expr.clone()).into_py(py))
}
Expand Down Expand Up @@ -200,6 +215,16 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
m.add_class::<PyBinaryExpr>()?;
m.add_class::<PyLiteral>()?;
m.add_class::<PyAggregateFunction>()?;
m.add_class::<PyNot>()?;
m.add_class::<PyIsNotNull>()?;
m.add_class::<PyIsNull>()?;
m.add_class::<PyIsTrue>()?;
m.add_class::<PyIsFalse>()?;
m.add_class::<PyIsUnknown>()?;
m.add_class::<PyIsNotTrue>()?;
m.add_class::<PyIsNotFalse>()?;
m.add_class::<PyIsNotUnknown>()?;
m.add_class::<PyNegative>()?;
m.add_class::<PyLike>()?;
m.add_class::<PyILike>()?;
m.add_class::<PySimilarTo>()?;
Expand Down
Loading