-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add related source code locations to errors #13662
Comments
Datafusion supports backtraces to find where the problem happens in the first place https://datafusion.apache.org/user-guide/crate-configuration.html#enable-backtraces |
That's true, and I think it's an invaluable tool for debugging and developing DataFusion or software that relies on it. But in my opinion it's not really the best end user facing error reporting solution.
Take this trace:
The query was With the changes that I'm contributing in #13664, the same query would produce diagnostics data that look like this:
|
Thanks @eliaperantoni |
I think the parser and the logical planner capture different categories of errors. They do it already now, just not in a user-friendly way. The parser would catch errors such as a syntactically invalid query (e.g. Though, you are right that the source location information must come from the parser, and we have contributed that here datafusion-sqlparser-rs#1435. It's just that the parser alone doesn't understand how the AST tree is being interpreted, the logical planner does that. One key consideration is that in #13664 I'm enhancing errors from the logical planner only: syntactically invalid queries would still result in a user-unfriendly error from datafusion-sqlparser-rs. Perhaps we can, at some point, do the same to datafusion-sqlparser-rs too? |
Is your feature request related to a problem or challenge?
DataFusionError
does not provide information about the location inside the SQL query that caused it. It's difficult for the end user to understand where, in a large query, to go look for the cause of the error.Example:
When creating a logical plan for this query, we'd return:
It's up to the user to figure out that the error lies on the third-to-last line.
Describe the solution you'd like
With the AST nodes from the parser now containing the source code location (thanks to apache/datafusion-sqlparser-rs#1435), it now becomes possible to add the same information to errors. This could seriously improve the experience for end users, since they would be able to clearly see where in the queries the errors lie.
In the example above, the desired feature of this ticket would be to add a reference to the third-to-last line, which is the cause of the error:
price_usd + '$' AS display_price_usd
.Furthermore, it would be helpful to link to additonal segments of code note that, despite not representing the root cause of the error, help the user understand the context around the error and the elements involved. In this example, we'd highlight the projected
price_usd
column in the CTE to help the user understand where it comes from.Describe alternatives you've considered
DataFusionError::Context
only adds additional debug strings, but doesn't attach source code location info.Additional context
No response
The text was updated successfully, but these errors were encountered: