Skip to content

Apache DataFusion SQL Query Engine

Fix Utf8View as Join Key (#13115)

Dmitry Bugakov67b0f2573e3c
diff --git a/datafusion/expr/src/utils.rs b/datafusion/expr/src/utils.rs
index bb5496c0f7..9207ad0099 100644
--- a/datafusion/expr/src/utils.rs
+++ b/datafusion/expr/src/utils.rs
@@ -981,6 +981,7 @@ pub fn can_hash(data_type: &DataType) -> bool {
},
DataType::Utf8 => true,
DataType::LargeUtf8 => true,
+ DataType::Utf8View => true,
DataType::Decimal128(_, _) => true,
DataType::Date32 => true,
DataType::Date64 => true,
diff --git a/datafusion/sqllogictest/test_files/joins.slt b/datafusion/sqllogictest/test_files/joins.slt
index af272e8f50..bc40f845cc 100644
--- a/datafusion/sqllogictest/test_files/joins.slt
+++ b/datafusion/sqllogictest/test_files/joins.slt
@@ -4277,3 +4277,16 @@ physical_plan
02)--HashJoinExec: mode=CollectLeft, join_type=Full, on=[(c1@0, c1@0)], filter=c2@0 >= c2@1
03)----MemoryExec: partitions=1, partition_sizes=[1]
04)----MemoryExec: partitions=1, partition_sizes=[1]
+
+# Test Utf8View as Join Key
+# Issue: https://github.com/apache/datafusion/issues/12468
+statement ok
+CREATE TABLE table1(v1 STRING) AS VALUES ('foo'), (NULL);
+
+statement ok
+CREATE TABLE table1_stringview AS SELECT arrow_cast(v1, 'Utf8View') AS v1 FROM table1;
+
+query T
+select * from table1 as t1 natural join table1_stringview as t2;
+----
+foo