paleolimbot commented on code in PR #40070:
URL: https://github.com/apache/arrow/pull/40070#discussion_r1504495011
##########
python/pyarrow/ipc.pxi:
##########
@@ -772,6 +772,38 @@ cdef class RecordBatchReader(_Weakrefable):
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
+ def cast(self, target_schema):
+ """
+ Wrap this reader with one that casts each batch lazily as it is pulled.
+ Currently only a safe cast to target_schema is implemented.
+
+ Parameters
+ ----------
+ target_schema : Schema
+ Schema to cast to, the names and order of fields must match.
+
+ Returns
+ -------
+ RecordBatchReader
+ """
+ cdef:
+ shared_ptr[CSchema] c_schema
+ shared_ptr[CRecordBatchReader] c_reader
+ RecordBatchReader out
+
+ if self.schema.names != target_schema.names:
+ raise ValueError("Target schema's field names are not matching "
Review Comment:
Done!
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]