This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 873c3f1b22 feat(arrow-array): support Date32/Date64 in
record_batch!/create_array! macros (#11962)
873c3f1b22 is described below
commit 873c3f1b223b095aeb6dee61ebf938994001f8b7
Author: Gabriel <[email protected]>
AuthorDate: Wed Oct 28 10:10:35 2026 +0000
feat(arrow-array): support Date32/Date64 in record_batch!/create_array!
macros (#11962)
## Summary
- Add `Date32`/`Date64` arms to the `create_array!` macro so
`record_batch!` can build date columns, matching existing support for
other primitive-backed types.
## Test plan
- [x] `cargo test -p arrow-array --lib record_batch::`
- [x] `cargo +stable fmt -p arrow-array -- --check`
- [x] `cargo clippy -p arrow-array --all-targets --all-features -- -D
warnings`
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Sonnet 5 <[email protected]>
---
arrow-array/src/record_batch.rs | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/arrow-array/src/record_batch.rs b/arrow-array/src/record_batch.rs
index 0933f61589..0c0b495533 100644
--- a/arrow-array/src/record_batch.rs
+++ b/arrow-array/src/record_batch.rs
@@ -115,6 +115,8 @@ macro_rules! create_array {
(@from TimestampMillisecond) => { $crate::TimestampMillisecondArray };
(@from TimestampMicrosecond) => { $crate::TimestampMicrosecondArray };
(@from TimestampNanosecond) => { $crate::TimestampNanosecondArray };
+ (@from Date32) => { $crate::Date32Array };
+ (@from Date64) => { $crate::Date64Array };
(@from $ty: ident) => {
compile_error!(concat!("Unsupported data type: ", stringify!($ty)))
@@ -954,7 +956,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
- use crate::types::{Int32Type, Int64Type};
+ use crate::types::{Date64Type, Int32Type, Int64Type};
use crate::{
BooleanArray, Int8Array, Int32Array, Int64Array, ListArray,
StringArray, StringViewArray,
};
@@ -1081,6 +1083,26 @@ mod tests {
assert_eq!(1, record_batch.column(1).null_count());
}
+ #[test]
+ fn create_record_batch_macro_date_types() {
+ let record_batch = record_batch!(
+ ("d32", Date32, [Some(1), None]),
+ ("d64", Date64, [86_400_000, 172_800_000])
+ )
+ .unwrap();
+
+ let expected = Schema::new(vec![
+ Field::new("d32", DataType::Date32, true),
+ Field::new("d64", DataType::Date64, true),
+ ]);
+ assert_eq!(&expected, record_batch.schema().as_ref());
+ assert_eq!(1, record_batch.column(0).null_count());
+ assert_eq!(
+ &[86_400_000, 172_800_000],
+ record_batch.column(1).as_primitive::<Date64Type>().values()
+ );
+ }
+
#[test]
fn create_record_batch_macro_length_mismatch() {
let err = record_batch!(("a", Int32, [1, 2, 3]), ("b", Int32, [1,
2])).unwrap_err();