Skip to content
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

Extend backtrace coverage for DatafusionError::Plan errors errors #7803

Merged
merged 6 commits into from
Oct 16, 2023

Conversation

comphead
Copy link
Contributor

@comphead comphead commented Oct 12, 2023

Which issue does this PR close?

Closes #7818

The PR improves backtrace coverage for DatafusionError::Plan errors, specifically for errors called in
ok_or_else or map_err constructions

Rationale for this change

Currently constructions ok_or_else or map_err using direct reference to DatafusionError::Plan which makes impossible to backtrace them in case of tracing error for the Result<T, E>. To improve the coverage one more error macros introduced plan_err_raw (name discussible)

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions optimizer Optimizer rules core Core DataFusion crate labels Oct 12, 2023
@@ -493,16 +500,16 @@ macro_rules! make_error {
}

// Exposes a macro to create `DataFusionError::Plan`
make_error!(plan_err, Plan);
make_error!(plan_err, plan_err_raw, Plan);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not able to invent better naming, appreciate if anyone helps

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe plan_err_obj or plan_datafusion_error?

@comphead comphead requested a review from alamb October 14, 2023 04:21
Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 👍 (did't come up with a better naming)

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @comphead -- this looks like an improvement to me. I left some suggestions on how to improve the documentation that I think would be valuable, and some alternative names for your consideration

@@ -478,9 +478,16 @@ macro_rules! with_dollar_sign {
/// plan_err!("Error {val}")
/// plan_err!("Error {val:?}")
macro_rules! make_error {
($NAME:ident, $ERR:ident) => {
($NAME:ident, $NAME_RAW: ident, $ERR:ident) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please document in comments what $NAME and $NAME_RAW are and how they are different?

my reading is that the raw is the name of an internal macro that gets generated. I think it would help to document more clearly what the difference in plan_err! and plan_err_raw! did (specifically that plan_err returns an Err(plan_err_raw)

@@ -493,16 +500,16 @@ macro_rules! make_error {
}

// Exposes a macro to create `DataFusionError::Plan`
make_error!(plan_err, Plan);
make_error!(plan_err, plan_err_raw, Plan);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe plan_err_obj or plan_datafusion_error?

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @comphead

@@ -477,12 +477,25 @@ macro_rules! with_dollar_sign {
/// plan_err!("Error {:?}", val)
/// plan_err!("Error {val}")
/// plan_err!("Error {val:?}")
///
/// `NAME_ERR` - macro name for wrapping Err(DataFusionError::*)
/// `NAME_DF_ERR` - macro name for wrapping DataFusionError::*. Needed to keep backtrace opportunity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@alamb alamb merged commit cb6f7fe into apache:main Oct 16, 2023
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend backtrace coverage for constructions like ok_or_else, map_err
4 participants