This is an automated email from the ASF dual-hosted git repository.
shiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new a3aed3b ARROW-4184: [Ruby] Add Arrow::RecordBatch#to_table
a3aed3b is described below
commit a3aed3b60bd61c55d7402c4484e480f1998b99f1
Author: Kouhei Sutou <[email protected]>
AuthorDate: Wed Jan 9 09:17:46 2019 +0900
ARROW-4184: [Ruby] Add Arrow::RecordBatch#to_table
Author: Kouhei Sutou <[email protected]>
Closes #3339 from kou/ruby-record-batch-to-table and squashes the following
commits:
a6fab35f <Kouhei Sutou> Require gobject-introspection gem 3.3.1 or later
4a1f3564 <Kouhei Sutou> Add Arrow::RecordBatch#to_table
---
ruby/red-arrow/lib/arrow/record-batch.rb | 9 +++++++++
ruby/red-arrow/red-arrow.gemspec | 2 +-
ruby/red-arrow/test/test-record-batch.rb | 23 ++++++++++++++---------
3 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/ruby/red-arrow/lib/arrow/record-batch.rb
b/ruby/red-arrow/lib/arrow/record-batch.rb
index f5f8ea2..6d9c35b 100644
--- a/ruby/red-arrow/lib/arrow/record-batch.rb
+++ b/ruby/red-arrow/lib/arrow/record-batch.rb
@@ -29,6 +29,15 @@ module Arrow
@columns ||= columns_raw
end
+ # Converts the record batch to {Arrow::Table}.
+ #
+ # @return [Arrow::Table]
+ #
+ # @since 0.12.0
+ def to_table
+ Table.new(schema, [self])
+ end
+
def respond_to_missing?(name, include_private)
return true if find_column(name)
super
diff --git a/ruby/red-arrow/red-arrow.gemspec b/ruby/red-arrow/red-arrow.gemspec
index 8e79c75..2d417f0 100644
--- a/ruby/red-arrow/red-arrow.gemspec
+++ b/ruby/red-arrow/red-arrow.gemspec
@@ -45,7 +45,7 @@ Gem::Specification.new do |spec|
spec.test_files += Dir.glob("test/**/*")
spec.extensions = ["dependency-check/Rakefile"]
- spec.add_runtime_dependency("gobject-introspection", ">= 3.1.1")
+ spec.add_runtime_dependency("gobject-introspection", ">= 3.3.1")
spec.add_runtime_dependency("pkg-config")
spec.add_runtime_dependency("native-package-installer")
diff --git a/ruby/red-arrow/test/test-record-batch.rb
b/ruby/red-arrow/test/test-record-batch.rb
index 994b16d..4dac085 100644
--- a/ruby/red-arrow/test/test-record-batch.rb
+++ b/ruby/red-arrow/test/test-record-batch.rb
@@ -16,16 +16,16 @@
# under the License.
class RecordBatchTest < Test::Unit::TestCase
- sub_test_case(".each") do
- setup do
- fields = [
- Arrow::Field.new("count", :uint32),
- ]
- @schema = Arrow::Schema.new(fields)
- @counts = Arrow::UInt32Array.new([1, 2, 4, 8])
- @record_batch = Arrow::RecordBatch.new(@schema, @counts.length,
[@counts])
- end
+ setup do
+ fields = [
+ Arrow::Field.new("count", :uint32),
+ ]
+ @schema = Arrow::Schema.new(fields)
+ @counts = Arrow::UInt32Array.new([1, 2, 4, 8])
+ @record_batch = Arrow::RecordBatch.new(@schema, @counts.length, [@counts])
+ end
+ sub_test_case(".each") do
test("default") do
records = []
@record_batch.each do |record|
@@ -54,4 +54,9 @@ class RecordBatchTest < Test::Unit::TestCase
records.collect {|record, i| [record.index, i]})
end
end
+
+ test("#to_table") do
+ assert_equal(Arrow::Table.new(@schema, [@counts]),
+ @record_batch.to_table)
+ end
end