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 2020/07/16 10:20:00 UTC

[GitHub] [arrow] pitrou commented on a change in pull request #7783: ARROW-9504: [C++/Python] Segmentation fault on ChunkedArray.take

pitrou commented on a change in pull request #7783:
URL: https://github.com/apache/arrow/pull/7783#discussion_r455681439



##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -284,6 +284,66 @@ def test_take_indices_types():
             arr.take(indices)
 
 
+def test_take_on_chunked_array():
+    # ARROW-9504
+    arr = pa.chunked_array([
+        [
+            "m",
+            "J",
+            "q",
+            "k",
+            "t"
+        ],
+        [
+            "m",
+            "J",
+            "q",
+            "k",
+            "t"
+        ]
+    ])
+
+    indices = np.array([0, 5, 1, 6, 2, 7, 3, 8, 4, 9])
+    result = arr.take(indices)
+    expected = pa.chunked_array([
+        "m",
+        "m",
+        "J",
+        "J",
+        "q",
+        "q",
+        "k",
+        "k",
+        "t"
+        "t"
+    ])

Review comment:
       What's the point of a second example?

##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -284,6 +284,66 @@ def test_take_indices_types():
             arr.take(indices)
 
 
+def test_take_on_chunked_array():
+    # ARROW-9504
+    arr = pa.chunked_array([
+        [
+            "m",
+            "J",
+            "q",
+            "k",
+            "t"
+        ],
+        [
+            "m",
+            "J",
+            "q",
+            "k",
+            "t"
+        ]

Review comment:
       Please, can you write a test with non-repeated arrays instead?

##########
File path: python/pyarrow/tests/test_compute.py
##########
@@ -284,6 +284,66 @@ def test_take_indices_types():
             arr.take(indices)
 
 
+def test_take_on_chunked_array():
+    # ARROW-9504
+    arr = pa.chunked_array([
+        [
+            "m",
+            "J",
+            "q",
+            "k",
+            "t"
+        ],
+        [
+            "m",
+            "J",
+            "q",
+            "k",
+            "t"
+        ]
+    ])
+
+    indices = np.array([0, 5, 1, 6, 2, 7, 3, 8, 4, 9])
+    result = arr.take(indices)
+    expected = pa.chunked_array([
+        "m",
+        "m",
+        "J",
+        "J",
+        "q",
+        "q",
+        "k",
+        "k",
+        "t"
+        "t"
+    ])
+    assert result.equals(expected)
+
+    indices = pa.chunked_array([[1], [1, 2]])
+    result = arr.take(indices)
+    expected = pa.chunked_array([
+        [
+            "J"
+        ],
+        [
+            "J",
+            "q"
+        ]
+    ])
+    assert result.equals(expected)

Review comment:
       Similarly, what's the point of this test?

##########
File path: python/pyarrow/_compute.pyx
##########
@@ -189,7 +191,7 @@ num_kernels: {}
         with nogil:
             result = GetResultValue(self.base_func.Execute(c_args,
                                                            c_options,
-                                                           c_exec_ctx))
+                                                           &c_exec_ctx))

Review comment:
       So that was the error? Nice :-)




----------------------------------------------------------------
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.

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