@@ -23,10 +23,10 @@ mod min_max_struct;
23
23
24
24
use arrow:: array:: ArrayRef ;
25
25
use arrow:: datatypes:: {
26
- DataType , Decimal128Type , Decimal256Type , DurationMicrosecondType ,
27
- DurationMillisecondType , DurationNanosecondType , DurationSecondType , Float16Type ,
28
- Float32Type , Float64Type , Int16Type , Int32Type , Int64Type , Int8Type , UInt16Type ,
29
- UInt32Type , UInt64Type , UInt8Type ,
26
+ DataType , Decimal128Type , Decimal256Type , Decimal32Type , Decimal64Type ,
27
+ DurationMicrosecondType , DurationMillisecondType , DurationNanosecondType ,
28
+ DurationSecondType , Float16Type , Float32Type , Float64Type , Int16Type , Int32Type ,
29
+ Int64Type , Int8Type , UInt16Type , UInt32Type , UInt64Type , UInt8Type ,
30
30
} ;
31
31
use datafusion_common:: stats:: Precision ;
32
32
use datafusion_common:: {
@@ -323,6 +323,12 @@ impl AggregateUDFImpl for Max {
323
323
Duration ( Nanosecond ) => {
324
324
primitive_max_accumulator ! ( data_type, i64 , DurationNanosecondType )
325
325
}
326
+ Decimal32 ( _, _) => {
327
+ primitive_max_accumulator ! ( data_type, i32 , Decimal32Type )
328
+ }
329
+ Decimal64 ( _, _) => {
330
+ primitive_max_accumulator ! ( data_type, i64 , Decimal64Type )
331
+ }
326
332
Decimal128 ( _, _) => {
327
333
primitive_max_accumulator ! ( data_type, i128 , Decimal128Type )
328
334
}
@@ -484,6 +490,32 @@ macro_rules! min_max {
484
490
( $VALUE: expr, $DELTA: expr, $OP: ident) => { {
485
491
Ok ( match ( $VALUE, $DELTA) {
486
492
( ScalarValue :: Null , ScalarValue :: Null ) => ScalarValue :: Null ,
493
+ (
494
+ lhs @ ScalarValue :: Decimal32 ( lhsv, lhsp, lhss) ,
495
+ rhs @ ScalarValue :: Decimal32 ( rhsv, rhsp, rhss)
496
+ ) => {
497
+ if lhsp. eq( rhsp) && lhss. eq( rhss) {
498
+ typed_min_max!( lhsv, rhsv, Decimal32 , $OP, lhsp, lhss)
499
+ } else {
500
+ return internal_err!(
501
+ "MIN/MAX is not expected to receive scalars of incompatible types {:?}" ,
502
+ ( lhs, rhs)
503
+ ) ;
504
+ }
505
+ }
506
+ (
507
+ lhs @ ScalarValue :: Decimal64 ( lhsv, lhsp, lhss) ,
508
+ rhs @ ScalarValue :: Decimal64 ( rhsv, rhsp, rhss)
509
+ ) => {
510
+ if lhsp. eq( rhsp) && lhss. eq( rhss) {
511
+ typed_min_max!( lhsv, rhsv, Decimal64 , $OP, lhsp, lhss)
512
+ } else {
513
+ return internal_err!(
514
+ "MIN/MAX is not expected to receive scalars of incompatible types {:?}" ,
515
+ ( lhs, rhs)
516
+ ) ;
517
+ }
518
+ }
487
519
(
488
520
lhs @ ScalarValue :: Decimal128 ( lhsv, lhsp, lhss) ,
489
521
rhs @ ScalarValue :: Decimal128 ( rhsv, rhsp, rhss)
@@ -919,6 +951,8 @@ impl AggregateUDFImpl for Min {
919
951
| Float16
920
952
| Float32
921
953
| Float64
954
+ | Decimal32 ( _, _)
955
+ | Decimal64 ( _, _)
922
956
| Decimal128 ( _, _)
923
957
| Decimal256 ( _, _)
924
958
| Date32
@@ -1000,6 +1034,12 @@ impl AggregateUDFImpl for Min {
1000
1034
Duration ( Nanosecond ) => {
1001
1035
primitive_min_accumulator ! ( data_type, i64 , DurationNanosecondType )
1002
1036
}
1037
+ Decimal32 ( _, _) => {
1038
+ primitive_min_accumulator ! ( data_type, i32 , Decimal32Type )
1039
+ }
1040
+ Decimal64 ( _, _) => {
1041
+ primitive_min_accumulator ! ( data_type, i64 , Decimal64Type )
1042
+ }
1003
1043
Decimal128 ( _, _) => {
1004
1044
primitive_min_accumulator ! ( data_type, i128 , Decimal128Type )
1005
1045
}
0 commit comments