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 6c9f542a0a GH-48423: [Ruby] Add support for reading date64 array
(#48424)
6c9f542a0a is described below
commit 6c9f542a0ac9bf41c1043f84aace8bd6f30696bd
Author: Sutou Kouhei <[email protected]>
AuthorDate: Thu Dec 11 07:06:13 2025 +0900
GH-48423: [Ruby] Add support for reading date64 array (#48424)
### Rationale for this change
It's a millisecond variant of date array.
### What changes are included in this PR?
* Add `ArrowFormat::Date64Type`
* Add `ArrowFormat::Date64Array`
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
* GitHub Issue: #48423
Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
ruby/red-arrow-format/lib/arrow-format/array.rb | 6 +++++
.../lib/arrow-format/file-reader.rb | 2 ++
ruby/red-arrow-format/lib/arrow-format/type.rb | 16 ++++++++++++
ruby/red-arrow-format/test/test-file-reader.rb | 29 ++++++++++++++++++++++
4 files changed, 53 insertions(+)
diff --git a/ruby/red-arrow-format/lib/arrow-format/array.rb
b/ruby/red-arrow-format/lib/arrow-format/array.rb
index e6fcef5705..fac39c609a 100644
--- a/ruby/red-arrow-format/lib/arrow-format/array.rb
+++ b/ruby/red-arrow-format/lib/arrow-format/array.rb
@@ -123,6 +123,12 @@ module ArrowFormat
end
end
+ class Date64Array < DateArray
+ def to_a
+ apply_validity(@values_buffer.values(:s64, 0, @size))
+ end
+ end
+
class VariableSizeBinaryLayoutArray < Array
def initialize(type, size, validity_buffer, offsets_buffer, values_buffer)
super(type, size, validity_buffer)
diff --git a/ruby/red-arrow-format/lib/arrow-format/file-reader.rb
b/ruby/red-arrow-format/lib/arrow-format/file-reader.rb
index 2070d0f7fb..4a46382685 100644
--- a/ruby/red-arrow-format/lib/arrow-format/file-reader.rb
+++ b/ruby/red-arrow-format/lib/arrow-format/file-reader.rb
@@ -166,6 +166,8 @@ module ArrowFormat
case fb_type.unit
when Org::Apache::Arrow::Flatbuf::DateUnit::DAY
type = Date32Type.singleton
+ when Org::Apache::Arrow::Flatbuf::DateUnit::MILLISECOND
+ type = Date64Type.singleton
end
when Org::Apache::Arrow::Flatbuf::List
type = ListType.new(read_field(fb_field.children[0]))
diff --git a/ruby/red-arrow-format/lib/arrow-format/type.rb
b/ruby/red-arrow-format/lib/arrow-format/type.rb
index 8580ef8343..5516a5807f 100644
--- a/ruby/red-arrow-format/lib/arrow-format/type.rb
+++ b/ruby/red-arrow-format/lib/arrow-format/type.rb
@@ -158,6 +158,22 @@ module ArrowFormat
end
end
+ class Date64Type < DateType
+ class << self
+ def singleton
+ @singleton ||= new
+ end
+ end
+
+ def initialize
+ super("Date64")
+ end
+
+ def build_array(size, validity_buffer, values_buffer)
+ Date64Array.new(self, size, validity_buffer, values_buffer)
+ end
+ end
+
class VariableSizeBinaryType < Type
end
diff --git a/ruby/red-arrow-format/test/test-file-reader.rb
b/ruby/red-arrow-format/test/test-file-reader.rb
index ba7a351d22..72b818314b 100644
--- a/ruby/red-arrow-format/test/test-file-reader.rb
+++ b/ruby/red-arrow-format/test/test-file-reader.rb
@@ -123,6 +123,35 @@ class TestFileReader < Test::Unit::TestCase
end
end
+ sub_test_case("Date64") do
+ def setup(&block)
+ @date_2017_08_28_00_00_00 = 1503878400000
+ @date_2025_12_09_00_00_00 = 1765324800000
+ super(&block)
+ end
+
+ def build_array
+ Arrow::Date64Array.new([
+ @date_2017_08_28_00_00_00,
+ nil,
+ @date_2025_12_09_00_00_00,
+ ])
+ end
+
+ def test_read
+ assert_equal([
+ {
+ "value" => [
+ @date_2017_08_28_00_00_00,
+ nil,
+ @date_2025_12_09_00_00_00,
+ ],
+ },
+ ],
+ read)
+ end
+ end
+
sub_test_case("Binary") do
def build_array
Arrow::BinaryArray.new(["Hello".b, nil, "World".b])