You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/10/24 16:41:52 UTC

[arrow] branch master updated: ARROW-1720: [Python] Implement bounds check in chunk getter

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new e876e17  ARROW-1720: [Python] Implement bounds check in chunk getter
e876e17 is described below

commit e876e175dc4d7655aaefd32ed144b6bbca54c2da
Author: Licht-T <li...@outlook.jp>
AuthorDate: Tue Oct 24 12:41:47 2017 -0400

    ARROW-1720: [Python] Implement bounds check in chunk getter
    
    This closes [ARROW-1720](https://issues.apache.org/jira/browse/ARROW-1720).
    
    Author: Licht-T <li...@outlook.jp>
    
    Closes #1243 from Licht-T/fix-unbound-chunk and squashes the following commits:
    
    cabdd437 [Licht-T] TST: Add bounds check tests for chunk getter
    bda7f4ce [Licht-T] BUG: Implement bounds check in chunk getter
---
 python/pyarrow/table.pxi           | 4 ++++
 python/pyarrow/tests/test_table.py | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/python/pyarrow/table.pxi b/python/pyarrow/table.pxi
index dd42cf2..694fe91 100644
--- a/python/pyarrow/table.pxi
+++ b/python/pyarrow/table.pxi
@@ -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):
diff --git a/python/pyarrow/tests/test_table.py b/python/pyarrow/tests/test_table.py
index 4a2868a..50190f5 100644
--- a/python/pyarrow/tests/test_table.py
+++ b/python/pyarrow/tests/test_table.py
@@ -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 = [

-- 
To stop receiving notification emails like this one, please contact
['"commits@arrow.apache.org" <co...@arrow.apache.org>'].