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 adfc5f4562 GH-45897: [Ruby] Unify test for table in raw_records and 
each_raw_record (#45977)
adfc5f4562 is described below

commit adfc5f4562823af8f412f0e02fb7b74936bcf090
Author: takuya kodama <[email protected]>
AuthorDate: Tue Apr 1 09:26:13 2025 +0800

    GH-45897: [Ruby] Unify test for table in raw_records and each_raw_record 
(#45977)
    
    ### Rationale for this change
    
    The PR reduces duplicated test cases and ensures that both `raw_records` 
and `each_raw_record` behave consistently by extracting their common test cases.
    - `Arrow::Table#each_raw_record`
    - `Arrow::Table#raw_records`
    
    ### What changes are included in this PR?
    
    We extracted shared test cases about tables used by both `raw_records` and 
`each_raw_record`.
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    No.
    
    * GitHub Issue: #45897
    
    Authored-by: otegami <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 ruby/red-arrow/test/each-raw-record/test-table.rb | 47 -----------------------
 ruby/red-arrow/test/raw-records/test-table.rb     | 22 +++++++++--
 2 files changed, 19 insertions(+), 50 deletions(-)

diff --git a/ruby/red-arrow/test/each-raw-record/test-table.rb 
b/ruby/red-arrow/test/each-raw-record/test-table.rb
deleted file mode 100644
index 96dbe57638..0000000000
--- a/ruby/red-arrow/test/each-raw-record/test-table.rb
+++ /dev/null
@@ -1,47 +0,0 @@
-# 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 EachRawRecordTableTest < Test::Unit::TestCase
-  test("2 arrays") do
-    raw_record_batches = [
-      [
-        [true, nil, "Ruby"],
-        [nil, 0, "GLib"],
-        [false, 2 ** 8 - 1, nil],
-      ],
-      [
-        [nil, 10, "A"],
-        [true, 20, "B"],
-        [false, nil, "C"],
-        [nil, 40, nil],
-      ]
-    ]
-    raw_records = raw_record_batches.inject do |all_records, record_batch|
-      all_records + record_batch
-    end
-    schema = [
-      {name: :column0, type: :boolean},
-      {name: :column1, type: :uint8},
-      {name: :column2, type: :string},
-    ]
-    record_batches = raw_record_batches.collect do |record_batch|
-      Arrow::RecordBatch.new(schema, record_batch)
-    end
-    table = Arrow::Table.new(schema, record_batches)
-    assert_equal(raw_records, table.each_raw_record.to_a)
-  end
-end
diff --git a/ruby/red-arrow/test/raw-records/test-table.rb 
b/ruby/red-arrow/test/raw-records/test-table.rb
index ae90217c29..7fc8e3517f 100644
--- a/ruby/red-arrow/test/raw-records/test-table.rb
+++ b/ruby/red-arrow/test/raw-records/test-table.rb
@@ -15,8 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 
-class RawRecordsTableTest < Test::Unit::TestCase
-  test("2 arrays") do
+module RawRecordsTableTests
+  def test_2_arrays
     raw_record_batches = [
       [
         [true, nil, "Ruby"],
@@ -42,6 +42,22 @@ class RawRecordsTableTest < Test::Unit::TestCase
       Arrow::RecordBatch.new(schema, record_batch)
     end
     table = Arrow::Table.new(schema, record_batches)
-    assert_equal(raw_records, table.raw_records)
+    assert_equal(raw_records, actual_records(table))
+  end
+end
+
+class EachRawRecordTableTest < Test::Unit::TestCase
+  include RawRecordsTableTests
+
+  def actual_records(target)
+    target.each_raw_record.to_a
+  end
+end
+
+class RawRecordsTableTest < Test::Unit::TestCase
+  include RawRecordsTableTests
+
+  def actual_records(target)
+    target.raw_records
   end
 end

Reply via email to