@@ -438,18 +438,11 @@ fn get_valid_types(
438
438
}
439
439
440
440
fn function_length_check ( length : usize , expected_length : usize ) -> Result < ( ) > {
441
- if length < 1 {
442
- return plan_err ! (
443
- "The signature expected at least one argument but received {expected_length}"
444
- ) ;
445
- }
446
-
447
441
if length != expected_length {
448
442
return plan_err ! (
449
- "The signature expected {length } arguments but received {expected_length }"
443
+ "The signature expected {expected_length } arguments but received {length }"
450
444
) ;
451
445
}
452
-
453
446
Ok ( ( ) )
454
447
}
455
448
@@ -939,6 +932,7 @@ mod tests {
939
932
940
933
use super :: * ;
941
934
use arrow:: datatypes:: Field ;
935
+ use datafusion_common:: assert_contains;
942
936
943
937
#[ test]
944
938
fn test_string_conversion ( ) {
@@ -1027,6 +1021,29 @@ mod tests {
1027
1021
Ok ( ( ) )
1028
1022
}
1029
1023
1024
+ #[ test]
1025
+ fn test_get_valid_types_length_check ( ) -> Result < ( ) > {
1026
+ let signature = TypeSignature :: Numeric ( 1 ) ;
1027
+
1028
+ let err = get_valid_types ( & signature, & [ ] ) . unwrap_err ( ) ;
1029
+ assert_contains ! (
1030
+ err. to_string( ) ,
1031
+ "The signature expected 1 arguments but received 0"
1032
+ ) ;
1033
+
1034
+ let err = get_valid_types (
1035
+ & signature,
1036
+ & [ DataType :: Int32 , DataType :: Int32 , DataType :: Int32 ] ,
1037
+ )
1038
+ . unwrap_err ( ) ;
1039
+ assert_contains ! (
1040
+ err. to_string( ) ,
1041
+ "The signature expected 1 arguments but received 3"
1042
+ ) ;
1043
+
1044
+ Ok ( ( ) )
1045
+ }
1046
+
1030
1047
#[ test]
1031
1048
fn test_fixed_list_wildcard_coerce ( ) -> Result < ( ) > {
1032
1049
let inner = Arc :: new ( Field :: new_list_field ( DataType :: Int32 , false ) ) ;
0 commit comments