Skip to content

Apache DataFusion SQL Query Engine

fix: largeUtf8 don't support `is distinct from` (#5993)

jakevin48c0a2b9c2b7
diff --git a/datafusion/core/tests/sqllogictests/test_files/select.slt b/datafusion/core/tests/sqllogictests/test_files/select.slt
index b0105d8de9..7d5a7717a7 100644
--- a/datafusion/core/tests/sqllogictests/test_files/select.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/select.slt
@@ -255,3 +255,13 @@ query B
select column1 not ilike column2 from t;
----
false
+
+query B
+select column1 is distinct from column2 from t;
+----
+true
+
+query B
+select column1 is not distinct from column2 from t;
+----
+false
diff --git a/datafusion/core/tests/sqllogictests/test_files/type_coercion.slt b/datafusion/core/tests/sqllogictests/test_files/type_coercion.slt
new file mode 100644
index 0000000000..f39d1caab1
--- /dev/null
+++ b/datafusion/core/tests/sqllogictests/test_files/type_coercion.slt
@@ -0,0 +1,31 @@
+# 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.
+
+##########
+## Test type coercion
+##########
+
+# test utf8 and large utf8
+query B
+select 's' is distinct from arrow_cast('s', 'LargeUtf8');
+----
+false
+
+query B
+select 's' is not distinct from arrow_cast('s', 'LargeUtf8');
+----
+true
diff --git a/datafusion/physical-expr/src/expressions/binary.rs b/datafusion/physical-expr/src/expressions/binary.rs
index 420abe313d..070c12eb6f 100644
--- a/datafusion/physical-expr/src/expressions/binary.rs
+++ b/datafusion/physical-expr/src/expressions/binary.rs
@@ -504,6 +504,7 @@ macro_rules! binary_array_op {
DataType::Float32 => compute_f32_op!($LEFT, $RIGHT, $OP, Float32Array),
DataType::Float64 => compute_f64_op!($LEFT, $RIGHT, $OP, Float64Array),
DataType::Utf8 => compute_utf8_op!($LEFT, $RIGHT, $OP, StringArray),
+ DataType::LargeUtf8 => compute_utf8_op!($LEFT, $RIGHT, $OP, LargeStringArray),
DataType::Timestamp(TimeUnit::Nanosecond, _) => {
compute_op!($LEFT, $RIGHT, $OP, TimestampNanosecondArray)
}