Skip to content

Commit 8ca883f

Browse files
authored
GH-48292: [Ruby] Add Arrow::Column#to_arrow{,_array,_chunked_array} (#48293)
### Rationale for this change If they exist, we can use `Arrow::Column` as `Arrow::Array`/`Arrow::ChunkedArray`. It's convenient. ### What changes are included in this PR? * Add `Arrow::Column#to_arrow` * Add `Arrow::Column#to_arrow_array` * Add `Arrow::Column#to_arrow_chunked_array` ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * GitHub Issue: #48292 Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 16712af commit 8ca883f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ruby/red-arrow/lib/arrow/column.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ def initialize(container, index)
3030
@container.share_input(@data)
3131
end
3232

33+
def to_arrow
34+
@data
35+
end
36+
37+
def to_arrow_array
38+
@data.to_arrow_array
39+
end
40+
41+
def to_arrow_chunked_array
42+
@data.to_arrow_chunked_array
43+
end
44+
3345
def name
3446
@field.name
3547
end

ruby/red-arrow/test/test-column.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ def setup
2121
@column = table.visible
2222
end
2323

24+
test("#to_arrow") do
25+
assert_equal(@column.data, @column.to_arrow)
26+
end
27+
28+
test("#to_arrow_array") do
29+
assert_equal(@column.data.chunks[0], @column.to_arrow_chunked_array)
30+
end
31+
32+
test("#to_arrow_chunked_array") do
33+
assert_equal(@column.data, @column.to_arrow_chunked_array)
34+
end
35+
2436
test("#name") do
2537
assert_equal("visible", @column.name)
2638
end

0 commit comments

Comments
 (0)