@@ -80,8 +80,8 @@ pub enum AggregateFunction {
8080 CovariancePop ,
8181 /// Correlation
8282 Correlation ,
83- /// Approximate quantile function
84- ApproxQuantile ,
83+ /// Approximate continuous percentile function
84+ ApproxPercentileCont ,
8585}
8686
8787impl fmt:: Display for AggregateFunction {
@@ -112,7 +112,7 @@ impl FromStr for AggregateFunction {
112112 "covar_samp" => AggregateFunction :: Covariance ,
113113 "covar_pop" => AggregateFunction :: CovariancePop ,
114114 "corr" => AggregateFunction :: Correlation ,
115- "approx_quantile " => AggregateFunction :: ApproxQuantile ,
115+ "approx_percentile_cont " => AggregateFunction :: ApproxPercentileCont ,
116116 _ => {
117117 return Err ( DataFusionError :: Plan ( format ! (
118118 "There is no built-in function named {}" ,
@@ -160,7 +160,7 @@ pub fn return_type(
160160 coerced_data_types[ 0 ] . clone ( ) ,
161161 true ,
162162 ) ) ) ) ,
163- AggregateFunction :: ApproxQuantile => Ok ( coerced_data_types[ 0 ] . clone ( ) ) ,
163+ AggregateFunction :: ApproxPercentileCont => Ok ( coerced_data_types[ 0 ] . clone ( ) ) ,
164164 }
165165}
166166
@@ -335,17 +335,18 @@ pub fn create_aggregate_expr(
335335 "CORR(DISTINCT) aggregations are not available" . to_string ( ) ,
336336 ) ) ;
337337 }
338- ( AggregateFunction :: ApproxQuantile , false ) => {
339- Arc :: new ( expressions:: ApproxQuantile :: new (
340- // Pass in the desired quantile expr
338+ ( AggregateFunction :: ApproxPercentileCont , false ) => {
339+ Arc :: new ( expressions:: ApproxPercentileCont :: new (
340+ // Pass in the desired percentile expr
341341 coerced_phy_exprs,
342342 name,
343343 return_type,
344344 ) ?)
345345 }
346- ( AggregateFunction :: ApproxQuantile , true ) => {
346+ ( AggregateFunction :: ApproxPercentileCont , true ) => {
347347 return Err ( DataFusionError :: NotImplemented (
348- "approx_quantile(DISTINCT) aggregations are not available" . to_string ( ) ,
348+ "approx_percentile_cont(DISTINCT) aggregations are not available"
349+ . to_string ( ) ,
349350 ) ) ;
350351 }
351352 } )
@@ -406,8 +407,8 @@ pub fn signature(fun: &AggregateFunction) -> Signature {
406407 AggregateFunction :: Correlation => {
407408 Signature :: uniform ( 2 , NUMERICS . to_vec ( ) , Volatility :: Immutable )
408409 }
409- AggregateFunction :: ApproxQuantile => Signature :: one_of (
410- // Accept any numeric value paired with a float64 quantile
410+ AggregateFunction :: ApproxPercentileCont => Signature :: one_of (
411+ // Accept any numeric value paired with a float64 percentile
411412 NUMERICS
412413 . iter ( )
413414 . map ( |t| TypeSignature :: Exact ( vec ! [ t. clone( ) , DataType :: Float64 ] ) )
@@ -421,8 +422,8 @@ pub fn signature(fun: &AggregateFunction) -> Signature {
421422mod tests {
422423 use super :: * ;
423424 use crate :: physical_plan:: expressions:: {
424- ApproxDistinct , ApproxQuantile , ArrayAgg , Avg , Correlation , Count , Covariance ,
425- DistinctArrayAgg , DistinctCount , Max , Min , Stddev , Sum , Variance ,
425+ ApproxDistinct , ApproxPercentileCont , ArrayAgg , Avg , Correlation , Count ,
426+ Covariance , DistinctArrayAgg , DistinctCount , Max , Min , Stddev , Sum , Variance ,
426427 } ;
427428 use crate :: { error:: Result , scalar:: ScalarValue } ;
428429
@@ -539,7 +540,7 @@ mod tests {
539540 }
540541
541542 #[ test]
542- fn test_agg_approx_quantile_phy_expr ( ) {
543+ fn test_agg_approx_percentile_phy_expr ( ) {
543544 for data_type in NUMERICS {
544545 let input_schema =
545546 Schema :: new ( vec ! [ Field :: new( "c1" , data_type. clone( ) , true ) ] ) ;
@@ -550,15 +551,15 @@ mod tests {
550551 Arc :: new( expressions:: Literal :: new( ScalarValue :: Float64 ( Some ( 0.2 ) ) ) ) ,
551552 ] ;
552553 let result_agg_phy_exprs = create_aggregate_expr (
553- & AggregateFunction :: ApproxQuantile ,
554+ & AggregateFunction :: ApproxPercentileCont ,
554555 false ,
555556 & input_phy_exprs[ ..] ,
556557 & input_schema,
557558 "c1" ,
558559 )
559560 . expect ( "failed to create aggregate expr" ) ;
560561
561- assert ! ( result_agg_phy_exprs. as_any( ) . is:: <ApproxQuantile >( ) ) ;
562+ assert ! ( result_agg_phy_exprs. as_any( ) . is:: <ApproxPercentileCont >( ) ) ;
562563 assert_eq ! ( "c1" , result_agg_phy_exprs. name( ) ) ;
563564 assert_eq ! (
564565 Field :: new( "c1" , data_type. clone( ) , false ) ,
@@ -568,7 +569,7 @@ mod tests {
568569 }
569570
570571 #[ test]
571- fn test_agg_approx_quantile_invalid_phy_expr ( ) {
572+ fn test_agg_approx_percentile_invalid_phy_expr ( ) {
572573 for data_type in NUMERICS {
573574 let input_schema =
574575 Schema :: new ( vec ! [ Field :: new( "c1" , data_type. clone( ) , true ) ] ) ;
@@ -579,13 +580,13 @@ mod tests {
579580 Arc :: new( expressions:: Literal :: new( ScalarValue :: Float64 ( Some ( 4.2 ) ) ) ) ,
580581 ] ;
581582 let err = create_aggregate_expr (
582- & AggregateFunction :: ApproxQuantile ,
583+ & AggregateFunction :: ApproxPercentileCont ,
583584 false ,
584585 & input_phy_exprs[ ..] ,
585586 & input_schema,
586587 "c1" ,
587588 )
588- . expect_err ( "should fail due to invalid quantile " ) ;
589+ . expect_err ( "should fail due to invalid percentile " ) ;
589590
590591 assert ! ( matches!( err, DataFusionError :: Plan ( _) ) ) ;
591592 }
0 commit comments