You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "pitrou (via GitHub)" <gi...@apache.org> on 2023/08/09 10:19:10 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #36891: GH-28481: [C++][Python] Add adjoin_as_list function

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


##########
python/pyarrow/tests/test_compute.py:
##########
@@ -3513,3 +3514,22 @@ def test_pairwise_diff():
     with pytest.raises(pa.ArrowInvalid,
                        match="overflow"):
         pa.compute.pairwise_diff_checked(arr, period=-1)
+
+
+def test_adjoin_as_list():
+    arrs = [pa.array([1, 2, None], type=pa.int32()), pa.array(
+        [None, 5, 6], type=pa.int32()), pa.array([None, None, 9], type=pa.int32())]
+    expected = pa.array([[1, None, None], [2, 5, None], [
+                        None, 6, 9]], type=pa.list_(pa.int32()))
+    result = pa.compute.adjoin_as_list(arrs[0], arrs[1], arrs[2])
+    assert result.equals(expected)
+
+    result = pa.compute.adjoin_as_list(
+        arrs[0], arrs[1], arrs[2], list_type="list")
+    assert result.equals(expected)
+
+    expected = pa.array([[1, None, None], [2, 5, None], [
+                        None, 6, 9]], type=pa.large_list(pa.int32()))
+    result = pa.compute.adjoin_as_list(
+        arrs[0], arrs[1], arrs[2], list_type="large_list")
+    assert result.equals(expected)

Review Comment:
   Try this for example:
   ```pycon
   >>> pa.list_(pa.int64(), 3)
   FixedSizeListType(fixed_size_list<item: int64>[3])
   ```



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