Skip to content

Commit 610fdec

Browse files
committed
hack string_concat_coercion
1 parent a3c239b commit 610fdec

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

datafusion/expr/src/type_coercion/binary.rs

+14-22
Original file line numberDiff line numberDiff line change
@@ -890,15 +890,21 @@ fn dictionary_coercion(
890890
/// 2. Data type of the other side should be able to cast to string type
891891
fn string_concat_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
892892
use arrow::datatypes::DataType::*;
893-
string_coercion_duplicate(lhs_type, rhs_type).or(match (lhs_type, rhs_type) {
894-
(Utf8, from_type) | (from_type, Utf8) => {
895-
string_concat_internal_coercion(from_type, &Utf8)
896-
}
897-
(LargeUtf8, from_type) | (from_type, LargeUtf8) => {
898-
string_concat_internal_coercion(from_type, &LargeUtf8)
893+
match (lhs_type, rhs_type) {
894+
// If Utf8View is in any side, we coerce to Utf8.
895+
(Utf8View, Utf8View | Utf8 | LargeUtf8) | (Utf8 | LargeUtf8, Utf8View) => {
896+
Some(Utf8)
899897
}
900-
_ => None,
901-
})
898+
_ => string_coercion(lhs_type, rhs_type).or(match (lhs_type, rhs_type) {
899+
(Utf8, from_type) | (from_type, Utf8) => {
900+
string_concat_internal_coercion(from_type, &Utf8)
901+
}
902+
(LargeUtf8, from_type) | (from_type, LargeUtf8) => {
903+
string_concat_internal_coercion(from_type, &LargeUtf8)
904+
}
905+
_ => None,
906+
}),
907+
}
902908
}
903909

904910
fn array_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
@@ -939,20 +945,6 @@ fn string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType>
939945
}
940946
}
941947

942-
fn string_coercion_duplicate(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
943-
use arrow::datatypes::DataType::*;
944-
match (lhs_type, rhs_type) {
945-
// If Utf8View is in any side, we coerce to Utf8.
946-
(Utf8View, Utf8View | Utf8 | LargeUtf8) | (Utf8 | LargeUtf8, Utf8View) => {
947-
Some(Utf8)
948-
}
949-
// Then, if LargeUtf8 is in any side, we coerce to LargeUtf8.
950-
(LargeUtf8, Utf8 | LargeUtf8) | (Utf8, LargeUtf8) => Some(LargeUtf8),
951-
(Utf8, Utf8) => Some(Utf8),
952-
_ => None,
953-
}
954-
}
955-
956948
fn numeric_string_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> {
957949
use arrow::datatypes::DataType::*;
958950
match (lhs_type, rhs_type) {

0 commit comments

Comments
 (0)