Skip to content

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

Merged
alamb merged 6 commits intoapache:mainfrom
comphead:dev
Oct 16, 2023
Merged

Extend backtrace coverage for DatafusionError::Plan errors errors#7803
alamb merged 6 commits intoapache:mainfrom
comphead:dev

Conversation

@comphead
Copy link
Copy Markdown
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
Comment thread datafusion/common/src/error.rs Outdated

// Exposes a macro to create `DataFusionError::Plan`
make_error!(plan_err, Plan);
make_error!(plan_err, plan_err_raw, Plan);
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread datafusion/common/src/error.rs Outdated
/// plan_err!("Error {val:?}")
macro_rules! make_error {
($NAME:ident, $ERR:ident) => {
($NAME:ident, $NAME_RAW: ident, $ERR:ident) => {
Copy link
Copy Markdown
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)

Comment thread datafusion/common/src/error.rs Outdated

// Exposes a macro to create `DataFusionError::Plan`
make_error!(plan_err, Plan);
make_error!(plan_err, plan_err_raw, Plan);
Copy link
Copy Markdown
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
Copy Markdown
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

/// 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍

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