This is an automated email from the ASF dual-hosted git repository.

kou 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 0c279eb  ARROW-4536: [GLib] Add data_type argument in 
garrow_list_array_new
0c279eb is described below

commit 0c279eb2ce04fa6e8b6051cd25a725dc680a475b
Author: Kenta Murata <[email protected]>
AuthorDate: Tue Feb 12 15:50:48 2019 +0900

    ARROW-4536: [GLib] Add data_type argument in garrow_list_array_new
    
    This pull-request adds `data_type` argument as the 1st argument of 
`garrow_list_array_new()` function to allow programmers to specify the field 
name of the resultant array.
    
    @kou Please check this.
    
    Author: Kenta Murata <[email protected]>
    
    Closes #3621 from mrkn/fix_garrow_list_array_new and squashes the following 
commits:
    
    38aa2f7b <Kenta Murata> Add data_type argument in garrow_list_array_new
---
 c_glib/arrow-glib/composite-array.cpp | 6 ++++--
 c_glib/arrow-glib/composite-array.h   | 3 ++-
 c_glib/test/test-list-array.rb        | 5 ++++-
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/c_glib/arrow-glib/composite-array.cpp 
b/c_glib/arrow-glib/composite-array.cpp
index bff1858..b202fb4 100644
--- a/c_glib/arrow-glib/composite-array.cpp
+++ b/c_glib/arrow-glib/composite-array.cpp
@@ -75,6 +75,7 @@ garrow_list_array_class_init(GArrowListArrayClass *klass)
 
 /**
  * garrow_list_array_new:
+ * @data_type: The data type of the list.
  * @length: The number of elements.
  * @value_offsets: The offsets of @values in Arrow format.
  * @values: The values as #GArrowArray.
@@ -90,16 +91,17 @@ garrow_list_array_class_init(GArrowListArrayClass *klass)
  * Since: 0.4.0
  */
 GArrowListArray *
-garrow_list_array_new(gint64 length,
+garrow_list_array_new(GArrowDataType *data_type,
+                      gint64 length,
                       GArrowBuffer *value_offsets,
                       GArrowArray *values,
                       GArrowBuffer *null_bitmap,
                       gint64 n_nulls)
 {
+  const auto arrow_data_type = garrow_data_type_get_raw(data_type);
   const auto arrow_value_offsets = garrow_buffer_get_raw(value_offsets);
   const auto arrow_values = garrow_array_get_raw(values);
   const auto arrow_bitmap = garrow_buffer_get_raw(null_bitmap);
-  auto arrow_data_type = arrow::list(arrow_values->type());
   auto arrow_list_array =
     std::make_shared<arrow::ListArray>(arrow_data_type,
                                        length,
diff --git a/c_glib/arrow-glib/composite-array.h 
b/c_glib/arrow-glib/composite-array.h
index 10432e2..275ae43 100644
--- a/c_glib/arrow-glib/composite-array.h
+++ b/c_glib/arrow-glib/composite-array.h
@@ -68,7 +68,8 @@ struct _GArrowListArrayClass
 
 GType garrow_list_array_get_type(void) G_GNUC_CONST;
 
-GArrowListArray *garrow_list_array_new(gint64 length,
+GArrowListArray *garrow_list_array_new(GArrowDataType *data_type,
+                                       gint64 length,
                                        GArrowBuffer *value_offsets,
                                        GArrowArray *values,
                                        GArrowBuffer *null_bitmap,
diff --git a/c_glib/test/test-list-array.rb b/c_glib/test/test-list-array.rb
index 271d322..abbd004 100644
--- a/c_glib/test/test-list-array.rb
+++ b/c_glib/test/test-list-array.rb
@@ -19,13 +19,16 @@ class TestListArray < Test::Unit::TestCase
   include Helper::Buildable
 
   def test_new
+    field = Arrow::Field.new("item", Arrow::Int8DataType.new)
+    data_type = Arrow::ListDataType.new(field)
     value_offsets = Arrow::Buffer.new([0, 2, 5, 5].pack("l*"))
     data = Arrow::Buffer.new([1, 2, 3, 4, 5].pack("c*"))
     nulls = Arrow::Buffer.new([0b11111].pack("C*"))
     values = Arrow::Int8Array.new(5, data, nulls, 0)
     assert_equal(build_list_array(Arrow::Int8DataType.new,
                                   [[1, 2], [3, 4, 5], nil]),
-                 Arrow::ListArray.new(3,
+                 Arrow::ListArray.new(data_type,
+                                      3,
                                       value_offsets,
                                       values,
                                       Arrow::Buffer.new([0b011].pack("C*")),

Reply via email to