@@ -23,10 +23,7 @@ use arrow::array::{Array, Float16Array};
2323use arrow:: compute:: { filter, is_not_null} ;
2424use arrow:: datatypes:: FieldRef ;
2525use arrow:: {
26- array:: {
27- ArrayRef , Float32Array , Float64Array , Int8Array , Int16Array , Int32Array ,
28- Int64Array , UInt8Array , UInt16Array , UInt32Array , UInt64Array ,
29- } ,
26+ array:: { ArrayRef , Float32Array , Float64Array } ,
3027 datatypes:: { DataType , Field } ,
3128} ;
3229use datafusion_common:: types:: { NativeType , logical_float64} ;
@@ -200,17 +197,7 @@ impl ApproxPercentileCont {
200197
201198 let data_type = args. expr_fields [ 0 ] . data_type ( ) ;
202199 let accumulator: ApproxPercentileAccumulator = match data_type {
203- DataType :: UInt8
204- | DataType :: UInt16
205- | DataType :: UInt32
206- | DataType :: UInt64
207- | DataType :: Int8
208- | DataType :: Int16
209- | DataType :: Int32
210- | DataType :: Int64
211- | DataType :: Float16
212- | DataType :: Float32
213- | DataType :: Float64 => {
200+ DataType :: Float16 | DataType :: Float32 | DataType :: Float64 => {
214201 if let Some ( max_size) = tdigest_max_size {
215202 ApproxPercentileAccumulator :: new_with_max_size (
216203 percentile,
@@ -397,38 +384,6 @@ impl ApproxPercentileAccumulator {
397384 . map ( |v| v. to_f64 ( ) )
398385 . collect :: < Vec < _ > > ( ) )
399386 }
400- DataType :: Int64 => {
401- let array = downcast_value ! ( values, Int64Array ) ;
402- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
403- }
404- DataType :: Int32 => {
405- let array = downcast_value ! ( values, Int32Array ) ;
406- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
407- }
408- DataType :: Int16 => {
409- let array = downcast_value ! ( values, Int16Array ) ;
410- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
411- }
412- DataType :: Int8 => {
413- let array = downcast_value ! ( values, Int8Array ) ;
414- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
415- }
416- DataType :: UInt64 => {
417- let array = downcast_value ! ( values, UInt64Array ) ;
418- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
419- }
420- DataType :: UInt32 => {
421- let array = downcast_value ! ( values, UInt32Array ) ;
422- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
423- }
424- DataType :: UInt16 => {
425- let array = downcast_value ! ( values, UInt16Array ) ;
426- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
427- }
428- DataType :: UInt8 => {
429- let array = downcast_value ! ( values, UInt8Array ) ;
430- Ok ( array. values ( ) . iter ( ) . map ( |v| * v as f64 ) . collect :: < Vec < _ > > ( ) )
431- }
432387 e => internal_err ! (
433388 "APPROX_PERCENTILE_CONT is not expected to receive the type {e:?}"
434389 ) ,
@@ -462,14 +417,6 @@ impl Accumulator for ApproxPercentileAccumulator {
462417 // These acceptable return types MUST match the validation in
463418 // ApproxPercentile::create_accumulator.
464419 Ok ( match & self . return_type {
465- DataType :: Int8 => ScalarValue :: Int8 ( Some ( q as i8 ) ) ,
466- DataType :: Int16 => ScalarValue :: Int16 ( Some ( q as i16 ) ) ,
467- DataType :: Int32 => ScalarValue :: Int32 ( Some ( q as i32 ) ) ,
468- DataType :: Int64 => ScalarValue :: Int64 ( Some ( q as i64 ) ) ,
469- DataType :: UInt8 => ScalarValue :: UInt8 ( Some ( q as u8 ) ) ,
470- DataType :: UInt16 => ScalarValue :: UInt16 ( Some ( q as u16 ) ) ,
471- DataType :: UInt32 => ScalarValue :: UInt32 ( Some ( q as u32 ) ) ,
472- DataType :: UInt64 => ScalarValue :: UInt64 ( Some ( q as u64 ) ) ,
473420 DataType :: Float16 => ScalarValue :: Float16 ( Some ( half:: f16:: from_f64 ( q) ) ) ,
474421 DataType :: Float32 => ScalarValue :: Float32 ( Some ( q as f32 ) ) ,
475422 DataType :: Float64 => ScalarValue :: Float64 ( Some ( q) ) ,
0 commit comments