-
Notifications
You must be signed in to change notification settings - Fork 715
refactor: improve error handling for datafusion engine #24097
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
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.
Pull request overview
This PR refactors error handling in the DataFusion integration by introducing a dedicated error module with proper backtrace support. The changes enable better debugging capabilities by capturing and formatting backtraces when converting RisingWave errors to DataFusion errors.
Key changes:
- Creates a new error module with
to_datafusion_errorfunction that captures backtraces - Enables the "backtrace" feature for DataFusion dependencies to support backtrace functionality
- Replaces the previous inline
boxedhelper function with the new centralized error conversion
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/frontend/src/datafusion/error.rs | New module containing error wrapper struct and to_datafusion_error function with backtrace capture logic |
| src/frontend/src/datafusion/mod.rs | Adds error module declaration and exports to_datafusion_error function, removes inline error conversion |
| src/frontend/src/datafusion/function.rs | Replaces all boxed calls with to_datafusion_error and removes old helper function |
| src/frontend/src/datafusion/iceberg_executor.rs | Updates to use exec_err! macro for more idiomatic DataFusion error handling |
| src/frontend/src/datafusion/iceberg_table_provider.rs | Simplifies return type using DFResult type alias for consistency |
| src/frontend/Cargo.toml | Enables "backtrace" features for datafusion dependencies and includes some unrelated formatting changes |
97eb01c to
dfffbcc
Compare
dfffbcc to
09e6d61
Compare
Signed-off-by: Mingzhuo Yin <[email protected]>
09e6d61 to
fe9e006
Compare
chenzl25
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.
LGTM
BugenZhao
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.
DataFusion's printing backtrace in Display impl is not a good practice in my own opinion. It's still okay if DataFusionError will be the topmost type. However, if we wrap it back into an RwError, it will confuse our Report and result in very ugly user-facing error message.
Would you add some e2e test case demonstrating the UI?
src/frontend/src/datafusion/error.rs
Outdated
| if let Some(bt) = std::error::request_ref::<Backtrace>(self.0.as_ref()) { | ||
| write!(f, "{}{}", DataFusionError::BACK_TRACE_SEP, bt)?; | ||
| } else if let Some(bt) = &self.1 { | ||
| write!(f, "{}{}", DataFusionError::BACK_TRACE_SEP, bt)?; | ||
| } |
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.
Shall we provide backtrace from either source, so that we can unify the fmt impl here?
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.
done in new commit
Below is the actual error users see today. It is admittedly ugly, but at the moment there is no clean way to log the detailed backtrace without also exposing it to the user-facing console. We may need to wait Detailed error info |
Actually we would like to refrain from printing backtrace to users via SQL interface. 😕 If embedding a backtrace is mainly for debugging purposes at current stage, then we may temporarily tolerate such user interface. However, if the motivation is to expose the backtrace to users, I don't think it's a good idea. |
I agree with it. Ideally, we would only emit the backtrace to logs for debugging purposes and keep the SQL user-facing error concise and clean. Unfortunately, with the current technical constraints, we don’t have a reliable way to separate the two. Given that limitation, if we have to choose between losing the backtrace entirely or tolerating a somewhat ugly error message, I think keeping the backtrace is the lesser evil. It significantly improves debuggability, even though the user experience is not ideal. This is not meant to justify exposing backtraces to users long-term. Once we have a proper mechanism to decouple logging from user-facing errors, we should absolutely switch to that. |
Done in new commit |
BugenZhao
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.
LGTM

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
This PR improves error handling in the DataFusion integration.
RisingWaveErrortoDataFusionError, it will embed backtrace to formated string like other datafusion errors.Checklist
Documentation
Release note