2010YOUY01 opened a new issue, #11250:
URL: https://github.com/apache/datafusion/issues/11250

   ### Is your feature request related to a problem or challenge?
   
   When input arguments of unsupported type, scalar functions will return 
user-friendly error message:
   ```
   > select abs(1,2,3);
   Error during planning: Error during planning: The function expected 1 
arguments but received 3 No function matches the given name and argument types 
'abs(Int64, Int64, Int64)'. You might need to add explicit type casts.
           Candidate functions:
           abs(Any)
   > select round(3.14, 2.5);
   Error during planning: Error during planning: Coercion from [Float64, 
Float64] to the signature OneOf([Exact([Float64, Int64]), Exact([Float32, 
Int64]), Exact([Float64]), Exact([Float32])]) failed. No function matches the 
given name and argument types 'round(Float64, Float64)'. You might need to add 
explicit type casts.
           Candidate functions:
           round(Float64, Int64)
           round(Float32, Int64)
           round(Float64)
           round(Float32)
   ```
   
   But operators don't support it: but operators' behaviour is similar to 
scalar function, they both take several input argument, and return some value, 
maybe it's possible to also support better error message for 
[operators](https://datafusion.apache.org/user-guide/sql/operators.html)
   ```
   > select NOT 1.5;
   type_coercion
   caused by
   Error during planning: Cannot infer common argument type for comparison 
operation Float64 IS DISTINCT FROM Boolean
   > select 2.0 << 3.5;
   Internal error: Data type Float64 not supported for binary operation 
'bitwise_shift_left' on dyn arrays.
   This was likely caused by a bug in DataFusion's code and we would welcome 
that you file an bug report in our issue tracker
   ```
   `DuckDB` seems to (partly..) unify their implementation, and the error 
message is very informative
   ```
   duckdb> select  2.0 << 3.5;
   Binder Error: No function matches the given name and argument types 
'<<(DECIMAL(2,1), DECIMAL(2,1))'. You might need to add explicit type casts.
           Candidate functions:
           <<(TINYINT, TINYINT) -> TINYINT
           <<(SMALLINT, SMALLINT) -> SMALLINT
           <<(INTEGER, INTEGER) -> INTEGER
           <<(BIGINT, BIGINT) -> BIGINT
           <<(HUGEINT, HUGEINT) -> HUGEINT
           <<(UTINYINT, UTINYINT) -> UTINYINT
           <<(USMALLINT, USMALLINT) -> USMALLINT
           <<(UINTEGER, UINTEGER) -> UINTEGER
           <<(UBIGINT, UBIGINT) -> UBIGINT
           <<(UHUGEINT, UHUGEINT) -> UHUGEINT
           <<(BIT, INTEGER) -> BIT
   
   LINE 1: select  2.0 << 3.5;
   ```
   
   A reference implementation for functions' error message: 
https://github.com/apache/datafusion/issues/6396
   
   ### Describe the solution you'd like
   
   _No response_
   
   ### Describe alternatives you've considered
   
   _No response_
   
   ### 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to