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

refactor: fix error macros hygiene (always import DataFusionError) #9366

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

crepererum
Copy link
Contributor

Which issue does this PR close?

-

Rationale for this change

Error macros should be hygienic, i.e. they should be self-contained and don't require the user to import additional symbols.

What changes are included in this PR?

  1. make error macros self-contained
  2. add regression test
  3. fix clippy fall-out

Are these changes tested?

Regression test.

Are there any user-facing changes?

User no longer needs to import DataFusionError just to use error macros (e.g. plan_err!).

@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions physical-expr Physical Expressions optimizer Optimizer rules core Core DataFusion crate substrait labels Feb 27, 2024
@crepererum crepererum force-pushed the crepererum/macro_hygiene branch from 83c5dfb to e114c7c Compare February 27, 2024 11:31
@alamb alamb changed the title refactor: fix error macros hygiene refactor: fix error macros hygiene (always import DataFusionError) Feb 27, 2024
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 @crepererum -- this has bothered me for a long time as well. It is a very nice paper cut improvement

😍

cc @comphead

datafusion/common/tests/macro_hygiene.rs Outdated Show resolved Hide resolved
fn merge_grouping_set<T: Clone>(left: &[T], right: &[T]) -> Result<Vec<T>> {
check_grouping_set_size_limit(left.len() + right.len())?;
Ok(left.iter().chain(right.iter()).cloned().collect())
}

/// Compute the cross product of two grouping_sets
///
/// # Example
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@crepererum crepererum force-pushed the crepererum/macro_hygiene branch from e114c7c to 8b784f2 Compare February 27, 2024 16:22
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

thanks @crepererum I love it.
Maybe we can invent a better naming for the mod? hygiene is a little bit unclear what is supposed to do

@crepererum crepererum force-pushed the crepererum/macro_hygiene branch from 8b784f2 to 2f3e097 Compare February 27, 2024 16:32
@crepererum
Copy link
Contributor Author

Maybe we can invent a better naming for the mod? hygiene is a little bit unclear what is supposed to do

I'm open to suggestions. To me "macro hygiene" is an official term.

@comphead
Copy link
Contributor

Maybe we can invent a better naming for the mod? hygiene is a little bit unclear what is supposed to do

I'm open to suggestions. To me "macro hygiene" is an official term.

Ic, good point. would you mind adding the this WIKI link to the macro file? I think it would be useful for ppl like me who face hygiene macro term the first time :)

@crepererum crepererum force-pushed the crepererum/macro_hygiene branch from 388b36a to ac63469 Compare February 28, 2024 11:06
@crepererum
Copy link
Contributor Author

Rebased and a addressed all comments. Merging this due to the high conflict potential (we can always file follow-up PRs).

@crepererum crepererum merged commit a1ae158 into apache:main Feb 28, 2024
23 checks passed
@crepererum crepererum deleted the crepererum/macro_hygiene branch February 28, 2024 12:25
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 physical-expr Physical Expressions sql SQL Planner substrait
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants