Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion datafusion/expr-common/src/type_coercion/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,10 @@ fn string_numeric_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<D
match (lhs_type, rhs_type) {
(Utf8, _) if rhs_type.is_numeric() => Some(Utf8),
(LargeUtf8, _) if rhs_type.is_numeric() => Some(LargeUtf8),
(Utf8View, _) if rhs_type.is_numeric() => Some(Utf8View),
(_, Utf8) if lhs_type.is_numeric() => Some(Utf8),
(_, LargeUtf8) if lhs_type.is_numeric() => Some(LargeUtf8),
(_, Utf8View) if lhs_type.is_numeric() => Some(Utf8View),
_ => None,
}
}
Expand Down Expand Up @@ -1127,7 +1129,8 @@ fn regex_comparison_string_coercion(
fn numeric_string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
use arrow::datatypes::DataType::*;
match (lhs_type, rhs_type) {
(Utf8 | LargeUtf8, other_type) | (other_type, Utf8 | LargeUtf8)
(Utf8 | Utf8View | LargeUtf8, other_type)
| (other_type, Utf8 | Utf8View | LargeUtf8)
if other_type.is_numeric() =>
{
Some(other_type.clone())
Expand Down
12 changes: 12 additions & 0 deletions datafusion/sqllogictest/test_files/strings.slt
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,15 @@ def

statement ok
drop table vals;

# test numeric_string_conversion
statement ok
create table foo as values (arrow_cast('1', 'Utf8View')), (arrow_cast('2', 'Utf8View'));

query T
select column1 = 1 from foo1;
----


statement ok
drop table foo;
Loading