diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rs index 31fe6a59baee..5bb098b75e23 100644 --- a/datafusion/expr-common/src/type_coercion/binary.rs +++ b/datafusion/expr-common/src/type_coercion/binary.rs @@ -650,8 +650,10 @@ fn string_numeric_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option 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, } } @@ -1127,7 +1129,8 @@ fn regex_comparison_string_coercion( fn numeric_string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option { 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()) diff --git a/datafusion/sqllogictest/test_files/strings.slt b/datafusion/sqllogictest/test_files/strings.slt index 81b8f4b2da9a..a6b7e5d54ea8 100644 --- a/datafusion/sqllogictest/test_files/strings.slt +++ b/datafusion/sqllogictest/test_files/strings.slt @@ -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; \ No newline at end of file