[ 
https://issues.apache.org/jira/browse/ARROW-1806?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16251640#comment-16251640
 ] 

ASF GitHub Bot commented on ARROW-1806:
---------------------------------------

wesm closed pull request #1315: ARROW-1806: [GLib] Add 
garrow_record_batch_writer_write_table()
URL: https://github.com/apache/arrow/pull/1315
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/c_glib/arrow-glib/writer.cpp b/c_glib/arrow-glib/writer.cpp
index 7d3b59457..9bcda2dbb 100644
--- a/c_glib/arrow-glib/writer.cpp
+++ b/c_glib/arrow-glib/writer.cpp
@@ -25,6 +25,7 @@
 #include <arrow-glib/error.hpp>
 #include <arrow-glib/record-batch.hpp>
 #include <arrow-glib/schema.hpp>
+#include <arrow-glib/table.hpp>
 
 #include <arrow-glib/output-stream.hpp>
 
@@ -166,6 +167,30 @@ 
garrow_record_batch_writer_write_record_batch(GArrowRecordBatchWriter *writer,
 }
 
 /**
+ * garrow_record_batch_writer_write_table:
+ * @writer: A #GArrowRecordBatchWriter.
+ * @table: The table to be written.
+ * @error: (nullable): Return locatipcn for a #GError or %NULL.
+ *
+ * Returns: %TRUE on success, %FALSE if there was an error.
+ *
+ * Since: 0.8.0
+ */
+gboolean
+garrow_record_batch_writer_write_table(GArrowRecordBatchWriter *writer,
+                                       GArrowTable *table,
+                                       GError **error)
+{
+  auto arrow_writer = garrow_record_batch_writer_get_raw(writer);
+  auto arrow_table = garrow_table_get_raw(table);
+
+  auto status = arrow_writer->WriteTable(*arrow_table);
+  return garrow_error_check(error,
+                            status,
+                            "[record-batch-writer][write-table]");
+}
+
+/**
  * garrow_record_batch_writer_close:
  * @writer: A #GArrowRecordBatchWriter.
  * @error: (nullable): Return locatipcn for a #GError or %NULL.
diff --git a/c_glib/arrow-glib/writer.h b/c_glib/arrow-glib/writer.h
index 3853c2bd7..41b5f723d 100644
--- a/c_glib/arrow-glib/writer.h
+++ b/c_glib/arrow-glib/writer.h
@@ -77,6 +77,10 @@ gboolean garrow_record_batch_writer_write_record_batch(
   GArrowRecordBatchWriter *writer,
   GArrowRecordBatch *record_batch,
   GError **error);
+gboolean garrow_record_batch_writer_write_table(
+  GArrowRecordBatchWriter *writer,
+  GArrowTable *table,
+  GError **error);
 gboolean garrow_record_batch_writer_close(
   GArrowRecordBatchWriter *writer,
   GError **error);
diff --git a/c_glib/test/test-file-writer.rb b/c_glib/test/test-file-writer.rb
index 6ba5c7aeb..3de8e5cf3 100644
--- a/c_glib/test/test-file-writer.rb
+++ b/c_glib/test/test-file-writer.rb
@@ -16,6 +16,8 @@
 # under the License.
 
 class TestFileWriter < Test::Unit::TestCase
+  include Helper::Buildable
+
   def test_write_record_batch
     tempfile = Tempfile.open("arrow-ipc-file-writer")
     output = Arrow::FileOutputStream.new(tempfile.path, false)
@@ -42,4 +44,35 @@ def test_write_record_batch
       input.close
     end
   end
+
+  def test_write_table
+    tempfile = Tempfile.open("arrow-ipc-file-writer")
+    output = Arrow::FileOutputStream.new(tempfile.path, false)
+
+    array = build_boolean_array([true, false, true])
+    field = Arrow::Field.new("enabled", Arrow::BooleanDataType.new)
+    schema = Arrow::Schema.new([field])
+    column = Arrow::Column.new(field, array)
+
+    begin
+      file_writer = Arrow::RecordBatchFileWriter.new(output, schema)
+      begin
+        table = Arrow::Table.new(schema, [column])
+        file_writer.write_table(table)
+      ensure
+        file_writer.close
+      end
+    ensure
+      output.close
+    end
+
+    input = Arrow::MemoryMappedInputStream.new(tempfile.path)
+    begin
+      file_reader = Arrow::RecordBatchFileReader.new(input)
+      assert_equal(Arrow::RecordBatch.new(schema, array.length, [array]),
+                   file_reader.read_record_batch(0))
+    ensure
+      input.close
+    end
+  end
 end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [GLib] Add garrow_record_batch_writer_write_table()
> ---------------------------------------------------
>
>                 Key: ARROW-1806
>                 URL: https://issues.apache.org/jira/browse/ARROW-1806
>             Project: Apache Arrow
>          Issue Type: New Feature
>          Components: GLib
>            Reporter: Kouhei Sutou
>            Assignee: Kouhei Sutou
>              Labels: pull-request-available
>             Fix For: 0.8.0
>
>




--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to