Skip to content

Commit ccf6258

Browse files
authored
Add Utf8View to TypeCategory::Unknown (#13350)
* add utf8view Signed-off-by: jayzhan211 <[email protected]> * add test Signed-off-by: jayzhan211 <[email protected]> * fix comment Signed-off-by: Jay Zhan <[email protected]> --------- Signed-off-by: jayzhan211 <[email protected]> Signed-off-by: Jay Zhan <[email protected]>
1 parent 042843a commit ccf6258

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

datafusion/expr-common/src/type_coercion/binary.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,13 @@ impl From<&DataType> for TypeCategory {
330330
return TypeCategory::Array;
331331
}
332332

333-
// String literal is possible to cast to many other types like numeric or datetime,
334-
// therefore, it is categorized as a unknown type
333+
// It is categorized as unknown type because the type will be resolved later on
335334
if matches!(
336335
data_type,
337-
DataType::Utf8 | DataType::LargeUtf8 | DataType::Null
336+
DataType::Utf8
337+
| DataType::LargeUtf8
338+
| DataType::Utf8View
339+
| DataType::Null
338340
) {
339341
return TypeCategory::Unknown;
340342
}

datafusion/sqllogictest/test_files/coalesce.slt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ none_set
242242
statement ok
243243
drop table test1
244244

245+
# coalesce with utf8view
246+
query TTT
247+
select coalesce(arrow_cast(null, 'Utf8View'), arrow_cast('t', 'Utf8')),
248+
arrow_typeof(coalesce(arrow_cast(null, 'Utf8View'), arrow_cast('t', 'Utf8'))),
249+
arrow_typeof(coalesce(arrow_cast(null, 'Utf8'), arrow_cast('t', 'Utf8View')));
250+
----
251+
t Utf8View Utf8View
252+
245253
# test dict coercion with value
246254
statement ok
247255
create table t(c varchar) as values ('a'), (null);

0 commit comments

Comments
 (0)