Skip to content

Commit

Permalink
Add Utf8View to TypeCategory::Unknown (#13350)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
jayzhan211 authored Nov 13, 2024
1 parent 042843a commit ccf6258
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions datafusion/expr-common/src/type_coercion/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions datafusion/sqllogictest/test_files/coalesce.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ccf6258

Please sign in to comment.