Skip to content

Commit 8668da6

Browse files
authored
Decimal256 coercion (#7034)
* Add Decimal256 ARM to TypeCoercion is_signed_numeric & is_decimal functions * Add Decimal256 to aggregates.rs as well
1 parent 7e2cca8 commit 8668da6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

datafusion/expr/src/type_coercion/aggregates.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ pub fn is_sum_support_arg_type(arg_type: &DataType) -> bool {
467467
_ => matches!(
468468
arg_type,
469469
arg_type if NUMERICS.contains(arg_type)
470-
|| matches!(arg_type, DataType::Decimal128(_, _))
470+
|| matches!(arg_type, DataType::Decimal128(_, _) | DataType::Decimal256(_, _))
471471
),
472472
}
473473
}
@@ -480,7 +480,7 @@ pub fn is_avg_support_arg_type(arg_type: &DataType) -> bool {
480480
_ => matches!(
481481
arg_type,
482482
arg_type if NUMERICS.contains(arg_type)
483-
|| matches!(arg_type, DataType::Decimal128(_, _))
483+
|| matches!(arg_type, DataType::Decimal128(_, _)| DataType::Decimal256(_, _))
484484
),
485485
}
486486
}
@@ -579,6 +579,7 @@ mod tests {
579579
let input_types = vec![
580580
vec![DataType::Int32],
581581
vec![DataType::Decimal128(10, 2)],
582+
vec![DataType::Decimal256(1, 1)],
582583
vec![DataType::Utf8],
583584
];
584585
for fun in funs {
@@ -594,6 +595,7 @@ mod tests {
594595
vec![DataType::Int32],
595596
vec![DataType::Float32],
596597
vec![DataType::Decimal128(20, 3)],
598+
vec![DataType::Decimal256(20, 3)],
597599
];
598600
for fun in funs {
599601
for input_type in &input_types {

datafusion/expr/src/type_coercion/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub fn is_signed_numeric(dt: &DataType) -> bool {
4949
| DataType::Float32
5050
| DataType::Float64
5151
| DataType::Decimal128(_, _)
52+
| DataType::Decimal256(_, _),
5253
)
5354
}
5455

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

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

0 commit comments

Comments
 (0)