Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions python/pyarrow/table.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ cdef class ChunkedArray:
pyarrow.Array
"""
self._check_nullptr()

if i >= self.num_chunks or i < 0:
raise IndexError('Chunk index out of range.')

return pyarrow_wrap_array(self.chunked_array.chunk(i))

def iterchunks(self):
Expand Down
6 changes: 6 additions & 0 deletions python/pyarrow/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ def test_table_basics():
for chunk in col.data.iterchunks():
assert chunk is not None

with pytest.raises(IndexError):
col.data.chunk(-1)

with pytest.raises(IndexError):
col.data.chunk(col.data.num_chunks)


def test_table_from_arrays_invalid_names():
data = [
Expand Down