@@ -93,7 +93,7 @@ pub fn coerce_types(
93
93
) -> Result < Vec < DataType > > {
94
94
use DataType :: * ;
95
95
// Validate input_types matches (at least one of) the func signature.
96
- check_arg_count ( agg_fun, input_types, & signature. type_signature ) ?;
96
+ check_arg_count ( agg_fun. name ( ) , input_types, & signature. type_signature ) ?;
97
97
98
98
match agg_fun {
99
99
AggregateFunction :: Count | AggregateFunction :: ApproxDistinct => {
@@ -323,17 +323,16 @@ pub fn coerce_types(
323
323
/// This method DOES NOT validate the argument types - only that (at least one,
324
324
/// in the case of [`TypeSignature::OneOf`]) signature matches the desired
325
325
/// number of input types.
326
- fn check_arg_count (
327
- agg_fun : & AggregateFunction ,
326
+ pub fn check_arg_count (
327
+ func_name : & str ,
328
328
input_types : & [ DataType ] ,
329
329
signature : & TypeSignature ,
330
330
) -> Result < ( ) > {
331
331
match signature {
332
332
TypeSignature :: Uniform ( agg_count, _) | TypeSignature :: Any ( agg_count) => {
333
333
if input_types. len ( ) != * agg_count {
334
334
return plan_err ! (
335
- "The function {:?} expects {:?} arguments, but {:?} were provided" ,
336
- agg_fun,
335
+ "The function {func_name} expects {:?} arguments, but {:?} were provided" ,
337
336
agg_count,
338
337
input_types. len( )
339
338
) ;
@@ -342,8 +341,7 @@ fn check_arg_count(
342
341
TypeSignature :: Exact ( types) => {
343
342
if types. len ( ) != input_types. len ( ) {
344
343
return plan_err ! (
345
- "The function {:?} expects {:?} arguments, but {:?} were provided" ,
346
- agg_fun,
344
+ "The function {func_name} expects {:?} arguments, but {:?} were provided" ,
347
345
types. len( ) ,
348
346
input_types. len( )
349
347
) ;
@@ -352,19 +350,18 @@ fn check_arg_count(
352
350
TypeSignature :: OneOf ( variants) => {
353
351
let ok = variants
354
352
. iter ( )
355
- . any ( |v| check_arg_count ( agg_fun , input_types, v) . is_ok ( ) ) ;
353
+ . any ( |v| check_arg_count ( func_name , input_types, v) . is_ok ( ) ) ;
356
354
if !ok {
357
355
return plan_err ! (
358
- "The function {:?} does not accept {:?} function arguments." ,
359
- agg_fun,
356
+ "The function {func_name} does not accept {:?} function arguments." ,
360
357
input_types. len( )
361
358
) ;
362
359
}
363
360
}
364
361
TypeSignature :: VariadicAny => {
365
362
if input_types. is_empty ( ) {
366
363
return plan_err ! (
367
- "The function {agg_fun:? } expects at least one argument"
364
+ "The function {func_name } expects at least one argument"
368
365
) ;
369
366
}
370
367
}
@@ -594,7 +591,7 @@ mod tests {
594
591
let input_types = vec ! [ DataType :: Int64 , DataType :: Int32 ] ;
595
592
let signature = fun. signature ( ) ;
596
593
let result = coerce_types ( & fun, & input_types, & signature) ;
597
- assert_eq ! ( "Error during planning: The function Min expects 1 arguments, but 2 were provided" , result. unwrap_err( ) . strip_backtrace( ) ) ;
594
+ assert_eq ! ( "Error during planning: The function MIN expects 1 arguments, but 2 were provided" , result. unwrap_err( ) . strip_backtrace( ) ) ;
598
595
599
596
// test input args is invalid data type for sum or avg
600
597
let fun = AggregateFunction :: Sum ;
0 commit comments