This is an automated email from the ASF dual-hosted git repository.
comphead pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 52fb1a0d3a Support spaceship operator (`<=>`) support (alias for `IS
NOT DISTINCT FROM` (#14187)
52fb1a0d3a is described below
commit 52fb1a0d3aa2c0139bcb35674f8e51b5d294786c
Author: Spaarsh <[email protected]>
AuthorDate: Mon Jan 20 00:04:12 2025 +0530
Support spaceship operator (`<=>`) support (alias for `IS NOT DISTINCT
FROM` (#14187)
* Mapped the Spaceship operator with IsNotDistinctFrom
* Added tests for Spaceship Operator <=>
* Added sanity test for Spaceship Operator <=>
---
datafusion/sql/src/expr/binary_op.rs | 1 +
datafusion/sqllogictest/test_files/expr.slt | 56 +++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/datafusion/sql/src/expr/binary_op.rs
b/datafusion/sql/src/expr/binary_op.rs
index eaf28adf4e..729304066d 100644
--- a/datafusion/sql/src/expr/binary_op.rs
+++ b/datafusion/sql/src/expr/binary_op.rs
@@ -53,6 +53,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
BinaryOperator::StringConcat => Ok(Operator::StringConcat),
BinaryOperator::ArrowAt => Ok(Operator::ArrowAt),
BinaryOperator::AtArrow => Ok(Operator::AtArrow),
+ BinaryOperator::Spaceship => Ok(Operator::IsNotDistinctFrom),
_ => not_impl_err!("Unsupported SQL binary operator {op:?}"),
}
}
diff --git a/datafusion/sqllogictest/test_files/expr.slt
b/datafusion/sqllogictest/test_files/expr.slt
index 06e2f4154d..e3ea9cd38a 100644
--- a/datafusion/sqllogictest/test_files/expr.slt
+++ b/datafusion/sqllogictest/test_files/expr.slt
@@ -1565,6 +1565,62 @@ select NULL < column1 from (VALUES (true), (false)) as t;
NULL
NULL
+#### comparisons_with_spaceship_operator
+
+# Basic comparisons
+query B
+select 1 <=> 1;
+----
+true
+
+query B
+select 1 <=> 2;
+----
+false
+
+# NULL handling
+query B
+select NULL <=> NULL;
+----
+true
+
+query B
+select 1 <=> NULL;
+----
+false
+
+query B
+select NULL <=> 1;
+----
+false
+
+# Table comparisons
+query B
+select column1 <=> column2 from (VALUES (1, 1), (2, 3), (NULL, NULL)) as t;
+----
+true
+false
+true
+
+# Sanity test - comparing <=> with equivalent expression
+query B
+SELECT
+ (column1 <=> column2) =
+ (IFNULL(column1, false) = IFNULL(column2, false)) AS comparison_result
+FROM (VALUES
+ (1, 1), -- equal values
+ (1, 2), -- different values
+ (NULL, NULL), -- both NULL
+ (1, NULL), -- first not NULL, second NULL
+ (NULL, 1) -- first NULL, second not NULL
+) AS t(column1, column2);
+----
+true
+true
+true
+true
+true
+
#### binary_mathematical_operator_with_null_lt
# 1. Integer and NULL
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]