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

kou 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 db349f16f7 GH-49119: [Ruby] Add support for writing map array (#49120)
db349f16f7 is described below

commit db349f16f778f25746f62fe107dcc32d43448a14
Author: Sutou Kouhei <[email protected]>
AuthorDate: Tue Feb 3 20:21:10 2026 +0900

    GH-49119: [Ruby] Add support for writing map array (#49120)
    
    ### Rationale for this change
    
    It's a list based array.
    
    ### What changes are included in this PR?
    
    * Add `ArrowFormat::MapType#to_flatbuffers`
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    Yes.
    * GitHub Issue: #49119
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 ruby/red-arrow-format/lib/arrow-format/type.rb |  4 ++++
 ruby/red-arrow-format/test/test-writer.rb      | 23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/ruby/red-arrow-format/lib/arrow-format/type.rb 
b/ruby/red-arrow-format/lib/arrow-format/type.rb
index 65353f26ab..808117740e 100644
--- a/ruby/red-arrow-format/lib/arrow-format/type.rb
+++ b/ruby/red-arrow-format/lib/arrow-format/type.rb
@@ -791,6 +791,10 @@ module ArrowFormat
     def build_array(size, validity_buffer, offsets_buffer, child)
       MapArray.new(self, size, validity_buffer, offsets_buffer, child)
     end
+
+    def to_flatbuffers
+      FB::Map::Data.new
+    end
   end
 
   class UnionType < Type
diff --git a/ruby/red-arrow-format/test/test-writer.rb 
b/ruby/red-arrow-format/test/test-writer.rb
index 7be4c162db..183a5f29dd 100644
--- a/ruby/red-arrow-format/test/test-writer.rb
+++ b/ruby/red-arrow-format/test/test-writer.rb
@@ -85,6 +85,8 @@ module WriterTests
                                       red_arrow_type.scale)
     when Arrow::FixedSizeBinaryDataType
       ArrowFormat::FixedSizeBinaryType.new(red_arrow_type.byte_width)
+    when Arrow::MapDataType
+      ArrowFormat::MapType.new(convert_field(red_arrow_type.field))
     when Arrow::ListDataType
       ArrowFormat::ListType.new(convert_field(red_arrow_type.field))
     when Arrow::LargeListDataType
@@ -851,6 +853,27 @@ module WriterTests
           end
         end
 
+        sub_test_case("Map") do
+          def build_array
+            data_type = Arrow::MapDataType.new(:string, :int8)
+            Arrow::MapArray.new(data_type,
+                                [
+                                  {"a" => -128, "b" => 127},
+                                  nil,
+                                  {"c" => nil},
+                                ])
+          end
+
+          def test_write
+            assert_equal([
+                           {"a" => -128, "b" => 127},
+                           nil,
+                           {"c" => nil},
+                         ],
+                         @values)
+          end
+        end
+
         sub_test_case("Struct") do
           def build_array
             data_type = Arrow::StructDataType.new(count: :int8,

Reply via email to