Skip to content

Commit

Permalink
Decimal256 coercion (#7034)
Browse files Browse the repository at this point in the history
* Add Decimal256 ARM to TypeCoercion is_signed_numeric & is_decimal functions

* Add Decimal256 to aggregates.rs as well
  • Loading branch information
jdye64 authored Jul 20, 2023
1 parent 7e2cca8 commit 8668da6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions datafusion/expr/src/type_coercion/aggregates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ pub fn is_sum_support_arg_type(arg_type: &DataType) -> bool {
_ => matches!(
arg_type,
arg_type if NUMERICS.contains(arg_type)
|| matches!(arg_type, DataType::Decimal128(_, _))
|| matches!(arg_type, DataType::Decimal128(_, _) | DataType::Decimal256(_, _))
),
}
}
Expand All @@ -480,7 +480,7 @@ pub fn is_avg_support_arg_type(arg_type: &DataType) -> bool {
_ => matches!(
arg_type,
arg_type if NUMERICS.contains(arg_type)
|| matches!(arg_type, DataType::Decimal128(_, _))
|| matches!(arg_type, DataType::Decimal128(_, _)| DataType::Decimal256(_, _))
),
}
}
Expand Down Expand Up @@ -579,6 +579,7 @@ mod tests {
let input_types = vec![
vec![DataType::Int32],
vec![DataType::Decimal128(10, 2)],
vec![DataType::Decimal256(1, 1)],
vec![DataType::Utf8],
];
for fun in funs {
Expand All @@ -594,6 +595,7 @@ mod tests {
vec![DataType::Int32],
vec![DataType::Float32],
vec![DataType::Decimal128(20, 3)],
vec![DataType::Decimal256(20, 3)],
];
for fun in funs {
for input_type in &input_types {
Expand Down
3 changes: 2 additions & 1 deletion datafusion/expr/src/type_coercion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub fn is_signed_numeric(dt: &DataType) -> bool {
| DataType::Float32
| DataType::Float64
| DataType::Decimal128(_, _)
| DataType::Decimal256(_, _),
)
}

Expand Down Expand Up @@ -91,5 +92,5 @@ pub fn is_utf8_or_large_utf8(dt: &DataType) -> bool {

/// Determine whether the given data type `dt` is a `Decimal`.
pub fn is_decimal(dt: &DataType) -> bool {
matches!(dt, DataType::Decimal128(_, _))
matches!(dt, DataType::Decimal128(_, _) | DataType::Decimal256(_, _))
}

0 comments on commit 8668da6

Please sign in to comment.