From 2ae8b5a43a28b38490885a4b6b65be644e53d499 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 22 Jul 2026 13:50:48 +0900 Subject: [PATCH] GH-50572: [Ruby] Add `ArrowFormat::RecordBatch#records` --- .../lib/arrow-format/field.rb | 4 +- .../lib/arrow-format/record-batch.rb | 58 +++++++++++-- .../lib/arrow-format/record.rb | 60 ++++++++++++++ .../lib/arrow-format/schema.rb | 25 ++++++ .../test/test-binary-array.rb | 2 +- .../test/test-boolean-array.rb | 2 +- .../test/test-date32-array.rb | 2 +- .../test/test-date64-array.rb | 2 +- .../test/test-day-time-interval-array.rb | 2 +- .../test/test-duration-array.rb | 2 +- .../test/test-float32-array.rb | 2 +- .../test/test-float64-array.rb | 2 +- .../red-arrow-format/test/test-int16-array.rb | 2 +- .../red-arrow-format/test/test-int32-array.rb | 2 +- .../red-arrow-format/test/test-int64-array.rb | 2 +- ruby/red-arrow-format/test/test-int8-array.rb | 2 +- .../test/test-large-binary-array.rb | 2 +- .../test/test-large-utf8-array.rb | 2 +- .../test-month-day-nano-interval-array.rb | 2 +- .../test/test-record-batch.rb | 71 ++++++++++++++-- ruby/red-arrow-format/test/test-record.rb | 82 +++++++++++++++++++ .../test/test-time32-array.rb | 2 +- .../test/test-time64-array.rb | 2 +- .../test/test-timestamp-array.rb | 2 +- .../test/test-uint16-array.rb | 2 +- .../test/test-uint32-array.rb | 2 +- .../test/test-uint64-array.rb | 2 +- .../red-arrow-format/test/test-uint8-array.rb | 2 +- ruby/red-arrow-format/test/test-utf8-array.rb | 2 +- .../test/test-year-month-interval-array.rb | 2 +- 30 files changed, 309 insertions(+), 39 deletions(-) create mode 100644 ruby/red-arrow-format/lib/arrow-format/record.rb create mode 100644 ruby/red-arrow-format/test/test-record.rb diff --git a/ruby/red-arrow-format/lib/arrow-format/field.rb b/ruby/red-arrow-format/lib/arrow-format/field.rb index b7e3ce4b5a50..0dce7f04cb01 100644 --- a/ruby/red-arrow-format/lib/arrow-format/field.rb +++ b/ruby/red-arrow-format/lib/arrow-format/field.rb @@ -1,3 +1,4 @@ +# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file @@ -23,7 +24,8 @@ def initialize(name, type, nullable: true, metadata: nil) - @name = name + name = name.to_s if name.is_a?(Symbol) + @name = name.to_str @type = type @nullable = nullable @metadata = metadata diff --git a/ruby/red-arrow-format/lib/arrow-format/record-batch.rb b/ruby/red-arrow-format/lib/arrow-format/record-batch.rb index 46d39a98e839..db2b2dbe8fca 100644 --- a/ruby/red-arrow-format/lib/arrow-format/record-batch.rb +++ b/ruby/red-arrow-format/lib/arrow-format/record-batch.rb @@ -1,3 +1,4 @@ +# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file @@ -15,6 +16,7 @@ # under the License. require_relative "buffer-alignable" +require_relative "record" module ArrowFormat class RecordBatch @@ -44,12 +46,43 @@ def empty? @n_rows.zero? end - def to_h - hash = {} - @schema.fields.zip(@columns) do |field, column| - hash[field.name] = column + def find_column(name_or_index) + case name_or_index + when Integer + @columns[name_or_index] + when Symbol + name_to_column[name_or_index.to_s] + else + name_to_column[name_or_index.to_str] end - hash + end + + def each_record(reuse_record: false) + unless block_given? + return to_enum(__method__, reuse_record: reuse_record) + end + + if reuse_record + record = Record.new(self, nil) + @n_rows.times do |i| + record.index = i + yield(record) + end + else + @n_rows.times do |i| + yield(Record.new(self, i)) + end + end + end + + def records + size.times.collect do |i| + Record.new(self, i) + end + end + + def to_h + name_to_column.dup end def to_flatbuffers @@ -158,7 +191,20 @@ def build(data) raise ArgumentError, message end - return Schema.new(fields), n_rows, columns + return Schema.new(fields), all_n_rows[0], columns + end + + def name_to_column + @name_to_column ||= build_name_to_column + end + + def build_name_to_column + name_to_column = {} + @schema.fields.zip(@columns) do |field, column| + name_to_column[field.name] = column + end + name_to_column.freeze + name_to_column end end end diff --git a/ruby/red-arrow-format/lib/arrow-format/record.rb b/ruby/red-arrow-format/lib/arrow-format/record.rb new file mode 100644 index 000000000000..957179e85b8d --- /dev/null +++ b/ruby/red-arrow-format/lib/arrow-format/record.rb @@ -0,0 +1,60 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +module ArrowFormat + class Record + attr_reader :record_batch + attr_accessor :index + def initialize(record_batch, index) + @record_batch = record_batch + @index = index + end + + def [](name_or_index) + column = @record_batch.find_column(name_or_index) + return nil if column.nil? + column[@index] + end + + def to_a + @record_batch.columns.collect do |column| + column[@index] + end + end + + def to_h + attributes = {} + @record_batch.schema.fields.zip(@record_batch.columns) do |field, column| + attributes[field.name] = column[@index] + end + attributes + end + + def respond_to_missing?(name, include_private) + return true if @record_batch.find_column(name) + super + end + + def method_missing(name, *args, &block) + if args.empty? + column = @record_batch.find_column(name) + return column[@index] if column + end + super + end + end +end diff --git a/ruby/red-arrow-format/lib/arrow-format/schema.rb b/ruby/red-arrow-format/lib/arrow-format/schema.rb index eb054ad546f3..250dc0571c56 100644 --- a/ruby/red-arrow-format/lib/arrow-format/schema.rb +++ b/ruby/red-arrow-format/lib/arrow-format/schema.rb @@ -1,3 +1,4 @@ +# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file @@ -25,6 +26,17 @@ def initialize(fields, metadata: nil, message_metadata: nil) @message_metadata = message_metadata end + def [](name_or_index) + case name_or_index + when Integer + @fields[name_or_index] + when Symbol + name_to_field[name_or_index.to_s] + else + name_to_field[name_or_index.to_str] + end + end + def to_flatbuffers fb_schema = FB::Schema::Data.new fb_schema.endianness = FB::Endianness::LITTLE @@ -33,5 +45,18 @@ def to_flatbuffers # fb_schema.features = @features fb_schema end + + private + def name_to_field + @name_to_field ||= build_name_to_field + end + + def build_name_to_field + name_to_field = {} + @fields.each do |field| + name_to_field[field.name] = field + end + name_to_field + end end end diff --git a/ruby/red-arrow-format/test/test-binary-array.rb b/ruby/red-arrow-format/test/test-binary-array.rb index 78783b7996b7..76ad4832d846 100644 --- a/ruby/red-arrow-format/test/test-binary-array.rb +++ b/ruby/red-arrow-format/test/test-binary-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-boolean-array.rb b/ruby/red-arrow-format/test/test-boolean-array.rb index d5357b081ca9..8490c1577474 100644 --- a/ruby/red-arrow-format/test/test-boolean-array.rb +++ b/ruby/red-arrow-format/test/test-boolean-array.rb @@ -61,7 +61,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-date32-array.rb b/ruby/red-arrow-format/test/test-date32-array.rb index ef98b8d902f7..331daabd833a 100644 --- a/ruby/red-arrow-format/test/test-date32-array.rb +++ b/ruby/red-arrow-format/test/test-date32-array.rb @@ -62,7 +62,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-date64-array.rb b/ruby/red-arrow-format/test/test-date64-array.rb index 167911fe1cd3..867bf296e221 100644 --- a/ruby/red-arrow-format/test/test-date64-array.rb +++ b/ruby/red-arrow-format/test/test-date64-array.rb @@ -62,7 +62,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-day-time-interval-array.rb b/ruby/red-arrow-format/test/test-day-time-interval-array.rb index b7151190cda4..a849926c9b97 100644 --- a/ruby/red-arrow-format/test/test-day-time-interval-array.rb +++ b/ruby/red-arrow-format/test/test-day-time-interval-array.rb @@ -97,7 +97,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-duration-array.rb b/ruby/red-arrow-format/test/test-duration-array.rb index 24d0bd98a0b8..498148bb11be 100644 --- a/ruby/red-arrow-format/test/test-duration-array.rb +++ b/ruby/red-arrow-format/test/test-duration-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-float32-array.rb b/ruby/red-arrow-format/test/test-float32-array.rb index 243c46b23507..6e659e98159a 100644 --- a/ruby/red-arrow-format/test/test-float32-array.rb +++ b/ruby/red-arrow-format/test/test-float32-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-float64-array.rb b/ruby/red-arrow-format/test/test-float64-array.rb index 92099f1cd06d..1086b06a16d0 100644 --- a/ruby/red-arrow-format/test/test-float64-array.rb +++ b/ruby/red-arrow-format/test/test-float64-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-int16-array.rb b/ruby/red-arrow-format/test/test-int16-array.rb index ddfdcc5ddc53..901a597e17c0 100644 --- a/ruby/red-arrow-format/test/test-int16-array.rb +++ b/ruby/red-arrow-format/test/test-int16-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-int32-array.rb b/ruby/red-arrow-format/test/test-int32-array.rb index 9940a323f452..23f4ab39470e 100644 --- a/ruby/red-arrow-format/test/test-int32-array.rb +++ b/ruby/red-arrow-format/test/test-int32-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-int64-array.rb b/ruby/red-arrow-format/test/test-int64-array.rb index b5db1d163c79..a431fd3f9391 100644 --- a/ruby/red-arrow-format/test/test-int64-array.rb +++ b/ruby/red-arrow-format/test/test-int64-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-int8-array.rb b/ruby/red-arrow-format/test/test-int8-array.rb index 459674f9fd20..d42b011bbb80 100644 --- a/ruby/red-arrow-format/test/test-int8-array.rb +++ b/ruby/red-arrow-format/test/test-int8-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-large-binary-array.rb b/ruby/red-arrow-format/test/test-large-binary-array.rb index 0fc7a1132808..95546eaec978 100644 --- a/ruby/red-arrow-format/test/test-large-binary-array.rb +++ b/ruby/red-arrow-format/test/test-large-binary-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-large-utf8-array.rb b/ruby/red-arrow-format/test/test-large-utf8-array.rb index 084f3b5ff9a0..8f5cd0a89818 100644 --- a/ruby/red-arrow-format/test/test-large-utf8-array.rb +++ b/ruby/red-arrow-format/test/test-large-utf8-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-month-day-nano-interval-array.rb b/ruby/red-arrow-format/test/test-month-day-nano-interval-array.rb index 26842d930246..f9805e921f8d 100644 --- a/ruby/red-arrow-format/test/test-month-day-nano-interval-array.rb +++ b/ruby/red-arrow-format/test/test-month-day-nano-interval-array.rb @@ -102,7 +102,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-record-batch.rb b/ruby/red-arrow-format/test/test-record-batch.rb index 61e907e3a5c1..30bd79fc35af 100644 --- a/ruby/red-arrow-format/test/test-record-batch.rb +++ b/ruby/red-arrow-format/test/test-record-batch.rb @@ -16,12 +16,16 @@ # under the License. class TestRecordBatch < Test::Unit::TestCase - sub_test_case("#initialize") do - def setup - @boolean_array = ArrowFormat::BooleanArray.new([true, nil, false]) - @int32_array = ArrowFormat::Int32Array.new([-(2 ** 31), 0, (2 ** 31) - 1]) - end + def setup + @boolean_array = ArrowFormat::BooleanArray.new([true, nil, false]) + @int32_array = ArrowFormat::Int32Array.new([-(2 ** 31), 0, (2 ** 31) - 1]) + @record_batch = ArrowFormat::RecordBatch.new({ + boolean: @boolean_array, + int32: @int32_array, + }) + end + sub_test_case("#initialize") do test("{}") do error = ArgumentError.new("no data") assert_raise(error) do @@ -35,7 +39,11 @@ def setup int32: @int32_array, } record_batch = ArrowFormat::RecordBatch.new(raw_records) - assert_equal(raw_records, record_batch.to_h) + assert_equal({ + "boolean" => @boolean_array, + "int32" => @int32_array, + }, + record_batch.to_h) end test("{String => Array}") do @@ -55,8 +63,8 @@ def setup ] record_batch = ArrowFormat::RecordBatch.new(raw_records) assert_equal({ - boolean: @boolean_array, - int32: @int32_array, + "boolean" => @boolean_array, + "int32" => @int32_array, }, record_batch.to_h) end @@ -72,4 +80,51 @@ def setup end end end + + sub_test_case("#find_column") do + test("Integer") do + assert_equal(@int32_array, @record_batch.find_column(1)) + end + + test("String") do + assert_equal(@int32_array, @record_batch.find_column("int32")) + end + + test("Symbol") do + assert_equal(@int32_array, @record_batch.find_column(:int32)) + end + end + + sub_test_case("#each_record") do + test("default") do + assert_equal([ + [true, -(2 ** 31)], + [nil, 0], + [false, (2 ** 31) - 1], + ], + @record_batch.each_record.collect(&:to_a)) + end + + test(":reuse_record") do + actual = [] + @record_batch.each_record(reuse_record: true) do |record| + actual << [record.object_id, record.index] + end + assert_equal([ + [actual[0][0], 0], + [actual[0][0], 1], + [actual[0][0], 2], + ], + actual) + end + end + + test("#records") do + assert_equal([ + {"boolean" => true, "int32" => -(2 ** 31)}, + {"boolean" => nil, "int32" => 0}, + {"boolean" => false, "int32" => (2 ** 31) - 1}, + ], + @record_batch.records.collect(&:to_h)) + end end diff --git a/ruby/red-arrow-format/test/test-record.rb b/ruby/red-arrow-format/test/test-record.rb new file mode 100644 index 000000000000..9583f6b7f865 --- /dev/null +++ b/ruby/red-arrow-format/test/test-record.rb @@ -0,0 +1,82 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +class TestRecord < Test::Unit::TestCase + def setup + @boolean_array = ArrowFormat::BooleanArray.new([true, nil, false]) + @int32_array = ArrowFormat::Int32Array.new([-(2 ** 31), 0, (2 ** 31) - 1]) + @record_batch = ArrowFormat::RecordBatch.new({ + boolean: @boolean_array, + int32: @int32_array, + }) + @record = @record_batch.records[1] + end + + sub_test_case("#[]") do + test("Integer") do + assert_equal(0, @record[1]) + end + + test("String") do + assert_equal(0, @record["int32"]) + end + + test("Symbol") do + assert_equal(0, @record[:int32]) + end + end + + def test_to_a + assert_equal([nil, 0], @record.to_a) + end + + def test_to_h + assert_equal({"boolean" => nil, "int32" => 0}, @record.to_h) + end + + sub_test_case("#respond_to_missing?") do + def test_existent + assert do + @record.respond_to?("int32") + end + end + + def test_nonexistent + assert do + not @record.respond_to?("nonexistent") + end + end + end + + sub_test_case("#method_missing") do + def test_existent + assert_equal(0, @record.int32) + end + + def test_existent_have_argument + assert_raise(NoMethodError) do + @record.int32(nil) + end + end + + def test_nonexitent + assert_raise(NoMethodError) do + @record.nonexistent + end + end + end +end diff --git a/ruby/red-arrow-format/test/test-time32-array.rb b/ruby/red-arrow-format/test/test-time32-array.rb index 74a01dc6d75e..3501855c88ec 100644 --- a/ruby/red-arrow-format/test/test-time32-array.rb +++ b/ruby/red-arrow-format/test/test-time32-array.rb @@ -62,7 +62,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-time64-array.rb b/ruby/red-arrow-format/test/test-time64-array.rb index dd7a08ad2fd3..76b93b64aeac 100644 --- a/ruby/red-arrow-format/test/test-time64-array.rb +++ b/ruby/red-arrow-format/test/test-time64-array.rb @@ -62,7 +62,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-timestamp-array.rb b/ruby/red-arrow-format/test/test-timestamp-array.rb index c2f73e366c07..cd2061afc9fa 100644 --- a/ruby/red-arrow-format/test/test-timestamp-array.rb +++ b/ruby/red-arrow-format/test/test-timestamp-array.rb @@ -92,7 +92,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-uint16-array.rb b/ruby/red-arrow-format/test/test-uint16-array.rb index 3c5ad6aceab5..49bbc08d1586 100644 --- a/ruby/red-arrow-format/test/test-uint16-array.rb +++ b/ruby/red-arrow-format/test/test-uint16-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-uint32-array.rb b/ruby/red-arrow-format/test/test-uint32-array.rb index 079a96cbf59b..746e39b03488 100644 --- a/ruby/red-arrow-format/test/test-uint32-array.rb +++ b/ruby/red-arrow-format/test/test-uint32-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-uint64-array.rb b/ruby/red-arrow-format/test/test-uint64-array.rb index c43808273577..2c91be15b957 100644 --- a/ruby/red-arrow-format/test/test-uint64-array.rb +++ b/ruby/red-arrow-format/test/test-uint64-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-uint8-array.rb b/ruby/red-arrow-format/test/test-uint8-array.rb index bd03aa0efbc9..7ab6b0d8c034 100644 --- a/ruby/red-arrow-format/test/test-uint8-array.rb +++ b/ruby/red-arrow-format/test/test-uint8-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-utf8-array.rb b/ruby/red-arrow-format/test/test-utf8-array.rb index eb6e669e2e5a..b55b470f6913 100644 --- a/ruby/red-arrow-format/test/test-utf8-array.rb +++ b/ruby/red-arrow-format/test/test-utf8-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null diff --git a/ruby/red-arrow-format/test/test-year-month-interval-array.rb b/ruby/red-arrow-format/test/test-year-month-interval-array.rb index 29bd61a1ef6c..2c48ac246737 100644 --- a/ruby/red-arrow-format/test/test-year-month-interval-array.rb +++ b/ruby/red-arrow-format/test/test-year-month-interval-array.rb @@ -60,7 +60,7 @@ def test_sliced_different_content sub_test_case("#[]") do def test_valid - assert_equal(@values[3], @array[3]) + assert_equal(@values[2], @array[2]) end def test_null