From aa9e800010e3a1ab51e58774d12de5f543e18946 Mon Sep 17 00:00:00 2001 From: jayzhan211 Date: Sat, 4 May 2024 09:32:14 +0800 Subject: [PATCH] rm builtin Signed-off-by: jayzhan211 --- datafusion/core/src/physical_planner.rs | 1 + datafusion/expr/src/aggregate_function.rs | 11 +- .../expr/src/type_coercion/aggregates.rs | 2 +- .../functions-aggregate/src/covariance.rs | 21 +-- datafusion/functions-aggregate/src/lib.rs | 2 +- .../physical-expr/src/aggregate/build_in.rs | 154 +--------------- .../physical-expr/src/aggregate/covariance.rs | 174 ------------------ .../physical-expr/src/expressions/mod.rs | 2 +- datafusion/proto/proto/datafusion.proto | 2 +- datafusion/proto/src/generated/pbjson.rs | 3 - datafusion/proto/src/generated/prost.rs | 4 +- .../proto/src/logical_plan/from_proto.rs | 1 - datafusion/proto/src/logical_plan/to_proto.rs | 4 - .../proto/src/physical_plan/to_proto.rs | 14 +- .../sqllogictest/test_files/functions.slt | 2 +- 15 files changed, 21 insertions(+), 376 deletions(-) diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs index 391ded84eab9..dfcda553af7d 100644 --- a/datafusion/core/src/physical_planner.rs +++ b/datafusion/core/src/physical_planner.rs @@ -1901,6 +1901,7 @@ pub fn create_aggregate_expr_with_name_and_maybe_filter( let ignore_nulls = null_treatment .unwrap_or(sqlparser::ast::NullTreatment::RespectNulls) == NullTreatment::IgnoreNulls; + let (agg_expr, filter, order_by) = match func_def { AggregateFunctionDefinition::BuiltIn(fun) => { let physical_sort_exprs = match order_by { diff --git a/datafusion/expr/src/aggregate_function.rs b/datafusion/expr/src/aggregate_function.rs index 3dc9c3a01c15..af8a682eff58 100644 --- a/datafusion/expr/src/aggregate_function.rs +++ b/datafusion/expr/src/aggregate_function.rs @@ -63,8 +63,6 @@ pub enum AggregateFunction { Stddev, /// Standard Deviation (Population) StddevPop, - /// Covariance (Sample) - Covariance, /// Covariance (Population) CovariancePop, /// Correlation @@ -128,7 +126,6 @@ impl AggregateFunction { VariancePop => "VAR_POP", Stddev => "STDDEV", StddevPop => "STDDEV_POP", - Covariance => "COVAR", CovariancePop => "COVAR_POP", Correlation => "CORR", RegrSlope => "REGR_SLOPE", @@ -184,9 +181,7 @@ impl FromStr for AggregateFunction { "string_agg" => AggregateFunction::StringAgg, // statistical "corr" => AggregateFunction::Correlation, - "covar" => AggregateFunction::Covariance, "covar_pop" => AggregateFunction::CovariancePop, - "covar_samp" => AggregateFunction::Covariance, "stddev" => AggregateFunction::Stddev, "stddev_pop" => AggregateFunction::StddevPop, "stddev_samp" => AggregateFunction::Stddev, @@ -260,9 +255,6 @@ impl AggregateFunction { AggregateFunction::VariancePop => { variance_return_type(&coerced_data_types[0]) } - AggregateFunction::Covariance => { - covariance_return_type(&coerced_data_types[0]) - } AggregateFunction::CovariancePop => { covariance_return_type(&coerced_data_types[0]) } @@ -357,8 +349,7 @@ impl AggregateFunction { Signature::uniform(1, NUMERICS.to_vec(), Volatility::Immutable) } AggregateFunction::NthValue => Signature::any(2, Volatility::Immutable), - AggregateFunction::Covariance - | AggregateFunction::CovariancePop + AggregateFunction::CovariancePop | AggregateFunction::Correlation | AggregateFunction::RegrSlope | AggregateFunction::RegrIntercept diff --git a/datafusion/expr/src/type_coercion/aggregates.rs b/datafusion/expr/src/type_coercion/aggregates.rs index 5ffdc8f94753..39726d7d0e62 100644 --- a/datafusion/expr/src/type_coercion/aggregates.rs +++ b/datafusion/expr/src/type_coercion/aggregates.rs @@ -183,7 +183,7 @@ pub fn coerce_types( } Ok(vec![Float64, Float64]) } - AggregateFunction::Covariance | AggregateFunction::CovariancePop => { + AggregateFunction::CovariancePop => { if !is_covariance_support_arg_type(&input_types[0]) { return plan_err!( "The function {:?} does not support inputs of type {:?}.", diff --git a/datafusion/functions-aggregate/src/covariance.rs b/datafusion/functions-aggregate/src/covariance.rs index 277641e2b2f1..dd8d1e664d44 100644 --- a/datafusion/functions-aggregate/src/covariance.rs +++ b/datafusion/functions-aggregate/src/covariance.rs @@ -30,7 +30,8 @@ use datafusion_common::{ ScalarValue, }; use datafusion_expr::{ - function::AccumulatorArgs, type_coercion::aggregates::NUMERICS, utils::format_state_name, Accumulator, AggregateUDFImpl, Signature, Volatility + function::AccumulatorArgs, type_coercion::aggregates::NUMERICS, + utils::format_state_name, Accumulator, AggregateUDFImpl, Signature, Volatility, }; use datafusion_physical_expr_common::aggregate::stats::StatsType; @@ -100,21 +101,9 @@ impl AggregateUDFImpl for CovarianceSample { _ordering_fields: Vec, ) -> Result> { Ok(vec![ - Field::new( - format_state_name(name, "count"), - DataType::UInt64, - true, - ), - Field::new( - format_state_name(name, "mean1"), - DataType::Float64, - true, - ), - Field::new( - format_state_name(name, "mean2"), - DataType::Float64, - true, - ), + Field::new(format_state_name(name, "count"), DataType::UInt64, true), + Field::new(format_state_name(name, "mean1"), DataType::Float64, true), + Field::new(format_state_name(name, "mean2"), DataType::Float64, true), Field::new( format_state_name(name, "algo_const"), DataType::Float64, diff --git a/datafusion/functions-aggregate/src/lib.rs b/datafusion/functions-aggregate/src/lib.rs index dd27f1943942..d4e4d3a5f328 100644 --- a/datafusion/functions-aggregate/src/lib.rs +++ b/datafusion/functions-aggregate/src/lib.rs @@ -66,8 +66,8 @@ use std::sync::Arc; /// Fluent-style API for creating `Expr`s pub mod expr_fn { - pub use super::first_last::first_value; pub use super::covariance::covar_samp; + pub use super::first_last::first_value; } /// Registers all enabled packages with a [`FunctionRegistry`] diff --git a/datafusion/physical-expr/src/aggregate/build_in.rs b/datafusion/physical-expr/src/aggregate/build_in.rs index 57ed35b0b761..36af875473be 100644 --- a/datafusion/physical-expr/src/aggregate/build_in.rs +++ b/datafusion/physical-expr/src/aggregate/build_in.rs @@ -181,15 +181,6 @@ pub fn create_aggregate_expr( (AggregateFunction::VariancePop, true) => { return not_impl_err!("VAR_POP(DISTINCT) aggregations are not available"); } - (AggregateFunction::Covariance, false) => Arc::new(expressions::Covariance::new( - input_phy_exprs[0].clone(), - input_phy_exprs[1].clone(), - name, - data_type, - )), - (AggregateFunction::Covariance, true) => { - return not_impl_err!("COVAR(DISTINCT) aggregations are not available"); - } (AggregateFunction::CovariancePop, false) => { Arc::new(expressions::CovariancePop::new( input_phy_exprs[0].clone(), @@ -428,8 +419,8 @@ mod tests { use crate::expressions::{ try_cast, ApproxDistinct, ApproxMedian, ApproxPercentileCont, ArrayAgg, Avg, - BitAnd, BitOr, BitXor, BoolAnd, BoolOr, Correlation, Count, Covariance, - DistinctArrayAgg, DistinctCount, Max, Min, Stddev, Sum, Variance, + BitAnd, BitOr, BitXor, BoolAnd, BoolOr, Count, DistinctArrayAgg, DistinctCount, + Max, Min, Stddev, Sum, Variance, }; use super::*; @@ -950,147 +941,6 @@ mod tests { Ok(()) } - #[test] - fn test_covar_expr() -> Result<()> { - let funcs = vec![AggregateFunction::Covariance]; - let data_types = vec![ - DataType::UInt32, - DataType::UInt64, - DataType::Int32, - DataType::Int64, - DataType::Float32, - DataType::Float64, - ]; - for fun in funcs { - for data_type in &data_types { - let input_schema = Schema::new(vec![ - Field::new("c1", data_type.clone(), true), - Field::new("c2", data_type.clone(), true), - ]); - let input_phy_exprs: Vec> = vec![ - Arc::new( - expressions::Column::new_with_schema("c1", &input_schema) - .unwrap(), - ), - Arc::new( - expressions::Column::new_with_schema("c2", &input_schema) - .unwrap(), - ), - ]; - let result_agg_phy_exprs = create_physical_agg_expr_for_test( - &fun, - false, - &input_phy_exprs[0..2], - &input_schema, - "c1", - )?; - if fun == AggregateFunction::Covariance { - assert!(result_agg_phy_exprs.as_any().is::()); - assert_eq!("c1", result_agg_phy_exprs.name()); - assert_eq!( - Field::new("c1", DataType::Float64, true), - result_agg_phy_exprs.field().unwrap() - ) - } - } - } - Ok(()) - } - - #[test] - fn test_covar_pop_expr() -> Result<()> { - let funcs = vec![AggregateFunction::CovariancePop]; - let data_types = vec![ - DataType::UInt32, - DataType::UInt64, - DataType::Int32, - DataType::Int64, - DataType::Float32, - DataType::Float64, - ]; - for fun in funcs { - for data_type in &data_types { - let input_schema = Schema::new(vec![ - Field::new("c1", data_type.clone(), true), - Field::new("c2", data_type.clone(), true), - ]); - let input_phy_exprs: Vec> = vec![ - Arc::new( - expressions::Column::new_with_schema("c1", &input_schema) - .unwrap(), - ), - Arc::new( - expressions::Column::new_with_schema("c2", &input_schema) - .unwrap(), - ), - ]; - let result_agg_phy_exprs = create_physical_agg_expr_for_test( - &fun, - false, - &input_phy_exprs[0..2], - &input_schema, - "c1", - )?; - if fun == AggregateFunction::Covariance { - assert!(result_agg_phy_exprs.as_any().is::()); - assert_eq!("c1", result_agg_phy_exprs.name()); - assert_eq!( - Field::new("c1", DataType::Float64, true), - result_agg_phy_exprs.field().unwrap() - ) - } - } - } - Ok(()) - } - - #[test] - fn test_corr_expr() -> Result<()> { - let funcs = vec![AggregateFunction::Correlation]; - let data_types = vec![ - DataType::UInt32, - DataType::UInt64, - DataType::Int32, - DataType::Int64, - DataType::Float32, - DataType::Float64, - ]; - for fun in funcs { - for data_type in &data_types { - let input_schema = Schema::new(vec![ - Field::new("c1", data_type.clone(), true), - Field::new("c2", data_type.clone(), true), - ]); - let input_phy_exprs: Vec> = vec![ - Arc::new( - expressions::Column::new_with_schema("c1", &input_schema) - .unwrap(), - ), - Arc::new( - expressions::Column::new_with_schema("c2", &input_schema) - .unwrap(), - ), - ]; - let result_agg_phy_exprs = create_physical_agg_expr_for_test( - &fun, - false, - &input_phy_exprs[0..2], - &input_schema, - "c1", - )?; - if fun == AggregateFunction::Covariance { - assert!(result_agg_phy_exprs.as_any().is::()); - assert_eq!("c1", result_agg_phy_exprs.name()); - assert_eq!( - Field::new("c1", DataType::Float64, true), - result_agg_phy_exprs.field().unwrap() - ) - } - } - } - Ok(()) - } - #[test] fn test_median_expr() -> Result<()> { let funcs = vec![AggregateFunction::ApproxMedian]; diff --git a/datafusion/physical-expr/src/aggregate/covariance.rs b/datafusion/physical-expr/src/aggregate/covariance.rs index ba9bdbc8aee3..272f1d8be2b5 100644 --- a/datafusion/physical-expr/src/aggregate/covariance.rs +++ b/datafusion/physical-expr/src/aggregate/covariance.rs @@ -36,14 +36,6 @@ use crate::aggregate::stats::StatsType; use crate::aggregate::utils::down_cast_any_ref; use crate::expressions::format_state_name; -/// COVAR and COVAR_SAMP aggregate expression -#[derive(Debug)] -pub struct Covariance { - name: String, - expr1: Arc, - expr2: Arc, -} - /// COVAR_POP aggregate expression #[derive(Debug)] pub struct CovariancePop { @@ -52,83 +44,6 @@ pub struct CovariancePop { expr2: Arc, } -impl Covariance { - /// Create a new COVAR aggregate function - pub fn new( - expr1: Arc, - expr2: Arc, - name: impl Into, - data_type: DataType, - ) -> Self { - // the result of covariance just support FLOAT64 data type. - assert!(matches!(data_type, DataType::Float64)); - Self { - name: name.into(), - expr1, - expr2, - } - } -} - -impl AggregateExpr for Covariance { - /// Return a reference to Any that can be used for downcasting - fn as_any(&self) -> &dyn Any { - self - } - - fn field(&self) -> Result { - Ok(Field::new(&self.name, DataType::Float64, true)) - } - - fn create_accumulator(&self) -> Result> { - Ok(Box::new(CovarianceAccumulator::try_new(StatsType::Sample)?)) - } - - fn state_fields(&self) -> Result> { - Ok(vec![ - Field::new( - format_state_name(&self.name, "count"), - DataType::UInt64, - true, - ), - Field::new( - format_state_name(&self.name, "mean1"), - DataType::Float64, - true, - ), - Field::new( - format_state_name(&self.name, "mean2"), - DataType::Float64, - true, - ), - Field::new( - format_state_name(&self.name, "algo_const"), - DataType::Float64, - true, - ), - ]) - } - - fn expressions(&self) -> Vec> { - vec![self.expr1.clone(), self.expr2.clone()] - } - - fn name(&self) -> &str { - &self.name - } -} - -impl PartialEq for Covariance { - fn eq(&self, other: &dyn Any) -> bool { - down_cast_any_ref(other) - .downcast_ref::() - .map(|x| { - self.name == x.name && self.expr1.eq(&x.expr1) && self.expr2.eq(&x.expr2) - }) - .unwrap_or(false) - } -} - impl CovariancePop { /// Create a new COVAR_POP aggregate function pub fn new( @@ -429,36 +344,6 @@ mod tests { ) } - #[test] - fn covariance_f64_2() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from(vec![1_f64, 2_f64, 3_f64])); - let b: ArrayRef = Arc::new(Float64Array::from(vec![4_f64, 5_f64, 6_f64])); - - generic_test_op2!( - a, - b, - DataType::Float64, - DataType::Float64, - Covariance, - ScalarValue::from(1_f64) - ) - } - - #[test] - fn covariance_f64_4() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from(vec![1.1_f64, 2_f64, 3_f64])); - let b: ArrayRef = Arc::new(Float64Array::from(vec![4.1_f64, 5_f64, 6_f64])); - - generic_test_op2!( - a, - b, - DataType::Float64, - DataType::Float64, - Covariance, - ScalarValue::from(0.9033333333333335_f64) - ) - } - #[test] fn covariance_f64_5() -> Result<()> { let a: ArrayRef = Arc::new(Float64Array::from(vec![1.1_f64, 2_f64, 3_f64])); @@ -580,50 +465,6 @@ mod tests { ) } - #[test] - fn covariance_i32_with_nulls_3() -> Result<()> { - let a: ArrayRef = Arc::new(Int32Array::from(vec![ - Some(1), - None, - Some(2), - None, - Some(3), - None, - ])); - let b: ArrayRef = Arc::new(Int32Array::from(vec![ - Some(4), - Some(9), - Some(5), - Some(8), - Some(6), - None, - ])); - - generic_test_op2!( - a, - b, - DataType::Int32, - DataType::Int32, - Covariance, - ScalarValue::from(1_f64) - ) - } - - #[test] - fn covariance_i32_all_nulls() -> Result<()> { - let a: ArrayRef = Arc::new(Int32Array::from(vec![None, None])); - let b: ArrayRef = Arc::new(Int32Array::from(vec![None, None])); - - generic_test_op2!( - a, - b, - DataType::Int32, - DataType::Int32, - Covariance, - ScalarValue::Float64(None) - ) - } - #[test] fn covariance_pop_i32_all_nulls() -> Result<()> { let a: ArrayRef = Arc::new(Int32Array::from(vec![None, None])); @@ -639,21 +480,6 @@ mod tests { ) } - #[test] - fn covariance_1_input() -> Result<()> { - let a: ArrayRef = Arc::new(Float64Array::from(vec![1_f64])); - let b: ArrayRef = Arc::new(Float64Array::from(vec![2_f64])); - - generic_test_op2!( - a, - b, - DataType::Float64, - DataType::Float64, - Covariance, - ScalarValue::Float64(None) - ) - } - #[test] fn covariance_pop_1_input() -> Result<()> { let a: ArrayRef = Arc::new(Float64Array::from(vec![1_f64])); diff --git a/datafusion/physical-expr/src/expressions/mod.rs b/datafusion/physical-expr/src/expressions/mod.rs index 55ebd9ed8c44..0cd2ac2c9e42 100644 --- a/datafusion/physical-expr/src/expressions/mod.rs +++ b/datafusion/physical-expr/src/expressions/mod.rs @@ -52,7 +52,7 @@ pub use crate::aggregate::build_in::create_aggregate_expr; pub use crate::aggregate::correlation::Correlation; pub use crate::aggregate::count::Count; pub use crate::aggregate::count_distinct::DistinctCount; -pub use crate::aggregate::covariance::{Covariance, CovariancePop}; +pub use crate::aggregate::covariance::CovariancePop; pub use crate::aggregate::grouping::Grouping; pub use crate::aggregate::median::Median; pub use crate::aggregate::min_max::{Max, Min}; diff --git a/datafusion/proto/proto/datafusion.proto b/datafusion/proto/proto/datafusion.proto index 9e4ea8e712ed..c057ab8acda7 100644 --- a/datafusion/proto/proto/datafusion.proto +++ b/datafusion/proto/proto/datafusion.proto @@ -548,7 +548,7 @@ enum AggregateFunction { ARRAY_AGG = 6; VARIANCE = 7; VARIANCE_POP = 8; - COVARIANCE = 9; + // COVARIANCE = 9; COVARIANCE_POP = 10; STDDEV = 11; STDDEV_POP = 12; diff --git a/datafusion/proto/src/generated/pbjson.rs b/datafusion/proto/src/generated/pbjson.rs index b5779d25c6e2..994703c5fcfb 100644 --- a/datafusion/proto/src/generated/pbjson.rs +++ b/datafusion/proto/src/generated/pbjson.rs @@ -430,7 +430,6 @@ impl serde::Serialize for AggregateFunction { Self::ArrayAgg => "ARRAY_AGG", Self::Variance => "VARIANCE", Self::VariancePop => "VARIANCE_POP", - Self::Covariance => "COVARIANCE", Self::CovariancePop => "COVARIANCE_POP", Self::Stddev => "STDDEV", Self::StddevPop => "STDDEV_POP", @@ -478,7 +477,6 @@ impl<'de> serde::Deserialize<'de> for AggregateFunction { "ARRAY_AGG", "VARIANCE", "VARIANCE_POP", - "COVARIANCE", "COVARIANCE_POP", "STDDEV", "STDDEV_POP", @@ -555,7 +553,6 @@ impl<'de> serde::Deserialize<'de> for AggregateFunction { "ARRAY_AGG" => Ok(AggregateFunction::ArrayAgg), "VARIANCE" => Ok(AggregateFunction::Variance), "VARIANCE_POP" => Ok(AggregateFunction::VariancePop), - "COVARIANCE" => Ok(AggregateFunction::Covariance), "COVARIANCE_POP" => Ok(AggregateFunction::CovariancePop), "STDDEV" => Ok(AggregateFunction::Stddev), "STDDEV_POP" => Ok(AggregateFunction::StddevPop), diff --git a/datafusion/proto/src/generated/prost.rs b/datafusion/proto/src/generated/prost.rs index c822ac13013c..fc23a9ea05f7 100644 --- a/datafusion/proto/src/generated/prost.rs +++ b/datafusion/proto/src/generated/prost.rs @@ -2834,7 +2834,7 @@ pub enum AggregateFunction { ArrayAgg = 6, Variance = 7, VariancePop = 8, - Covariance = 9, + /// COVARIANCE = 9; CovariancePop = 10, Stddev = 11, StddevPop = 12, @@ -2881,7 +2881,6 @@ impl AggregateFunction { AggregateFunction::ArrayAgg => "ARRAY_AGG", AggregateFunction::Variance => "VARIANCE", AggregateFunction::VariancePop => "VARIANCE_POP", - AggregateFunction::Covariance => "COVARIANCE", AggregateFunction::CovariancePop => "COVARIANCE_POP", AggregateFunction::Stddev => "STDDEV", AggregateFunction::StddevPop => "STDDEV_POP", @@ -2925,7 +2924,6 @@ impl AggregateFunction { "ARRAY_AGG" => Some(Self::ArrayAgg), "VARIANCE" => Some(Self::Variance), "VARIANCE_POP" => Some(Self::VariancePop), - "COVARIANCE" => Some(Self::Covariance), "COVARIANCE_POP" => Some(Self::CovariancePop), "STDDEV" => Some(Self::Stddev), "STDDEV_POP" => Some(Self::StddevPop), diff --git a/datafusion/proto/src/logical_plan/from_proto.rs b/datafusion/proto/src/logical_plan/from_proto.rs index 83b232da9d21..35d4c6409bc1 100644 --- a/datafusion/proto/src/logical_plan/from_proto.rs +++ b/datafusion/proto/src/logical_plan/from_proto.rs @@ -428,7 +428,6 @@ impl From for AggregateFunction { protobuf::AggregateFunction::ArrayAgg => Self::ArrayAgg, protobuf::AggregateFunction::Variance => Self::Variance, protobuf::AggregateFunction::VariancePop => Self::VariancePop, - protobuf::AggregateFunction::Covariance => Self::Covariance, protobuf::AggregateFunction::CovariancePop => Self::CovariancePop, protobuf::AggregateFunction::Stddev => Self::Stddev, protobuf::AggregateFunction::StddevPop => Self::StddevPop, diff --git a/datafusion/proto/src/logical_plan/to_proto.rs b/datafusion/proto/src/logical_plan/to_proto.rs index b2236847ace8..dcec2a3b8595 100644 --- a/datafusion/proto/src/logical_plan/to_proto.rs +++ b/datafusion/proto/src/logical_plan/to_proto.rs @@ -369,7 +369,6 @@ impl From<&AggregateFunction> for protobuf::AggregateFunction { AggregateFunction::ArrayAgg => Self::ArrayAgg, AggregateFunction::Variance => Self::Variance, AggregateFunction::VariancePop => Self::VariancePop, - AggregateFunction::Covariance => Self::Covariance, AggregateFunction::CovariancePop => Self::CovariancePop, AggregateFunction::Stddev => Self::Stddev, AggregateFunction::StddevPop => Self::StddevPop, @@ -674,9 +673,6 @@ pub fn serialize_expr( AggregateFunction::VariancePop => { protobuf::AggregateFunction::VariancePop } - AggregateFunction::Covariance => { - protobuf::AggregateFunction::Covariance - } AggregateFunction::CovariancePop => { protobuf::AggregateFunction::CovariancePop } diff --git a/datafusion/proto/src/physical_plan/to_proto.rs b/datafusion/proto/src/physical_plan/to_proto.rs index c7df6ebf5828..a0a0ee72054b 100644 --- a/datafusion/proto/src/physical_plan/to_proto.rs +++ b/datafusion/proto/src/physical_plan/to_proto.rs @@ -25,12 +25,12 @@ use datafusion::physical_expr::{PhysicalSortExpr, ScalarFunctionExpr}; use datafusion::physical_plan::expressions::{ ApproxDistinct, ApproxMedian, ApproxPercentileCont, ApproxPercentileContWithWeight, ArrayAgg, Avg, BinaryExpr, BitAnd, BitOr, BitXor, BoolAnd, BoolOr, CaseExpr, - CastExpr, Column, Correlation, Count, Covariance, CovariancePop, CumeDist, - DistinctArrayAgg, DistinctBitXor, DistinctCount, DistinctSum, FirstValue, Grouping, - InListExpr, IsNotNullExpr, IsNullExpr, LastValue, Literal, Max, Median, Min, - NegativeExpr, NotExpr, NthValue, NthValueAgg, Ntile, OrderSensitiveArrayAgg, Rank, - RankType, Regr, RegrType, RowNumber, Stddev, StddevPop, StringAgg, Sum, TryCastExpr, - Variance, VariancePop, WindowShift, + CastExpr, Column, Correlation, Count, CovariancePop, CumeDist, DistinctArrayAgg, + DistinctBitXor, DistinctCount, DistinctSum, FirstValue, Grouping, InListExpr, + IsNotNullExpr, IsNullExpr, LastValue, Literal, Max, Median, Min, NegativeExpr, + NotExpr, NthValue, NthValueAgg, Ntile, OrderSensitiveArrayAgg, Rank, RankType, Regr, + RegrType, RowNumber, Stddev, StddevPop, StringAgg, Sum, TryCastExpr, Variance, + VariancePop, WindowShift, }; use datafusion::physical_plan::udaf::AggregateFunctionExpr; use datafusion::physical_plan::windows::{BuiltInWindowExpr, PlainAggregateWindowExpr}; @@ -292,8 +292,6 @@ fn aggr_expr_to_aggr_fn(expr: &dyn AggregateExpr) -> Result { protobuf::AggregateFunction::Variance } else if aggr_expr.downcast_ref::().is_some() { protobuf::AggregateFunction::VariancePop - } else if aggr_expr.downcast_ref::().is_some() { - protobuf::AggregateFunction::Covariance } else if aggr_expr.downcast_ref::().is_some() { protobuf::AggregateFunction::CovariancePop } else if aggr_expr.downcast_ref::().is_some() { diff --git a/datafusion/sqllogictest/test_files/functions.slt b/datafusion/sqllogictest/test_files/functions.slt index bc8f6a268703..d03b33d0c8e5 100644 --- a/datafusion/sqllogictest/test_files/functions.slt +++ b/datafusion/sqllogictest/test_files/functions.slt @@ -495,7 +495,7 @@ statement error Did you mean 'STDDEV'? SELECT STDEV(v1) from test; # Aggregate function -statement error Did you mean 'COVAR'? +statement error DataFusion error: Error during planning: Invalid function 'covaria'.\nDid you mean 'covar'? SELECT COVARIA(1,1); # Window function