This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-11989-e600f5a22d3883d4edb19df8be8730f1b5ad45ed in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
commit 348878b27b0bf93cad5eff94dc4f153e21c262e0 Author: Kosta Tarasov <[email protected]> AuthorDate: Thu Oct 29 15:09:14 2026 +0000 Reuse VARIANT_SPEC_VERSION when encoding metadata (#11989) # Which issue does this PR close? Follow-up to #11961. # Rationale for this change The metadata writer and empty metadata bytes still hardcode version `1`, despite the shared `VARIANT_SPEC_VERSION` introduced in #11961. # What changes are included in this PR? Use `VARIANT_SPEC_VERSION` in `WritableMetadataBuilder::finish` and `EMPTY_VARIANT_METADATA_BYTES` so metadata encoding uses the same constant as validation and the Parquet annotation. # Are these changes tested? Existing metadata builder tests and empty metadata doctests cover the substitutions; no new tests are needed. Variant and workspace tests, Clippy, formatting, and spelling checks pass. # Are there any significant user-facing changes? No. The encoded bytes are unchanged. # AI Use Patch and description prepared with AI assistance. --- parquet-variant/src/builder/metadata.rs | 5 +++-- parquet-variant/src/variant/metadata.rs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/parquet-variant/src/builder/metadata.rs b/parquet-variant/src/builder/metadata.rs index 8cde95e943..4b76700137 100644 --- a/parquet-variant/src/builder/metadata.rs +++ b/parquet-variant/src/builder/metadata.rs @@ -20,7 +20,7 @@ use std::collections::HashMap; use arrow_schema::ArrowError; use indexmap::IndexSet; -use crate::{VariantMetadata, int_size}; +use crate::{VARIANT_SPEC_VERSION, VariantMetadata, int_size}; /// Write little-endian integer to buffer fn write_offset(buf: &mut Vec<u8>, value: usize, nbytes: u8) { @@ -228,7 +228,8 @@ impl WritableMetadataBuilder { metadata_buffer.reserve(metadata_size); // Write header: version=1, field names are sorted, with calculated offset_size - metadata_buffer.push(0x01 | ((is_sorted as u8) << 4) | ((offset_size - 1) << 6)); + metadata_buffer + .push(VARIANT_SPEC_VERSION | ((is_sorted as u8) << 4) | ((offset_size - 1) << 6)); // Write dictionary size write_offset(metadata_buffer, nkeys, offset_size); diff --git a/parquet-variant/src/variant/metadata.rs b/parquet-variant/src/variant/metadata.rs index da45757729..ee5bbbeeba 100644 --- a/parquet-variant/src/variant/metadata.rs +++ b/parquet-variant/src/variant/metadata.rs @@ -159,7 +159,7 @@ const _: () = crate::utils::expect_size_of::<VariantMetadata>(20); /// let metadata_bytes = metadata_builder.into_inner(); /// assert_eq!(&metadata_bytes, EMPTY_VARIANT_METADATA_BYTES); /// ``` -pub const EMPTY_VARIANT_METADATA_BYTES: &[u8] = &[1, 0, 0]; +pub const EMPTY_VARIANT_METADATA_BYTES: &[u8] = &[VARIANT_SPEC_VERSION, 0, 0]; /// The empty metadata dictionary. ///
