You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2021/03/02 11:05:41 UTC

[arrow] branch master updated: ARROW-11742: [Rust][DataFusion] Add Expr::is_null and Expr::is_not_nu…

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

alamb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 9460da1  ARROW-11742: [Rust][DataFusion] Add Expr::is_null and Expr::is_not_nu…
9460da1 is described below

commit 9460da1a9d74730e599f308f0885c53a7c47c1bf
Author: Nga Tran <nt...@influxdata.com>
AuthorDate: Tue Mar 2 06:04:10 2021 -0500

    ARROW-11742: [Rust][DataFusion] Add Expr::is_null and Expr::is_not_nu…
    
    Implement is_null and is_not_null for DataFusion logical_plan's Expr specified in[ ARROW-11742](https://issues.apache.org/jira/browse/ARROW-11742)
    
    Closes #9608 from NGA-TRAN/ARROW-11742
    
    Authored-by: Nga Tran <nt...@influxdata.com>
    Signed-off-by: Andrew Lamb <an...@nerdnetworks.org>
---
 rust/datafusion/src/logical_plan/expr.rs | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/rust/datafusion/src/logical_plan/expr.rs b/rust/datafusion/src/logical_plan/expr.rs
index 775ab64..f40e524 100644
--- a/rust/datafusion/src/logical_plan/expr.rs
+++ b/rust/datafusion/src/logical_plan/expr.rs
@@ -442,6 +442,18 @@ impl Expr {
         }
     }
 
+    /// Return `IsNull(Box(self))
+    #[allow(clippy::wrong_self_convention)]
+    pub fn is_null(self) -> Expr {
+        Expr::IsNull(Box::new(self))
+    }
+
+    /// Return `IsNotNull(Box(self))
+    #[allow(clippy::wrong_self_convention)]
+    pub fn is_not_null(self) -> Expr {
+        Expr::IsNotNull(Box::new(self))
+    }
+
     /// Create a sort expression from an existing expression.
     ///
     /// ```
@@ -1388,6 +1400,17 @@ mod tests {
         )
     }
 
+    #[test]
+    fn filter_is_null_and_is_not_null() {
+        let col_null = Expr::Column("col1".to_string());
+        let col_not_null = Expr::Column("col2".to_string());
+        assert_eq!(format!("{:?}", col_null.is_null()), "#col1 IS NULL");
+        assert_eq!(
+            format!("{:?}", col_not_null.is_not_null()),
+            "#col2 IS NOT NULL"
+        );
+    }
+
     #[derive(Default)]
     struct RecordingRewriter {
         v: Vec<String>,