paleolimbot commented on code in PR #40070:
URL: https://github.com/apache/arrow/pull/40070#discussion_r1501013262
##########
python/pyarrow/src/arrow/python/ipc.cc:
##########
@@ -19,6 +19,7 @@
#include <memory>
+#include "arrow/compute/api.h"
Review Comment:
Done!
##########
python/pyarrow/src/arrow/python/ipc.cc:
##########
@@ -63,5 +64,59 @@ 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();
+
+ // Check for conformable number of columns
+ int num_fields = schema->num_fields();
+ if (src->num_fields() != num_fields) {
+ return Status::Invalid("Source has ", src->num_fields(), " but requested
schema has ",
+ num_fields);
+ }
+
+ // Try to cast an empty version of all the columns before succceeding
+ compute::CastOptions options;
+ for (int i = 0; i < num_fields; i++) {
+ ARROW_ASSIGN_OR_RAISE(auto empty_array,
MakeEmptyArray(src->field(i)->type()));
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]