This is an automated email from the ASF dual-hosted git repository.

alamb 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 6ff8cc4d04 Support for `Arc<str>` in `ParquetRecordWriter` derive 
macro (#8973)
6ff8cc4d04 is described below

commit 6ff8cc4d04750332208931b483c4703025ced079
Author: Ivan Reshetnikov <[email protected]>
AuthorDate: Thu Dec 11 20:47:37 2025 +0100

    Support for `Arc<str>` in `ParquetRecordWriter` derive macro (#8973)
    
    # Which issue does this PR close?
    
    - Closes #8972.
    
    # Rationale for this change
    
    See #8972 for more info.
    
    # What changes are included in this PR?
    
    Updates the derive macro implementation to include string serialization
    from `Arc<str>`.
    
    # Are these changes tested?
    
    Yes. I've updated `parquet_derive_test` to include writing `Arc<str>`.
    And we've been using our fork with these changes in production for ~3
    years.
    
    # Are there any user-facing changes?
    
    Not sure, probably not?
    
    ---------
    
    Co-authored-by: Harry Bairstow <[email protected]>
---
 parquet_derive/src/parquet_field.rs | 4 ++--
 parquet_derive_test/src/lib.rs      | 9 +++++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/parquet_derive/src/parquet_field.rs 
b/parquet_derive/src/parquet_field.rs
index f51c22f65f..7473f23055 100644
--- a/parquet_derive/src/parquet_field.rs
+++ b/parquet_derive/src/parquet_field.rs
@@ -643,7 +643,7 @@ impl Type {
             }
             "f32" => BasicType::FLOAT,
             "f64" => BasicType::DOUBLE,
-            "String" | "str" => BasicType::BYTE_ARRAY,
+            "String" | "str" | "Arc < str >" => BasicType::BYTE_ARRAY,
             "Uuid" => BasicType::FIXED_LEN_BYTE_ARRAY,
             f => unimplemented!("{} currently is not supported", f),
         }
@@ -733,7 +733,7 @@ impl Type {
             "NaiveDate" => quote! { Some(LogicalType::Date) },
             "NaiveDateTime" => quote! { None },
             "f32" | "f64" => quote! { None },
-            "String" | "str" => quote! { Some(LogicalType::String) },
+            "String" | "str" | "Arc < str >" => quote! { 
Some(LogicalType::String) },
             "Uuid" => quote! { Some(LogicalType::Uuid) },
             f => unimplemented!("{} currently is not supported", f),
         }
diff --git a/parquet_derive_test/src/lib.rs b/parquet_derive_test/src/lib.rs
index 71eb636069..fe96fa0e61 100644
--- a/parquet_derive_test/src/lib.rs
+++ b/parquet_derive_test/src/lib.rs
@@ -23,6 +23,7 @@
 #![allow(clippy::approx_constant)]
 
 use parquet_derive::{ParquetRecordReader, ParquetRecordWriter};
+use std::sync::Arc;
 
 #[derive(ParquetRecordWriter)]
 struct ACompleteRecord<'a> {
@@ -30,8 +31,10 @@ struct ACompleteRecord<'a> {
     pub a_str: &'a str,
     pub a_string: String,
     pub a_borrowed_string: &'a String,
+    pub a_arc_str: Arc<str>,
     pub maybe_a_str: Option<&'a str>,
     pub maybe_a_string: Option<String>,
+    pub maybe_a_arc_str: Option<Arc<str>>,
     pub i16: i16,
     pub i32: i32,
     pub u64: u64,
@@ -130,8 +133,10 @@ mod tests {
             REQUIRED BINARY          a_str (STRING);
             REQUIRED BINARY          a_string (STRING);
             REQUIRED BINARY          a_borrowed_string (STRING);
+            REQUIRED BINARY          a_arc_str (STRING);
             OPTIONAL BINARY          maybe_a_str (STRING);
             OPTIONAL BINARY          maybe_a_string (STRING);
+            OPTIONAL BINARY          maybe_a_arc_str (STRING);
             REQUIRED INT32           i16 (INTEGER(16,true));
             REQUIRED INT32           i32;
             REQUIRED INT64           u64 (INTEGER(64,false));
@@ -159,8 +164,10 @@ mod tests {
 
         let a_str = "hello mother".to_owned();
         let a_borrowed_string = "cool news".to_owned();
+        let a_arc_str: Arc<str> = "hello arc".into();
         let maybe_a_string = Some("it's true, I'm a string".to_owned());
         let maybe_a_str = Some(&a_str[..]);
+        let maybe_a_arc_str = Some(a_arc_str.clone());
         let borrowed_byte_vec = vec![0x68, 0x69, 0x70];
         let borrowed_maybe_byte_vec = Some(vec![0x71, 0x72]);
         let borrowed_maybe_borrowed_byte_vec = Some(&borrowed_byte_vec[..]);
@@ -170,8 +177,10 @@ mod tests {
             a_str: &a_str[..],
             a_string: "hello father".into(),
             a_borrowed_string: &a_borrowed_string,
+            a_arc_str,
             maybe_a_str: Some(&a_str[..]),
             maybe_a_string: Some(a_str.clone()),
+            maybe_a_arc_str,
             i16: -45,
             i32: 456,
             u64: 4563424,

Reply via email to