feat: add `custom_metadata` support to `RecordBatch` with IPC read/write #9445
All Vouch review confidence checks passed
Residual risk 0.29 = Change Risk (0.49) × (1 − Review Confidence (0.41)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.49 · 325 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.346
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #9445"
general
weight: 0.35
rustyconover
Which issue does this PR close?
Rationale for this change
The IPC
Messageflatbuffer envelope has acustom_metadatafield for per-batch key-value metadata, separate from schema-level metadata. arrow-rs currently drops it on read and has no way to write it. PyArrow supports it (write_batch(custom_metadata=...), since v11.0.0), as do arrow-go and arrow-js.What changes are included in this PR?
Add per-batch
custom_metadatatoRecordBatch, stored asarrow_schema::Metadata(introduced in #10075). An emptyMetadatadoes not allocate, soRecordBatchgrows by a single pointer (40 → 48 bytes). Clones share the underlying map, and IPC encoding is deterministic (sorted by key).RecordBatchmethods:custom_metadatato theMessageflatbuffer viaconvert::metadata_to_fbreader::message_custom_metadata;FileDecoder,StreamReader, andStreamDecoderattach the metadata to decoded batchesflight_data_to_arrow_batchextracts and attachescustom_metadatafilter_record_batchandtake_record_batchpreservecustom_metadataslice(),project(),normalize(),with_schema(), andremove_column()Are these changes tested?
Yes:
RecordBatchAPI (setting, mutating, copy-on-write, sharing between batches, equality, and preservation through slice/project)StreamDecoderround-trips, including multiple batches with different metadata and batches without metadataarrow-ipc/test_data/custom_metadata.arrow_{file,stream}) for cross-language interopfilter_record_batchandtake_record_batchpreserve the metadataAre there any user-facing changes?
Yes, new public APIs on
RecordBatchandarrow_ipc::reader::message_custom_metadata. There are no breaking changes: existing constructors produce batches with empty metadata, andPartialEqnow also comparescustom_metadata.Written with AI assistance; all changes reviewed by the author.
🤖 Generated with Claude Code