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

agrove pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 66dee05  Between bindings (#229)
66dee05 is described below

commit 66dee05f080a86e053128dd8fd60c59ff040f3f5
Author: Jeremy Dyer <[email protected]>
AuthorDate: Thu Feb 23 12:59:57 2023 -0500

    Between bindings (#229)
    
    * Between bindings
    
    * cargo fmt changes
    
    * cargo fmt changes
---
 Cargo.lock                       | 39 ++++++++++-----------
 datafusion/__init__.py           |  2 ++
 datafusion/tests/test_imports.py |  2 ++
 src/expr.rs                      |  2 ++
 src/expr/between.rs              | 76 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 101 insertions(+), 20 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 04a2ea8..9e337e2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -844,9 +844,9 @@ dependencies = [
  "datafusion",
  "itertools",
  "object_store",
- "prost 0.11.6",
+ "prost 0.11.7",
  "prost-build 0.9.0",
- "prost-types 0.11.6",
+ "prost-types 0.11.7",
  "substrait",
  "tokio",
 ]
@@ -1813,12 +1813,12 @@ dependencies = [
 
 [[package]]
 name = "prost"
-version = "0.11.6"
+version = "0.11.7"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "21dc42e00223fc37204bd4aa177e69420c604ca4a183209a8f9de30c6d934698"
+checksum = "3933d3ac2717077b3d5f42b40f59edfb1fb6a8c14e1c7de0f38075c4bac8e314"
 dependencies = [
  "bytes",
- "prost-derive 0.11.6",
+ "prost-derive 0.11.7",
 ]
 
 [[package]]
@@ -1843,9 +1843,9 @@ dependencies = [
 
 [[package]]
 name = "prost-build"
-version = "0.11.6"
+version = "0.11.7"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "a3f8ad728fb08fe212df3c05169e940fbb6d9d16a877ddde14644a983ba2012e"
+checksum = "a24be1d23b4552a012093e1b93697b73d644ae9590e3253d878d0e77d411b614"
 dependencies = [
  "bytes",
  "heck 0.4.1",
@@ -1854,8 +1854,8 @@ dependencies = [
  "log",
  "multimap",
  "petgraph",
- "prost 0.11.6",
- "prost-types 0.11.6",
+ "prost 0.11.7",
+ "prost-types 0.11.7",
  "regex",
  "tempfile",
  "which",
@@ -1876,9 +1876,9 @@ dependencies = [
 
 [[package]]
 name = "prost-derive"
-version = "0.11.6"
+version = "0.11.7"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "8bda8c0881ea9f722eb9629376db3d0b903b462477c1aafcb0566610ac28ac5d"
+checksum = "8e9935362e8369bc3acd874caeeae814295c504c2bdbcde5c024089cf8b4dc12"
 dependencies = [
  "anyhow",
  "itertools",
@@ -1899,12 +1899,11 @@ dependencies = [
 
 [[package]]
 name = "prost-types"
-version = "0.11.6"
+version = "0.11.7"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "a5e0526209433e96d83d750dd81a99118edbc55739e7e61a46764fd2ad537788"
+checksum = "7de56acd5cc9642cac2a9518d4c8c53818905398fe42d33235859e0d542a7695"
 dependencies = [
- "bytes",
- "prost 0.11.6",
+ "prost 0.11.7",
 ]
 
 [[package]]
@@ -2469,9 +2468,9 @@ source = 
"registry+https://github.com/rust-lang/crates.io-index";
 checksum = "e2feb96a6a106e21161551af32dc4e0fdab3aceb926b940d7e92a086b640fc7c"
 dependencies = [
  "heck 0.4.1",
- "prost 0.11.6",
- "prost-build 0.11.6",
- "prost-types 0.11.6",
+ "prost 0.11.7",
+ "prost-build 0.11.7",
+ "prost-types 0.11.7",
  "schemars",
  "serde",
  "serde_json",
@@ -2488,9 +2487,9 @@ checksum = 
"6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
 
 [[package]]
 name = "syn"
-version = "1.0.107"
+version = "1.0.108"
 source = "registry+https://github.com/rust-lang/crates.io-index";
-checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
+checksum = "d56e159d99e6c2b93995d171050271edb50ecc5288fbc7cc17de8fdce4e58c14"
 dependencies = [
  "proc-macro2",
  "quote",
diff --git a/datafusion/__init__.py b/datafusion/__init__.py
index c695bfb..748a291 100644
--- a/datafusion/__init__.py
+++ b/datafusion/__init__.py
@@ -62,6 +62,7 @@ from .expr import (
     IsNotFalse,
     IsNotUnknown,
     Negative,
+    Between,
 )
 
 __version__ = importlib_metadata.version(__name__)
@@ -99,6 +100,7 @@ __all__ = [
     "IsNotFalse",
     "IsNotUnknown",
     "Negative",
+    "Between",
 ]
 
 
diff --git a/datafusion/tests/test_imports.py b/datafusion/tests/test_imports.py
index b154f56..683b061 100644
--- a/datafusion/tests/test_imports.py
+++ b/datafusion/tests/test_imports.py
@@ -58,6 +58,7 @@ from datafusion.expr import (
     IsNotFalse,
     IsNotUnknown,
     Negative,
+    Between,
 )
 
 
@@ -105,6 +106,7 @@ def test_class_module_is_datafusion():
         IsNotFalse,
         IsNotUnknown,
         Negative,
+        Between,
     ]:
         assert klass.__module__ == "datafusion.expr"
 
diff --git a/src/expr.rs b/src/expr.rs
index f411068..56f1633 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -41,6 +41,7 @@ pub mod aggregate;
 pub mod aggregate_expr;
 pub mod alias;
 pub mod analyze;
+pub mod between;
 pub mod binary_expr;
 pub mod bool_expr;
 pub mod column;
@@ -230,6 +231,7 @@ pub(crate) fn init_module(m: &PyModule) -> PyResult<()> {
     m.add_class::<PySimilarTo>()?;
     m.add_class::<PyScalarVariable>()?;
     m.add_class::<alias::PyAlias>()?;
+    m.add_class::<between::PyBetween>()?;
     // operators
     m.add_class::<table_scan::PyTableScan>()?;
     m.add_class::<projection::PyProjection>()?;
diff --git a/src/expr/between.rs b/src/expr/between.rs
new file mode 100644
index 0000000..9b78b9e
--- /dev/null
+++ b/src/expr/between.rs
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::expr::PyExpr;
+use datafusion_expr::expr::Between;
+use pyo3::prelude::*;
+use std::fmt::{self, Display, Formatter};
+
+#[pyclass(name = "Between", module = "datafusion.expr", subclass)]
+#[derive(Clone)]
+pub struct PyBetween {
+    between: Between,
+}
+
+impl From<PyBetween> for Between {
+    fn from(between: PyBetween) -> Self {
+        between.between
+    }
+}
+
+impl From<Between> for PyBetween {
+    fn from(between: Between) -> PyBetween {
+        PyBetween { between }
+    }
+}
+
+impl Display for PyBetween {
+    fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+        write!(
+            f,
+            "Between
+            Expr: {:?}
+            Negated: {:?}
+            Low: {:?}
+            High: {:?}",
+            &self.between.expr, &self.between.negated, &self.between.low, 
&self.between.high
+        )
+    }
+}
+
+#[pymethods]
+impl PyBetween {
+    fn expr(&self) -> PyResult<PyExpr> {
+        Ok((*self.between.expr).clone().into())
+    }
+
+    fn negated(&self) -> PyResult<bool> {
+        Ok(self.between.negated)
+    }
+
+    fn low(&self) -> PyResult<PyExpr> {
+        Ok((*self.between.low).clone().into())
+    }
+
+    fn high(&self) -> PyResult<PyExpr> {
+        Ok((*self.between.high).clone().into())
+    }
+
+    fn __repr__(&self) -> String {
+        format!("{}", self)
+    }
+}

Reply via email to