Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-17256 [Python] Can't call combine_chunks on empty ChunkedArray #13757

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/pyarrow/table.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,10 @@ cdef class ChunkedArray(_PandasConvertible):
100
]
"""
return concat_arrays(self.chunks)
if self.num_chunks == 0:
return array([], type=self.type)
else:
return concat_arrays(self.chunks)

def unique(self):
"""
Expand Down
10 changes: 10 additions & 0 deletions python/pyarrow/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3192,3 +3192,13 @@ def test_to_pandas_timezone():
arr = pa.chunked_array([arr])
s = arr.to_pandas()
assert s.dt.tz is not None


def test_chunked_array_can_combine_chunks_with_no_chunks():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combine_chunks is tested in test_table.py, could you move your test there too?

# https://issues.apache.org/jira/browse/ARROW-17256
assert pa.chunked_array([], type=pa.bool_()).combine_chunks() == pa.array(
[], type=pa.bool_()
)
assert pa.chunked_array(
[pa.array([], type=pa.bool_())], type=pa.bool_()
).combine_chunks() == pa.array([], type=pa.bool_())