This is an automated email from the ASF dual-hosted git repository.
jonah pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 268df42a60 fix: incorrect error message of function_length_check
(#14056)
268df42a60 is described below
commit 268df42a600e85ab80c6934d4ffb54062649dac2
Author: niebayes <[email protected]>
AuthorDate: Fri Jan 10 17:14:16 2025 +0800
fix: incorrect error message of function_length_check (#14056)
* minor fix
* add ut
* remove check for 0 arg
---
datafusion/expr/src/type_coercion/functions.rs | 33 +++++++++++++++++++-------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/datafusion/expr/src/type_coercion/functions.rs
b/datafusion/expr/src/type_coercion/functions.rs
index 96bb5c4b2d..5294cc526d 100644
--- a/datafusion/expr/src/type_coercion/functions.rs
+++ b/datafusion/expr/src/type_coercion/functions.rs
@@ -438,18 +438,11 @@ fn get_valid_types(
}
fn function_length_check(length: usize, expected_length: usize) ->
Result<()> {
- if length < 1 {
- return plan_err!(
- "The signature expected at least one argument but received
{expected_length}"
- );
- }
-
if length != expected_length {
return plan_err!(
- "The signature expected {length} arguments but received
{expected_length}"
+ "The signature expected {expected_length} arguments but
received {length}"
);
}
-
Ok(())
}
@@ -939,6 +932,7 @@ mod tests {
use super::*;
use arrow::datatypes::Field;
+ use datafusion_common::assert_contains;
#[test]
fn test_string_conversion() {
@@ -1027,6 +1021,29 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_get_valid_types_length_check() -> Result<()> {
+ let signature = TypeSignature::Numeric(1);
+
+ let err = get_valid_types(&signature, &[]).unwrap_err();
+ assert_contains!(
+ err.to_string(),
+ "The signature expected 1 arguments but received 0"
+ );
+
+ let err = get_valid_types(
+ &signature,
+ &[DataType::Int32, DataType::Int32, DataType::Int32],
+ )
+ .unwrap_err();
+ assert_contains!(
+ err.to_string(),
+ "The signature expected 1 arguments but received 3"
+ );
+
+ Ok(())
+ }
+
#[test]
fn test_fixed_list_wildcard_coerce() -> Result<()> {
let inner = Arc::new(Field::new_list_field(DataType::Int32, false));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]