@@ -33,9 +33,10 @@ use arrow::array::{
3333} ;
3434use arrow:: compute;
3535use arrow:: datatypes:: {
36- DataType , Decimal128Type , Decimal256Type , Float16Type , Float32Type , Float64Type ,
37- Int16Type , Int32Type , Int64Type , Int8Type , IntervalUnit , UInt16Type , UInt32Type ,
38- UInt64Type , UInt8Type ,
36+ DataType , Decimal128Type , Decimal256Type , DurationMicrosecondType ,
37+ DurationMillisecondType , DurationNanosecondType , DurationSecondType , Float16Type ,
38+ Float32Type , Float64Type , Int16Type , Int32Type , Int64Type , Int8Type , IntervalUnit ,
39+ UInt16Type , UInt32Type , UInt64Type , UInt8Type ,
3940} ;
4041use datafusion_common:: stats:: Precision ;
4142use datafusion_common:: {
@@ -264,6 +265,7 @@ impl AggregateUDFImpl for Max {
264265 | Binary
265266 | LargeBinary
266267 | BinaryView
268+ | Duration ( _)
267269 )
268270 }
269271
@@ -318,6 +320,18 @@ impl AggregateUDFImpl for Max {
318320 Timestamp ( Nanosecond , _) => {
319321 primitive_max_accumulator ! ( data_type, i64 , TimestampNanosecondType )
320322 }
323+ Duration ( Second ) => {
324+ primitive_max_accumulator ! ( data_type, i64 , DurationSecondType )
325+ }
326+ Duration ( Millisecond ) => {
327+ primitive_max_accumulator ! ( data_type, i64 , DurationMillisecondType )
328+ }
329+ Duration ( Microsecond ) => {
330+ primitive_max_accumulator ! ( data_type, i64 , DurationMicrosecondType )
331+ }
332+ Duration ( Nanosecond ) => {
333+ primitive_max_accumulator ! ( data_type, i64 , DurationNanosecondType )
334+ }
321335 Decimal128 ( _, _) => {
322336 primitive_max_accumulator ! ( data_type, i128 , Decimal128Type )
323337 }
@@ -1118,6 +1132,7 @@ impl AggregateUDFImpl for Min {
11181132 | Binary
11191133 | LargeBinary
11201134 | BinaryView
1135+ | Duration ( _)
11211136 )
11221137 }
11231138
@@ -1172,6 +1187,18 @@ impl AggregateUDFImpl for Min {
11721187 Timestamp ( Nanosecond , _) => {
11731188 primitive_min_accumulator ! ( data_type, i64 , TimestampNanosecondType )
11741189 }
1190+ Duration ( Second ) => {
1191+ primitive_min_accumulator ! ( data_type, i64 , DurationSecondType )
1192+ }
1193+ Duration ( Millisecond ) => {
1194+ primitive_min_accumulator ! ( data_type, i64 , DurationMillisecondType )
1195+ }
1196+ Duration ( Microsecond ) => {
1197+ primitive_min_accumulator ! ( data_type, i64 , DurationMicrosecondType )
1198+ }
1199+ Duration ( Nanosecond ) => {
1200+ primitive_min_accumulator ! ( data_type, i64 , DurationNanosecondType )
1201+ }
11751202 Decimal128 ( _, _) => {
11761203 primitive_min_accumulator ! ( data_type, i128 , Decimal128Type )
11771204 }
0 commit comments