Attach `Diagnostic` to "invalid function argument types" error
Is your feature request related to a problem or challenge?
For a query like:
SELECT sum('a')
The only message that the end user of an application built atop of DataFusion sees is:
Error during planning: Execution error: User-defined coercion failed with Execution("Sum not supported for Utf8") No function matches the given name and argument types 'sum(Utf8)'. You might need to add explicit type casts.
Candidate functions:
sum(UserDefined)
We want to provide a richer message that references and highlights locations in the original SQL query, and contextualises and helps the user understand the error. In the end, it would be possible to display errors in a fashion akin to what was enabled by #13664 for some errors:
See #14429 for more information.
Describe the solution you'd like
Attach a well crafted Diagnostic to the DataFusionError, building on top of the foundations laid in #13664. See #14429 for more information.
Describe alternatives you've considered
No response
Additional context
No response
Hi I'm interested in this ticket. Could you please assign it to me?
If you think my progress slow, feel free to ping me any time, I will try to prioritize and expedite. Thank you!
@dentiny Absolutely! Though I don't have the permissions to assign it to you, you can write take and the GitHub bot will
take
I think this is a good first issue as the need is clear and the tests in https://github.com/apache/datafusion/blob/85fbde2661bdb462fc498dc18f055c44f229604c/datafusion/sql/tests/cases/diagnostic.rs are well structured for extension.
Hey @dentiny how is it going with this ticket :) Can I help with anything?
Hi @eliaperantoni thanks for checking! I'm still playing around df these days, should be able to get sth by EOW, do you think it's ok for you?
Hi @eliaperantoni thanks for checking! I'm still playing around df these days, should be able to get sth by EOW, do you think it's ok for you?
Absolutely! I'm here if you need any help :)
Checking the code, I found for "invalid argument type" error there're quite a few places we need to update; I update only one of them in the PR, mainly want to make sure I don't mis-understand, could followup with other PRs later on.
@eliaperantoni I was planning to work on this, I have already made progress, my inital plan is:
- Add span storage to ScalarFunction/AggregateFunction and plumb it from the SQL parser to the coercion layer.
- Adjust pattern matches/constructors across planner/optimizer/unparser to compile with the new fields.
- Wrap the coercion errors with diagnostics using those spans and add tests for both scalar and aggregate cases.
My only question was making all these changes will require touching several files, would that be appropriate for this issue. Because Without adding spans to function expressions, we’d be guessing locations and couldn’t meet the goal of highlighting the SQL source.
Let me know if you have any other feedback.
@alamb if you're available for feedback on this.
Has this issue been solved?
I don't think so
I don't think @eliaperantoni is actively working on this area any more
I am not sure if @kumarUjjawal is doing so either
I was looking into it few weeks ago but currently it is not in my plans. Feel free to take a look @RSAgr
Hi! I'm looking to make my first contribution to DataFusion, and this issue looks like a great starting point.
Is anyone currently working on this? If not, I'd love to take it on. I've already started exploring the codebase and have a rough plan for the implementation.
Thanks!
Hi @choplin Thank you for the interest. I don't think anyone is working on this at the moment. Feel free to take. If you need any help let me know.
Assigned!
Hi @choplin, are you still working on this? If it’s available, I’d love to pick it up as my first contribution to DataFusion.
@aruadecarvalho Thank you. I've been too busy for a while to work on this, so please feel free to take it. I have already opened #23063 for this issue, but the problem is that it requires a breaking change—adding a new field to a struct to keep a span—so what we have to do is to align with the release schedule to merge the breaking change. JFYI.
Thanks for the context! I’ll take this and review #23063. I’ll check with @alamb the breaking change and release timing before proceeding.
take