Skip to content

Comments

feat: record_batch! macro#6588

Merged
alamb merged 1 commit intoapache:masterfrom
ByteBaker:master
Nov 16, 2024
Merged

feat: record_batch! macro#6588
alamb merged 1 commit intoapache:masterfrom
ByteBaker:master

Conversation

@ByteBaker
Copy link
Contributor

closes: #6553

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 18, 2024
@ByteBaker
Copy link
Contributor Author

For your review @alamb

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.

@timsaucer
Copy link
Member

Thank you for doing this!

@ByteBaker
Copy link
Contributor Author

@alamb you're right. I was just lazy and did the bare-minimum. Lemme see how I can further extend this to cover more types and add necessary docs wherever applicable. I'll be back soon.

@alamb alamb marked this pull request as draft November 15, 2024 20:53
@alamb
Copy link
Contributor

alamb commented Nov 15, 2024

Marking as draft as the CI is not passing and there seems to be planned work. CI might pass if we merge up from main

@ByteBaker
Copy link
Contributor Author

@alamb sorry but I've been somewhat occupied the past several weeks. There's some work I've done but I don't think it's quite ready yet.

@ByteBaker ByteBaker closed this Nov 16, 2024
@ByteBaker ByteBaker reopened this Nov 16, 2024
@ByteBaker ByteBaker marked this pull request as ready for review November 16, 2024 12:24
@ByteBaker ByteBaker force-pushed the master branch 2 times, most recently from e05d26d to e4310ab Compare November 16, 2024 12:36
@ByteBaker
Copy link
Contributor Author

ByteBaker commented Nov 16, 2024

@alamb @timsaucer I've synced the repo and pushed the work for now. Please take a look.

I believe this covers most, if not all the non-nested types. I've also added the necessary docs, clearly mentioning the limitations of this macro.

@timsaucer
Copy link
Member

Oh nice. FWIW, I don’t think we need to cover nested types. This is really just a convenience macro and primarily used for unit tests and examples, so it’s perfectly reasonable in my opinion that the scope is limited. For anything more the user can do what they’ve been doing until now.

I will try to review tomorrow or Monday unless someone gets to it first.

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.

Love it

/// ("b", b),
/// ]);
/// ```
/// Another way to quickly create a [`RecordBatch`] is to use the [`record_batch!`] macro,
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

@alamb alamb merged commit 1f19412 into apache:master Nov 16, 2024
@alamb
Copy link
Contributor

alamb commented Nov 16, 2024

Thanks @ByteBaker and @timsaucer

@alamb alamb added the enhancement Any new improvement worthy of a entry in the changelog label Nov 17, 2024
ByteBaker added a commit to ByteBaker/datafusion that referenced this pull request Oct 23, 2025
Removes DataFusion's custom `record_batch!` and `create_array!` macro
implementations in favor of the upstream versions from arrow-rs added in
apache/arrow-rs#6588.

Changes:
- Replace custom macro definitions with re-exports from arrow::array
- Update syntax from vec![...] to array literal [...] across 67 usages
- Add arrow_schema aliases in test modules for macro compatibility
- Replace macro usage with manual RecordBatch construction where
  variables are used (macros only support literals)

Closes apache#13037
ByteBaker added a commit to ByteBaker/datafusion that referenced this pull request Oct 28, 2025
Removes DataFusion's custom `record_batch!` and `create_array!` macro
implementations in favor of the upstream versions from arrow-rs added in
apache/arrow-rs#6588.

Changes:
- Replace custom macro definitions with re-exports from arrow::array
- Update syntax from vec![...] to array literal [...] across 67 usages
- Add arrow_schema aliases in test modules for macro compatibility
- Replace macro usage with manual RecordBatch construction where
  variables are used (macros only support literals)

Closes apache#13037
ByteBaker added a commit to ByteBaker/datafusion that referenced this pull request Oct 28, 2025
Removes DataFusion's custom `record_batch!` and `create_array!` macro
implementations in favor of the upstream versions from arrow-rs added in
apache/arrow-rs#6588.

Changes:
- Replace custom macro definitions with re-exports from arrow::array
- Update syntax from vec![...] to array literal [...] across 67 usages
- Add arrow_schema aliases in test modules for macro compatibility
- Add record_batch_vec! legacy macro for cases where upstream macro
  cannot be used (variables, vec repetition syntax)
- Use record_batch_vec! in examples and tests that pass variables
- Add datafusion-common dependency to ffi_example_table_provider

The record_batch_vec! macro is a temporary solution until arrow-rs
supports variables and repetition syntax. See upstream issue:
apache/arrow-rs#6553

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

Labels

arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add record_batch! macro for easy record batch creation

3 participants