This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new a58416c2ea fix concat dictionary(int32, utf8) bug (#12143)
a58416c2ea is described below
commit a58416c2eae47d19f0ef4756768f1e978d7c7dd3
Author: iamthinh <[email protected]>
AuthorDate: Sat Aug 24 04:00:38 2024 -0700
fix concat dictionary(int32, utf8) bug (#12143)
* fix concat bug
* clippy fix
---
datafusion/expr-common/src/type_coercion/binary.rs | 3 +++
.../sqllogictest/test_files/type_coercion.slt | 29 ++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/datafusion/expr-common/src/type_coercion/binary.rs
b/datafusion/expr-common/src/type_coercion/binary.rs
index 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.slt
index 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
types
SELECT 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 ##
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]