Skip to content

Commit 48732b4

Browse files
authored
Support arithmetic operation on DictionaryArray (#5194)
* Support arithmetic operation on DictionaryArray * Add tests * Add some nulls to tests
1 parent 04b1367 commit 48732b4

3 files changed

Lines changed: 478 additions & 57 deletions

File tree

‎datafusion/expr/src/type_coercion/binary.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,10 @@ fn mathematics_numerical_coercion(
328328
// same type => all good
329329
// TODO: remove this
330330
// bug: https://github.com/apache/arrow-datafusion/issues/3387
331-
if lhs_type == rhs_type {
331+
if lhs_type == rhs_type
332+
&& !(matches!(lhs_type, DataType::Dictionary(_, _))
333+
|| matches!(rhs_type, DataType::Dictionary(_, _)))
334+
{
332335
return Some(lhs_type.clone());
333336
}
334337

@@ -341,6 +344,9 @@ fn mathematics_numerical_coercion(
341344
(Null, dec_type @ Decimal128(_, _)) | (dec_type @ Decimal128(_, _), Null) => {
342345
Some(dec_type.clone())
343346
}
347+
(Dictionary(_, lhs_value_type), Dictionary(_, rhs_value_type)) => {
348+
mathematics_numerical_coercion(mathematics_op, lhs_value_type, rhs_value_type)
349+
}
344350
(Dictionary(key_type, value_type), _) => {
345351
let value_type =
346352
mathematics_numerical_coercion(mathematics_op, value_type, rhs_type);

0 commit comments

Comments
 (0)