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 d48c3057e1 fix(arrow-schema): allow empty metadata value for UUID 
extension type (#10001)
d48c3057e1 is described below

commit d48c3057e1e8113463fe5d3cee3ede6db092eaf2
Author: Alfonso Subiotto Marqués <[email protected]>
AuthorDate: Wed May 20 14:56:04 2026 +0200

    fix(arrow-schema): allow empty metadata value for UUID extension type 
(#10001)
    
    # Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax.
    -->
    
    - Closes #10000
    
    # Rationale for this change
    
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    -->
    Some ipc writers such as arrow-go unconditionally write an empty
    metadata value, which breaks deserialization.
    
    # What changes are included in this PR?
    
    <!--
    There is no need to duplicate the description in the issue here but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    Empty check
    
    # Are these changes tested?
    
    <!--
    We typically require tests for all PRs in order to:
    1. Prevent the code from being accidentally broken by subsequent changes
    2. Serve as another way to document the expected behavior of the code
    
    If tests are not included in your PR, please explain why (for example,
    are they covered by existing tests)?
    
    If this PR claims a performance improvement, please include evidence
    such as benchmark results.
    -->
    Yes
    
    # Are there any user-facing changes?
    
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    
    If there are any breaking changes to public APIs, please call them out.
    -->
    
    Signed-off-by: Alfonso Subiotto Marques <[email protected]>
---
 arrow-schema/src/extension/canonical/uuid.rs | 31 +++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/arrow-schema/src/extension/canonical/uuid.rs 
b/arrow-schema/src/extension/canonical/uuid.rs
index affea04acb..7a9f6e6e53 100644
--- a/arrow-schema/src/extension/canonical/uuid.rs
+++ b/arrow-schema/src/extension/canonical/uuid.rs
@@ -53,10 +53,14 @@ impl ExtensionType for Uuid {
     fn deserialize_metadata(metadata: Option<&str>) -> Result<Self::Metadata, 
ArrowError> {
         metadata.map_or_else(
             || Ok(()),
-            |_| {
-                Err(ArrowError::InvalidArgumentError(
-                    "Uuid extension type expects no metadata".to_owned(),
-                ))
+            |v| {
+                if !v.is_empty() {
+                    Err(ArrowError::InvalidArgumentError(
+                        "Uuid extension type expects no metadata".to_owned(),
+                    ))
+                } else {
+                    Ok(())
+                }
             },
         )
     }
@@ -122,11 +126,28 @@ mod tests {
         let field = Field::new("", DataType::FixedSizeBinary(16), 
false).with_metadata(
             [
                 (EXTENSION_TYPE_NAME_KEY.to_owned(), Uuid::NAME.to_owned()),
-                (EXTENSION_TYPE_METADATA_KEY.to_owned(), "".to_owned()),
+                (
+                    EXTENSION_TYPE_METADATA_KEY.to_owned(),
+                    "unexpected".to_owned(),
+                ),
             ]
             .into_iter()
             .collect(),
         );
         field.extension_type::<Uuid>();
     }
+
+    #[test]
+    fn empty_metadata_string_is_treated_as_none() -> Result<(), ArrowError> {
+        let field = Field::new("", DataType::FixedSizeBinary(16), 
false).with_metadata(
+            [
+                (EXTENSION_TYPE_NAME_KEY.to_owned(), Uuid::NAME.to_owned()),
+                (EXTENSION_TYPE_METADATA_KEY.to_owned(), "".to_owned()),
+            ]
+            .into_iter()
+            .collect(),
+        );
+        field.try_extension_type::<Uuid>()?;
+        Ok(())
+    }
 }

Reply via email to