Make macros in common::test_util hygenic and not dependent on user dependencies#17102
Merged
Jefffrey merged 1 commit intoAug 11, 2025
Merged
Conversation
Jefffrey
approved these changes
Aug 10, 2025
Jefffrey
left a comment
Contributor
There was a problem hiding this comment.
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 👍
Contributor
|
Thanks @AdamGS 🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
datafusion-commonaren't hygenic, requiring the arrow crate as a dependency #17101.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?