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

Run cargo-fmt on datafusion-functions/core #9367

Merged
merged 6 commits into from
Feb 28, 2024
Merged

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Feb 27, 2024

Which issue does this PR close?

Part of #9281

Rationale for this change

cargo fmt is not run on much of the code in datafusion-functions due to rust-lang/rustfmt#3253, As @jonahgao found

This makes PRs larger than necessary and misses all the benefits of cargo-fmt

What changes are included in this PR?

  1. Change how the datafusion-functions/core module is declared using a direct conditional include so it it is visible to rust-fmt
  2. Run cargo fmt and check in the resulting formatting changes in core

Are these changes tested?

Yes, by CI

Are there any user-facing changes?

No, this is an internal development process change

use arrow::array::Array;
use arrow::compute::kernels::cmp::eq;
use arrow::compute::kernels::nullif::nullif;
use datafusion_common::ScalarValue;
use datafusion_expr::{ScalarUDFImpl, Signature, Volatility};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The changes in this file are entirely due to cargo-fmt being run now

@@ -84,7 +84,11 @@ use log::debug;
#[macro_use]
pub mod macros;

make_package!(core, "core_expressions", "Core datafusion expressions");
/// Core datafusion expressions
/// Enabled via feature flag `core_expressions`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the actual change. If this PR is merged, I will make follow on PR(s) to apply the same treatment to the other modules in datafusion-functions.

I did only one initially to keep the size of the PR down

/// properly (so they get an error telling them why a function is not available)
/// instead of getting a cryptic "no function found" message at runtime.

macro_rules! make_stub_package {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is part of the make_package macro which I think keeps most of the "don't repeat yourself" goal but still allows cargo fmt to run.

Once I port over the other modules to use this pattern, I will remove the make_package macro

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.

lgtm thanks @alamb and @jonahgao

so package level macros prevented cargo fmt to run?

Copy link
Contributor

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

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

Nice 👍

@alamb
Copy link
Contributor Author

alamb commented Feb 27, 2024

lgtm thanks @alamb and @jonahgao

so package level macros prevented cargo fmt to run?

I think the problem is rust-lang/rustfmt#3253 -- specifically if you use a macro to define a module cargo fmt cant' see it.

This code was previously using a macro to create code like

mod core;

@alamb alamb merged commit e4182d4 into apache:main Feb 28, 2024
23 checks passed
@alamb alamb deleted the alamb/fmt branch February 28, 2024 18:46
@alamb
Copy link
Contributor Author

alamb commented Feb 28, 2024

Here is the follow on PR to run rustfmt on all the modules: #9390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants