pitrou commented on a change in pull request #7952:
URL: https://github.com/apache/arrow/pull/7952#discussion_r469948366
##########
File path: python/pyarrow/tests/test_array.py
##########
@@ -975,6 +975,47 @@ def check_result(result, expected_field_names,
expected_type_codes,
arr = pa.UnionArray.from_sparse(logical_types, [binary, int64[1:]])
+def test_union_array_to_pylist_with_nulls():
+ # ARROW-9556
+ arr = pa.UnionArray.from_sparse(
+ pa.array([0, 1, 0, 0, 1], type=pa.int8()),
+ [
+ pa.array([0.0, 1.1, None, 3.3, 4.4]),
+ pa.array([True, True, False, True, False]),
+ ]
+ )
+ assert arr.to_pylist() == [0.0, True, None, 3.3, False]
+
+ arr = pa.UnionArray.from_sparse(
+ pa.array([0, 1, 0, 0, 1], type=pa.int8()),
+ [
+ pa.array([0.0, 1.1, None, 3.3, 4.4]),
+ pa.array([True, None, False, True, False]),
+ ]
+ )
+ assert arr.to_pylist() == [0.0, None, None, 3.3, False]
Review comment:
Is this test repeated from above or am I missing something?
##########
File path: python/pyarrow/tests/test_array.py
##########
@@ -975,6 +975,47 @@ def check_result(result, expected_field_names,
expected_type_codes,
arr = pa.UnionArray.from_sparse(logical_types, [binary, int64[1:]])
+def test_union_array_to_pylist_with_nulls():
+ # ARROW-9556
+ arr = pa.UnionArray.from_sparse(
+ pa.array([0, 1, 0, 0, 1], type=pa.int8()),
+ [
+ pa.array([0.0, 1.1, None, 3.3, 4.4]),
+ pa.array([True, True, False, True, False]),
+ ]
+ )
+ assert arr.to_pylist() == [0.0, True, None, 3.3, False]
+
+ arr = pa.UnionArray.from_sparse(
+ pa.array([0, 1, 0, 0, 1], type=pa.int8()),
+ [
+ pa.array([0.0, 1.1, None, 3.3, 4.4]),
+ pa.array([True, None, False, True, False]),
+ ]
+ )
+ assert arr.to_pylist() == [0.0, None, None, 3.3, False]
+
+ arr = pa.UnionArray.from_dense(
+ pa.array([0, 1, 0, 0, 0, 1, 1], type=pa.int8()),
+ pa.array([0, 0, 1, 2, 3, 1, 2], type=pa.int32()),
+ [
+ pa.array([0.0, 1.1, None, 3.3]),
+ pa.array([True, True, False])
+ ]
+ )
+ assert arr.to_pylist() == [0.0, True, 1.1, None, 3.3, True, False]
+
+ arr = pa.UnionArray.from_dense(
+ pa.array([0, 1, 0, 0, 0, 1, 1], type=pa.int8()),
+ pa.array([0, 0, 1, 2, 3, 1, 2], type=pa.int32()),
+ [
+ pa.array([0.0, 1.1, None, 3.3]),
+ pa.array([True, None, False])
+ ]
+ )
+ assert arr.to_pylist() == [0.0, True, 1.1, None, 3.3, None, False]
Review comment:
Same question here.
----------------------------------------------------------------
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:
[email protected]