You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/05/08 05:15:35 UTC

(datafusion) branch gh-readonly-queue/main/pr-22054-2f29038f97b02d128e22208a082cfaebc07f36fd created (now bdb1c83a74)

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

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-22054-2f29038f97b02d128e22208a082cfaebc07f36fd
in repository https://gitbox.apache.org/repos/asf/datafusion.git


      at bdb1c83a74 Support `IS (NOT) DISTINCT FROM` in Unparser (#22054)

This branch includes the following new commits:

     new bdb1c83a74 Support `IS (NOT) DISTINCT FROM` in Unparser (#22054)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org


(datafusion) 01/01: Support `IS (NOT) DISTINCT FROM` in Unparser (#22054)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-22054-2f29038f97b02d128e22208a082cfaebc07f36fd
in repository https://gitbox.apache.org/repos/asf/datafusion.git

commit bdb1c83a74c89d53fc6531967f6618f87fa11dd2
Author: Peter L <ce...@hotmail.com>
AuthorDate: Fri May 8 14:45:14 2026 +0930

    Support `IS (NOT) DISTINCT FROM` in Unparser (#22054)
    
    ## Which issue does this PR close?
    
    Closes https://github.com/apache/datafusion/issues/22053
    
    ## Rationale for this change
    
    Extra support in the Unparser for `IS DISTINCT FROM` and `IS NOT
    DISTINCT FROM` expressions
    
    ## What changes are included in this PR?
    
    Changes to support operators in Unparser
    
    ## Are these changes tested?
    
    Yes, tests added
    
    ## Are there any user-facing changes?
    
    Not really!
---
 datafusion/sql/src/unparser/expr.rs | 47 +++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/datafusion/sql/src/unparser/expr.rs b/datafusion/sql/src/unparser/expr.rs
index e76aea5849..2124d5739c 100644
--- a/datafusion/sql/src/unparser/expr.rs
+++ b/datafusion/sql/src/unparser/expr.rs
@@ -148,6 +148,32 @@ impl Unparser<'_> {
                 ))))
             }
             Expr::Column(col) => self.col_to_sql(col),
+            Expr::BinaryExpr(BinaryExpr {
+                left,
+                op: Operator::IsDistinctFrom,
+                right,
+            }) => {
+                let l = self.expr_to_sql_inner(left.as_ref())?;
+                let r = self.expr_to_sql_inner(right.as_ref())?;
+
+                Ok(ast::Expr::Nested(Box::new(ast::Expr::IsDistinctFrom(
+                    Box::new(l),
+                    Box::new(r),
+                ))))
+            }
+            Expr::BinaryExpr(BinaryExpr {
+                left,
+                op: Operator::IsNotDistinctFrom,
+                right,
+            }) => {
+                let l = self.expr_to_sql_inner(left.as_ref())?;
+                let r = self.expr_to_sql_inner(right.as_ref())?;
+
+                Ok(ast::Expr::Nested(Box::new(ast::Expr::IsNotDistinctFrom(
+                    Box::new(l),
+                    Box::new(r),
+                ))))
+            }
             Expr::BinaryExpr(BinaryExpr { left, op, right }) => {
                 let l = self.expr_to_sql_inner(left.as_ref())?;
                 let r = self.expr_to_sql_inner(right.as_ref())?;
@@ -3681,4 +3707,25 @@ mod tests {
 
         Ok(())
     }
+
+    #[test]
+    fn test_is_distinct_from() {
+        let expr = Expr::BinaryExpr(BinaryExpr::new(
+            Box::new(col("c1")),
+            Operator::IsDistinctFrom,
+            Box::new(lit(true)),
+        ));
+
+        let sql = expr_to_sql(&expr).unwrap().to_string();
+        assert_eq!(sql, "(c1 IS DISTINCT FROM true)");
+
+        let expr = Expr::BinaryExpr(BinaryExpr::new(
+            Box::new(col("c1")),
+            Operator::IsNotDistinctFrom,
+            Box::new(lit(true)),
+        ));
+
+        let sql = expr_to_sql(&expr).unwrap().to_string();
+        assert_eq!(sql, "(c1 IS NOT DISTINCT FROM true)");
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org