Skip to content

Apache DataFusion SQL Query Engine

Add Utf8View to `TypeCategory::Unknown` (#13350)

Jay Zhanccf6258a1e02
diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rs
index 31fe6a59ba..c32b4951db 100644
--- a/datafusion/expr-common/src/type_coercion/binary.rs
+++ b/datafusion/expr-common/src/type_coercion/binary.rs
@@ -330,11 +330,13 @@ impl From<&DataType> for TypeCategory {
return TypeCategory::Array;
}
- // String literal is possible to cast to many other types like numeric or datetime,
- // therefore, it is categorized as a unknown type
+ // It is categorized as unknown type because the type will be resolved later on
if matches!(
data_type,
- DataType::Utf8 | DataType::LargeUtf8 | DataType::Null
+ DataType::Utf8
+ | DataType::LargeUtf8
+ | DataType::Utf8View
+ | DataType::Null
) {
return TypeCategory::Unknown;
}
diff --git a/datafusion/sqllogictest/test_files/coalesce.slt b/datafusion/sqllogictest/test_files/coalesce.slt
index 97e77d0feb..06460a005c 100644
--- a/datafusion/sqllogictest/test_files/coalesce.slt
+++ b/datafusion/sqllogictest/test_files/coalesce.slt
@@ -242,6 +242,14 @@ none_set
statement ok
drop table test1
+# coalesce with utf8view
+query TTT
+select coalesce(arrow_cast(null, 'Utf8View'), arrow_cast('t', 'Utf8')),
+ arrow_typeof(coalesce(arrow_cast(null, 'Utf8View'), arrow_cast('t', 'Utf8'))),
+ arrow_typeof(coalesce(arrow_cast(null, 'Utf8'), arrow_cast('t', 'Utf8View')));
+----
+t Utf8View Utf8View
+
# test dict coercion with value
statement ok
create table t(c varchar) as values ('a'), (null);