Apache DataFusion SQL Query Engine
fix concat dictionary(int32, utf8) bug (#12143)
iamthinha58416c2eae4
diff --git a/datafusion/expr-common/src/type_coercion/binary.rs b/datafusion/expr-common/src/type_coercion/binary.rsindex 401762ad4d..552bc89b38 100644--- a/datafusion/expr-common/src/type_coercion/binary.rs+++ b/datafusion/expr-common/src/type_coercion/binary.rs@@ -936,6 +936,9 @@ fn string_concat_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<Da(LargeUtf8, from_type) | (from_type, LargeUtf8) => {string_concat_internal_coercion(from_type, &LargeUtf8)}+ (Dictionary(_, lhs_value_type), Dictionary(_, rhs_value_type)) => {+ string_coercion(lhs_value_type, rhs_value_type).or(None)+ }_ => None,})}diff --git a/datafusion/sqllogictest/test_files/type_coercion.slt b/datafusion/sqllogictest/test_files/type_coercion.sltindex e420c0cc71..0f9399cede 100644--- a/datafusion/sqllogictest/test_files/type_coercion.slt+++ b/datafusion/sqllogictest/test_files/type_coercion.slt@@ -50,6 +50,35 @@ select interval '1 month' - '2023-05-01'::date;query error DataFusion error: Error during planning: Cannot coerce arithmetic expression Interval\(MonthDayNano\) \- Timestamp\(Nanosecond, None\) to valid typesSELECT interval '1 month' - '2023-05-01 12:30:00'::timestamp;+# dictionary(int32, utf8) -> utf8+query T+select arrow_cast('foo', 'Dictionary(Int32, Utf8)') || arrow_cast('bar', 'Dictionary(Int32, Utf8)');+----+foobar++# dictionary(int32, largeUtf8) -> largeUtf8+query T+select arrow_cast('foo', 'Dictionary(Int32, LargeUtf8)') || arrow_cast('bar', 'Dictionary(Int32, LargeUtf8)');+----+foobar++####################################+## Concat column dictionary test ##+####################################+statement ok+create table t as values (arrow_cast('foo', 'Dictionary(Int32, Utf8)'), arrow_cast('bar', 'Dictionary(Int32, Utf8)'));++query T+select column1 || column2 from t;+----+foobar++statement ok+DROP TABLE t++#######################################+## Concat column dictionary test end ##+############################################################################# Test type coercion with UNIONs ##