@@ -24,6 +24,7 @@ use datafusion_common::{
2424 config:: ConfigOptions , file_options:: file_type:: FileType , not_impl_err, DFSchema ,
2525 Result , TableReference ,
2626} ;
27+ use sqlparser:: ast:: NullTreatment ;
2728
2829use crate :: { AggregateUDF , Expr , GetFieldAccess , ScalarUDF , TableSource , WindowUDF } ;
2930
@@ -107,7 +108,7 @@ pub trait UserDefinedSQLPlanner: Send + Sync {
107108
108109 /// Plan the array literal, returns OriginalArray if not possible
109110 ///
110- /// Returns origin expression arguments if not possible
111+ /// Returns original expression arguments if not possible
111112 fn plan_array_literal (
112113 & self ,
113114 exprs : Vec < Expr > ,
@@ -124,7 +125,7 @@ pub trait UserDefinedSQLPlanner: Send + Sync {
124125
125126 /// Plan the dictionary literal `{ key: value, ...}`
126127 ///
127- /// Returns origin expression arguments if not possible
128+ /// Returns original expression arguments if not possible
128129 fn plan_dictionary_literal (
129130 & self ,
130131 expr : RawDictionaryExpr ,
@@ -135,10 +136,20 @@ pub trait UserDefinedSQLPlanner: Send + Sync {
135136
136137 /// Plan an extract expression, e.g., `EXTRACT(month FROM foo)`
137138 ///
138- /// Returns origin expression arguments if not possible
139+ /// Returns original expression arguments if not possible
139140 fn plan_extract ( & self , args : Vec < Expr > ) -> Result < PlannerResult < Vec < Expr > > > {
140141 Ok ( PlannerResult :: Original ( args) )
141142 }
143+
144+ /// Plan an aggregate function, e.g., `SUM(foo)`
145+ ///
146+ /// Returns original expression arguments if not possible
147+ fn plan_aggregate_function (
148+ & self ,
149+ aggregate_function : RawAggregateFunction ,
150+ ) -> Result < PlannerResult < RawAggregateFunction > > {
151+ Ok ( PlannerResult :: Original ( aggregate_function) )
152+ }
142153}
143154
144155/// An operator with two arguments to plan
@@ -183,3 +194,14 @@ pub enum PlannerResult<T> {
183194 /// The raw expression could not be planned, and is returned unmodified
184195 Original ( T ) ,
185196}
197+
198+ // An aggregate function to plan.
199+ #[ derive( Debug , Clone ) ]
200+ pub struct RawAggregateFunction {
201+ pub udf : Arc < crate :: AggregateUDF > ,
202+ pub args : Vec < Expr > ,
203+ pub distinct : bool ,
204+ pub filter : Option < Box < Expr > > ,
205+ pub order_by : Option < Vec < Expr > > ,
206+ pub null_treatment : Option < NullTreatment > ,
207+ }
0 commit comments