You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/25 10:54:06 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #12096: ARROW-15277: [Python] Use Make to create ChunkedArray and remove checks

pitrou commented on code in PR #12096:
URL: https://github.com/apache/arrow/pull/12096#discussion_r857500145


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -1187,8 +1187,8 @@ def test_drop_null(ty, values):
 
 
 def test_drop_null_chunked_array():
-    arr = pa.chunked_array([["a", None], ["c", "d", None], [None], []])
-    expected_drop = pa.chunked_array([["a"], ["c", "d"], [], []])
+    arr = pa.chunked_array([[None, None], [None], []])

Review Comment:
   Not sure why you're changing this test?



##########
python/pyarrow/table.pxi:
##########
@@ -1309,31 +1310,13 @@ def chunked_array(arrays, type=None):
 
     for x in arrays:
         arr = x if isinstance(x, Array) else array(x, type=type)
-
-        if type is None:
-            # it allows more flexible chunked array construction from to coerce
-            # subsequent arrays to the firstly inferred array type
-            # it also spares the inference overhead after the first chunk
-            type = arr.type
-        else:
-            if arr.type != type:
-                raise TypeError(
-                    "All array chunks must have type {}".format(type)
-                )
-
         c_arrays.push_back(arr.sp_array)
 
-    if c_arrays.size() == 0 and type is None:
-        raise ValueError("When passing an empty collection of arrays "
-                         "you must also pass the data type")

Review Comment:
   For the record, are the error conditions checked by the test suite?



##########
python/pyarrow/includes/libarrow.pxd:
##########
@@ -748,6 +748,9 @@ cdef extern from "arrow/api.h" namespace "arrow" nogil:
         CChunkedArray(const vector[shared_ptr[CArray]]& arrays)
         CChunkedArray(const vector[shared_ptr[CArray]]& arrays,
                       const shared_ptr[CDataType]& type)
+
+        @staticmethod
+        CResult[shared_ptr[CChunkedArray]] Make(vector[shared_ptr[CArray]] chunks, shared_ptr[CDataType] type)

Review Comment:
   Try `archery lint --python --fix` to ensure lines don't get too long.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org