-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add macros for DataFusionError variants #15946
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
base: main
Are you sure you want to change the base?
Conversation
46d4193
to
9ab2ef4
Compare
datafusion/common/src/error.rs
Outdated
@@ -808,12 +808,18 @@ make_error!(plan_err, plan_datafusion_err, Plan); | |||
// Exposes a macro to create `DataFusionError::Internal` with optional backtrace | |||
make_error!(internal_err, internal_datafusion_err, Internal); | |||
|
|||
// Exposes a macro to create `DataFusionError::IoError` with optional backtrace | |||
make_error!(external_err, external_datafusion_err, External); |
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.
wasn't there any current usage of this error types it to replace with macros?
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.
Hi @comphead, I noticed that using make_error!
isn't suitable for these error variants because External
and ExecutionJoin
are designed to wrap original error objects, not just error messages.
Instead, I've implemented custom macros for External
and ExecutionJoin
errors, similar to #15796, and replaced a few use cases as examples. Should we replace all the cases?
9ab2ef4
to
dfeded6
Compare
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.
The key point of this macros is preserving backtrace which makes debugging easier if you got an error from datafusion among multiple layers of processing.
The variant below is for non string errors preserving the backtrace
#[macro_export]
macro_rules! schema_err {
($ERR:expr $(; diagnostic = $DIAG:expr)?) => {{
let err = $crate::error::DataFusionError::SchemaError(
$ERR,
Box::new(Some($crate::error::DataFusionError::get_back_trace())),
);
$(
let err = err.with_diagnostic($DIAG);
)?
Err(err)
}
};
}
Which issue does this PR close?
Rationale for this change
What changes are included in this PR?
As #15491 says, add two macros for
Moreover, the macro for
ResourcesExhausted
already existed, so we don't need to add it in the PRAre these changes tested?
Are there any user-facing changes?