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 71c4b88352 GH-45119: [Ruby] Use #size for Arrow::Column#size backend
(#45133)
71c4b88352 is described below
commit 71c4b88352096ca48b9798c802c288b4990900a7
Author: Sutou Kouhei <[email protected]>
AuthorDate: Tue Dec 31 15:47:36 2024 +0900
GH-45119: [Ruby] Use #size for Arrow::Column#size backend (#45133)
### Rationale for this change
`#n_rows` is available only on `Arrow::ChunkedArray`. It's not available on
`Arrow::Array`.
### What changes are included in this PR?
It's available on both of `Arrow::Array` and `Arrow::ChunkedArray`.
### Are these changes tested?
Yes.
### Are there any user-facing changes?
Yes.
* GitHub Issue: #45119
Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
ruby/red-arrow/lib/arrow/column.rb | 8 ++++----
ruby/red-arrow/test/test-column.rb | 8 ++++++++
ruby/red-arrow/test/test-record-batch.rb | 6 ++++++
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/ruby/red-arrow/lib/arrow/column.rb
b/ruby/red-arrow/lib/arrow/column.rb
index ba575381ee..a1de0d6128 100644
--- a/ruby/red-arrow/lib/arrow/column.rb
+++ b/ruby/red-arrow/lib/arrow/column.rb
@@ -58,11 +58,11 @@ module Arrow
@data.reverse_each(&block)
end
- def n_rows
- @data.n_rows
+ def size
+ @data.size
end
- alias_method :size, :n_rows
- alias_method :length, :n_rows
+ alias_method :length, :size
+ alias_method :n_rows, :size
def n_nulls
@data.n_nulls
diff --git a/ruby/red-arrow/test/test-column.rb
b/ruby/red-arrow/test/test-column.rb
index f78377e363..c3a6ee0f4d 100644
--- a/ruby/red-arrow/test/test-column.rb
+++ b/ruby/red-arrow/test/test-column.rb
@@ -49,6 +49,14 @@ class ColumnTest < Test::Unit::TestCase
assert_equal([false, nil, true], @column.reverse_each.to_a)
end
+ test("#size") do
+ assert_equal(3, @column.size)
+ end
+
+ test("#length") do
+ assert_equal(3, @column.length)
+ end
+
test("#n_rows") do
assert_equal(3, @column.n_rows)
end
diff --git a/ruby/red-arrow/test/test-record-batch.rb
b/ruby/red-arrow/test/test-record-batch.rb
index e94c26f2e3..fec640343c 100644
--- a/ruby/red-arrow/test/test-record-batch.rb
+++ b/ruby/red-arrow/test/test-record-batch.rb
@@ -178,5 +178,11 @@ class RecordBatchTest < Test::Unit::TestCase
@record_batch[[:c, "a", -1, 3..4]])
end
end
+
+ sub_test_case("#column") do
+ test("#size") do
+ assert_equal(@counts.size, @record_batch[:count].size)
+ end
+ end
end
end