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 b29b786ed3 GH-48916: [Ruby] Add support for writing binary array
(#48917)
b29b786ed3 is described below
commit b29b786ed3d770a9d9765ee6b1ed221e887e9093
Author: Sutou Kouhei <[email protected]>
AuthorDate: Thu Jan 22 10:21:02 2026 +0900
GH-48916: [Ruby] Add support for writing binary array (#48917)
### Rationale for this change
It's a variable size binary layout array.
### What changes are included in this PR?
* Add `ArrowFormat::BinaryType#to_flatbuffers`
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
* GitHub Issue: #48916
Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
ruby/red-arrow-format/lib/arrow-format/type.rb | 10 +++++++++-
ruby/red-arrow-format/test/test-writer.rb | 18 ++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/ruby/red-arrow-format/lib/arrow-format/type.rb
b/ruby/red-arrow-format/lib/arrow-format/type.rb
index 109d944254..4e70dedbf7 100644
--- a/ruby/red-arrow-format/lib/arrow-format/type.rb
+++ b/ruby/red-arrow-format/lib/arrow-format/type.rb
@@ -482,7 +482,15 @@ module ArrowFormat
end
def build_array(size, validity_buffer, offsets_buffer, values_buffer)
- BinaryArray.new(self, size, validity_buffer, offsets_buffer,
values_buffer)
+ BinaryArray.new(self,
+ size,
+ validity_buffer,
+ offsets_buffer,
+ values_buffer)
+ end
+
+ def to_flatbuffers
+ FB::Binary::Data.new
end
end
diff --git a/ruby/red-arrow-format/test/test-writer.rb
b/ruby/red-arrow-format/test/test-writer.rb
index f2313e64a7..240aab7a7f 100644
--- a/ruby/red-arrow-format/test/test-writer.rb
+++ b/ruby/red-arrow-format/test/test-writer.rb
@@ -26,6 +26,8 @@ module WriterTests
ArrowFormat::Int8Type.singleton
when Arrow::UInt8DataType
ArrowFormat::UInt8Type.singleton
+ when Arrow::BinaryDataType
+ ArrowFormat::BinaryType.singleton
else
raise "Unsupported type: #{red_arrow_type.inspect}"
end
@@ -45,6 +47,11 @@ module WriterTests
type.build_array(red_arrow_array.size,
convert_buffer(red_arrow_array.null_bitmap),
convert_buffer(red_arrow_array.data_buffer))
+ when ArrowFormat::VariableSizeBinaryType
+ type.build_array(red_arrow_array.size,
+ convert_buffer(red_arrow_array.null_bitmap),
+ convert_buffer(red_arrow_array.offsets_buffer),
+ convert_buffer(red_arrow_array.data_buffer))
else
raise "Unsupported array #{red_arrow_array.inspect}"
end
@@ -96,6 +103,17 @@ module WriterTests
@values)
end
end
+
+ sub_test_case("Binary") do
+ def build_array
+ Arrow::BinaryArray.new(["Hello".b, nil, "World".b])
+ end
+
+ def test_write
+ assert_equal(["Hello".b, nil, "World".b],
+ @values)
+ end
+ end
end
end
end