paleolimbot commented on code in PR #40070:
URL: https://github.com/apache/arrow/pull/40070#discussion_r1504494474
##########
python/pyarrow/table.pxi:
##########
@@ -2995,7 +3017,7 @@ cdef class RecordBatch(_Tabular):
----------
requested_schema : PyCapsule | None
A PyCapsule containing a C ArrowSchema representation of a
requested
- schema. PyArrow will attempt to cast the batch to this schema.
+ schema. PyArrow will attempt to cast each batch to this schema.
Review Comment:
I don't remember! (Reverted!)
##########
python/pyarrow/src/arrow/python/ipc.cc:
##########
@@ -63,5 +64,70 @@ Result<std::shared_ptr<RecordBatchReader>>
PyRecordBatchReader::Make(
return reader;
}
+CastingRecordBatchReader::CastingRecordBatchReader() {}
+
+Status CastingRecordBatchReader::Init(std::shared_ptr<RecordBatchReader>
parent,
+ std::shared_ptr<Schema> schema) {
+ std::shared_ptr<Schema> src = parent->schema();
+
+ // The check for names has already been done in Python where it's easier to
+ // generate a nice error message.
+ int num_fields = schema->num_fields();
+ if (src->num_fields() != num_fields) {
+ return Status::Invalid("Number of fields not equal");
+ }
+
+ // Ensure all columns can be cast before succeeding
+ for (int i = 0; i < num_fields; i++) {
+ if (!compute::CanCast(*src->field(i)->type(), *schema->field(i)->type())) {
+ return Status::NotImplemented("Field ", i, " cannot be cast from ",
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]