arrow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From u..@apache.org
Subject arrow git commit: ARROW-962: [Python] Add schema attribute to RecordBatchFileReader
Date Sat, 15 Jul 2017 11:25:15 GMT
Repository: arrow
Updated Branches:
  refs/heads/master cb31b8bc1 -> bfe395906


ARROW-962: [Python] Add schema attribute to RecordBatchFileReader

Author: Wes McKinney <wes.mckinney@twosigma.com>

Closes #843 from wesm/ARROW-962 and squashes the following commits:

b7144aa [Wes McKinney] Add schema attribute to RecordBatchFileReader


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/bfe39590
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/bfe39590
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/bfe39590

Branch: refs/heads/master
Commit: bfe39590670c54483391d2d6a127ff7a98d513a0
Parents: cb31b8b
Author: Wes McKinney <wes.mckinney@twosigma.com>
Authored: Sat Jul 15 13:25:10 2017 +0200
Committer: Uwe L. Korn <uwelk@xhochy.com>
Committed: Sat Jul 15 13:25:10 2017 +0200

----------------------------------------------------------------------
 python/pyarrow/io.pxi            | 8 ++++++--
 python/pyarrow/tests/test_ipc.py | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/bfe39590/python/pyarrow/io.pxi
----------------------------------------------------------------------
diff --git a/python/pyarrow/io.pxi b/python/pyarrow/io.pxi
index cfa751d..64cce03 100644
--- a/python/pyarrow/io.pxi
+++ b/python/pyarrow/io.pxi
@@ -990,8 +990,7 @@ cdef class _RecordBatchReader:
             check_status(CRecordBatchStreamReader.Open(in_stream, &reader))
 
         self.reader = <shared_ptr[CRecordBatchReader]> reader
-        self.schema = Schema()
-        self.schema.init_schema(self.reader.get().schema())
+        self.schema = pyarrow_wrap_schema(self.reader.get().schema())
 
     def get_next_batch(self):
         """
@@ -1049,6 +1048,9 @@ cdef class _RecordBatchFileReader:
     cdef:
         shared_ptr[CRecordBatchFileReader] reader
 
+    cdef readonly:
+        Schema schema
+
     def __cinit__(self):
         pass
 
@@ -1067,6 +1069,8 @@ cdef class _RecordBatchFileReader:
             else:
                 check_status(CRecordBatchFileReader.Open(reader, &self.reader))
 
+        self.schema = pyarrow_wrap_schema(self.reader.get().schema())
+
     property num_record_batches:
 
         def __get__(self):

http://git-wip-us.apache.org/repos/asf/arrow/blob/bfe39590/python/pyarrow/tests/test_ipc.py
----------------------------------------------------------------------
diff --git a/python/pyarrow/tests/test_ipc.py b/python/pyarrow/tests/test_ipc.py
index 47ef756..b91a8e9 100644
--- a/python/pyarrow/tests/test_ipc.py
+++ b/python/pyarrow/tests/test_ipc.py
@@ -89,6 +89,7 @@ class TestFile(MessagingTest, unittest.TestCase):
             # it works. Must convert back to DataFrame
             batch = reader.get_batch(i)
             assert batches[i].equals(batch)
+            assert reader.schema.equals(batches[0].schema)
 
     def test_read_all(self):
         batches = self.write_batches()


Mime
View raw message