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

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new f2b4e34d71 GH-49456: [C++] Use static key/item/value field names for 
map type again (#49457)
f2b4e34d71 is described below

commit f2b4e34d71996d744efe037bc2927e7658e78c33
Author: Sutou Kouhei <[email protected]>
AuthorDate: Thu Mar 5 20:04:21 2026 +0900

    GH-49456: [C++] Use static key/item/value field names for map type again 
(#49457)
    
    ### Rationale for this change
    
    This reverts GH-49415 because the previous behavior (using static 
"key"/"value"/"entries" field names for map type) is better. Our specification 
defines the static field names.
    
    ### What changes are included in this PR?
    
    Always use "key"/"value"/"entries" for map type field names.
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    No. This just revers the unreleased change.
    * GitHub Issue: #49456
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 cpp/src/arrow/ipc/metadata_internal.cc | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/cpp/src/arrow/ipc/metadata_internal.cc 
b/cpp/src/arrow/ipc/metadata_internal.cc
index 68dfaa0798..7f2a47b069 100644
--- a/cpp/src/arrow/ipc/metadata_internal.cc
+++ b/cpp/src/arrow/ipc/metadata_internal.cc
@@ -390,7 +390,20 @@ Status ConcreteTypeFromFlatbuffer(flatbuf::Type type, 
const void* type_data,
         return Status::Invalid("Map's keys must be non-nullable");
       } else {
         auto map = static_cast<const flatbuf::Map*>(type_data);
-        *out = std::make_shared<MapType>(children[0], map->keysSorted());
+        // We always use "key"/"value"/"entries" field names instead
+        // of field names in FlatBuffers because the specification
+        // defines them:
+        //
+        // 
https://github.com/apache/arrow/blob/apache-arrow-23.0.1/format/Schema.fbs#L127-L130
+        //
+        //   In a field with Map type, the field has a child Struct
+        //   field, which then has two children: the key type and the
+        //   value type. The names of the child fields may be
+        //   respectively "entries", "key", and "value", but this is
+        //   not enforced.
+        *out = 
std::make_shared<MapType>(children[0]->type()->field(0)->WithName("key"),
+                                         
children[0]->type()->field(1)->WithName("value"),
+                                         map->keysSorted());
       }
       return Status::OK();
     case flatbuf::Type::Type_FixedSizeList:

Reply via email to