-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Improve error message for wrong built-in scalar function signatures. #6415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really nice @2010YOUY01 -- thank you so much. I have also noticed the hard to understand error messages and this looks like a great improvement ❤️
datafusion/expr/src/function_err.rs
Outdated
| fn join_types<T: std::fmt::Debug>(types: &[T], delimiter: &str) -> String { | ||
| types | ||
| .iter() | ||
| .map(|t| format!("{:?}", t)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we use the Display impl here to better follow the Rust convention of Display for users and Debug for developers.
| .map(|t| format!("{:?}", t)) | |
| .map(|t| t.to_string()) |
However, under the covers that simply calls the Debug impl 🤦 so it won't make any practical difference
https://docs.rs/arrow-schema/40.0.0/src/arrow_schema/datatype.rs.html#307
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Updated.
|
I'll plan to merge this tomorrow unless there are more comments or anyone wants more time to review |
jackwener
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense to me, thank you @2010YOUY01
| statement ok | ||
| drop table test | ||
|
|
||
| # error message for wrong function signature (Variadic: arbitrary number of args all from some common types) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
Thanks @jackwener |
Which issue does this PR close?
#6396
Rationale for this change
Currently, the error message for the built-in scalar function signature mismatch is not straightforward.
The error message before and after this change is shown below:
(There are 5 different function signature types(variadic, exact...) from internal implementation, 1 function is chosen from each type)
What changes are included in this PR?
function_err.rsto generate error messages by providing candidate function signatures if input function arguments are not valid.Are these changes tested?
There are 5 function signature types from internal implementation , remaining 2 of them are not used when defining built-in scalar functions.
1 of each signature type has an end-to-end sqllogictest for the error message.
Are there any user-facing changes?
No.