@@ -26,7 +26,9 @@ use std::vec;
2626
2727use arrow:: datatypes:: { DataType , Field , FieldRef } ;
2828
29- use datafusion_common:: { Result , ScalarValue , Statistics , exec_err, not_impl_err} ;
29+ use datafusion_common:: {
30+ DataFusionError , Result , ScalarValue , Statistics , exec_err, not_impl_err,
31+ } ;
3032use datafusion_expr_common:: dyn_eq:: { DynEq , DynHash } ;
3133use datafusion_expr_common:: operator:: Operator ;
3234use datafusion_physical_expr_common:: physical_expr:: PhysicalExpr ;
@@ -272,6 +274,16 @@ impl AggregateUDF {
272274 self . inner . coerce_types ( arg_types)
273275 }
274276
277+ /// Returns a function-specific signature failure for argument combinations
278+ /// that are better described semantically than by generic signature
279+ /// diagnostics.
280+ pub fn diagnose_failed_signature (
281+ & self ,
282+ arg_types : & [ DataType ] ,
283+ ) -> Option < DataFusionError > {
284+ self . inner . diagnose_failed_signature ( arg_types)
285+ }
286+
275287 /// See [`AggregateUDFImpl::with_beneficial_ordering`] for more details.
276288 pub fn with_beneficial_ordering (
277289 self ,
@@ -799,6 +811,16 @@ pub trait AggregateUDFImpl: Debug + DynEq + DynHash + Send + Sync + Any {
799811 not_impl_err ! ( "Function {} does not implement coerce_types" , self . name( ) )
800812 }
801813
814+ /// Returns a semantic signature failure for argument combinations that
815+ /// should be surfaced directly instead of going through generic `OneOf`
816+ /// diagnostics.
817+ fn diagnose_failed_signature (
818+ & self ,
819+ _arg_types : & [ DataType ] ,
820+ ) -> Option < DataFusionError > {
821+ None
822+ }
823+
802824 /// If this function is max, return true
803825 /// If the function is min, return false
804826 /// Otherwise return None (the default)
@@ -1339,6 +1361,13 @@ impl AggregateUDFImpl for AliasedAggregateUDFImpl {
13391361 self . inner . coerce_types ( arg_types)
13401362 }
13411363
1364+ fn diagnose_failed_signature (
1365+ & self ,
1366+ arg_types : & [ DataType ] ,
1367+ ) -> Option < DataFusionError > {
1368+ self . inner . diagnose_failed_signature ( arg_types)
1369+ }
1370+
13421371 fn return_field ( & self , arg_fields : & [ FieldRef ] ) -> Result < FieldRef > {
13431372 self . inner . return_field ( arg_fields)
13441373 }
0 commit comments