Jefffrey commented on PR #20070: URL: https://github.com/apache/datafusion/pull/20070#issuecomment-3847772204
Yeah I was initially thinking of trying to cleanup the existing errors, specifically cases where they are really ugly (coercion API, also if the signature is a `OneOf`). But after looking at DuckDB I decided to try this way to make it more generic. I can work towards keeping the existing specific error messages, but my main concern is how to deal with `OneOf` signature. For argument count errors (none of the `OneOf` signatures count of arguments match) I can fix the current logic to be something like `udf expects 1 to 4 arguments, got 5`. - e.g. `log` can take 1 or 2 arguments, so if we supply 3 we can form an error `log expects 1 to 2 arguments, got 3` However for cases where the input arguments match more than one of the `OneOf` signatures in count, I wonder how to neatly handle the error? For example, `log`: https://github.com/apache/datafusion/blob/796c7d1daea5acd65702eef2884bdac0daf83876/datafusion/functions/src/math/log.rs#L83-L100 - For the 2 argument case, it expects `[float, float]` or `[float, decimal]` If we supply `[string, string]`, how should we form the error? Currently we just append errors from each of the `OneOf` signatures which leads to a really ugly error: ```sql > select log(1, ''); Error during planning: Internal error: Function 'log' failed to match any signature, errors: Error during planning: Function 'log' expects 1 arguments but received 2,Error during planning: Function 'log' expects 1 arguments but received 2,Error during planning: Function 'log' requires TypeSignatureClass::Decimal, but received String (DataType: Utf8).,Error during planning: Function 'log' requires TypeSignatureClass::Float, but received String (DataType: Utf8).. This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues No function matches the given name and argument types 'log(Int64, Utf8)'. You might need to add explicit type casts. Candidate functions: log(Coercion(TypeSignatureClass::Decimal)) log(Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64)) log(Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64), Coercion(TypeSignatureClass::Decimal)) log(Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64), Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64)) ``` - Can try to fix the display + internal error reference, but how to handle the following: > Function 'log' requires TypeSignatureClass::Decimal, but received String (DataType: Utf8).,Error during planning: Function 'log' requires TypeSignatureClass::Float, but received String (DataType: Utf8). Maybe only for cases like this we erase the error message and only show candidate functions, like this PR does? -- 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]
