Skip to content

Make macros in common::test_util hygenic and not dependent on user dependencies#17102

Merged
Jefffrey merged 1 commit into
apache:mainfrom
AdamGS:adamg/make-common-test-util-macros-hygenic
Aug 11, 2025
Merged

Make macros in common::test_util hygenic and not dependent on user dependencies#17102
Jefffrey merged 1 commit into
apache:mainfrom
AdamGS:adamg/make-common-test-util-macros-hygenic

Conversation

@AdamGS

@AdamGS AdamGS commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Make both macros slightly nicer to use, and prevent some potentially confusing error messages.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added the common Related to common crate label Aug 8, 2025

@Jefffrey Jefffrey left a comment

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.

Tested with simple example with dependency on only datafusion-common, first off main:

use datafusion_common::record_batch;

fn main() {
    let batch = record_batch!(
        ("a", Int32, vec![1, 2, 3]),
        ("b", Float64, vec![Some(4.0), None, Some(5.0)]),
        ("c", Utf8, vec!["alpha", "beta", "gamma"])
    );
}

Error:

error[E0433]: failed to resolve: use of unresolved module or unlinked crate `arrow`
 --> src/main.rs:4:17
  |
4 |       let batch = record_batch!(
  |  _________________^
5 | |         ("a", Int32, vec![1, 2, 3]),
6 | |         ("b", Float64, vec![Some(4.0), None, Some(5.0)]),
7 | |         ("c", Utf8, vec!["alpha", "beta", "gamma"])
8 | |     );
  | |_____^ use of unresolved module or unlinked crate `arrow`
  |
  = help: if you wanted to use a crate named `arrow`, use `cargo add arrow` to add it to your `Cargo.toml`
  = note: this error originates in the macro `record_batch` (in Nightly builds, run with -Z macro-backtrace for more info)

With this branch, it compiles successfully without a dependency on arrow.

LGTM 👍

@Jefffrey
Jefffrey merged commit 999b44b into apache:main Aug 11, 2025
27 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

Thanks @AdamGS 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

common Related to common crate

2 participants