niebayes opened a new issue, #14059:
URL: https://github.com/apache/datafusion/issues/14059

   ### Describe the bug
   
   When given the type signature `TypeSignature::Numeric`, the 
`get_valid_types` function fails to check if the first data type is numeric. S
   pecifically, the function works correctly when the type signature is 
`TypeSignature::Numeric(n)` with n > 1. However, it behaves incorrectly when `n 
= 1`. 
   This is because the function first attempts to coerce data types into a 
numeric type. Such coercion is only performed when the number of arguments is 
greater than 1, but it does not check if the single data type is numeric when 
there's only one argument.
   
   ### To Reproduce
   
   You can write a simple unit test to reproduce the error:
   
   ```rust
       #[test]
       fn test_get_valid_types_numeric() -> Result<()> {
           let signature = TypeSignature::Numeric(1);
   
           // Returns ok while it's expected to return err.
           let got = get_valid_types(&signature, &[DataType::Binary]);
           assert!(got.is_ok());
   
           Ok(())
       }
   ```
   
   ### Expected behavior
   
   The `get_valid_types` functions rejects non-numeric arguments when given 
`TypeSignature::Numeric(1)`.
   
   ### Additional context
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to