Light-City commented on code in PR #37171:
URL: https://github.com/apache/arrow/pull/37171#discussion_r1308110581


##########
cpp/src/arrow/record_batch.cc:
##########
@@ -283,6 +283,25 @@ bool RecordBatch::ApproxEquals(const RecordBatch& other, 
const EqualOptions& opt
   return true;
 }
 
+Result<std::shared_ptr<RecordBatch>> RecordBatch::RewriteSchema(
+    std::shared_ptr<Schema> schema) const {
+  if (schema_->num_fields() != schema->num_fields())
+    return Status::Invalid("RecordBatch schema fields", schema_->num_fields(),
+                           ", did not match new schema fields: ", 
schema->num_fields());
+  auto fields = schema_->fields();
+  int n_fields = static_cast<int>(fields.size());
+  for (int i = 0; i < n_fields; i++) {
+    auto old_type = fields[i]->type();
+    auto replace_type = schema->field(i)->type();
+    if (!old_type->Equals(replace_type)) {
+      return Status::Invalid(
+          "RecordBatch schema field index ", i, " type is ", 
old_type->ToString(),
+          ", did not match new schema field type: ", replace_type->ToString());
+    }
+  }
+  return RecordBatch::Make(std::move(schema), num_rows(), 
std::move(columns()));

Review Comment:
   > That's not relevant here. `columns` there can and should be moved from, 
but `columns()` here is a const reference and `move` does nothing (and it 
should do nothing, otherwise this method would invalidate the original record 
batch).
   
   ok, you are right, I removed std::move



-- 
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]

Reply via email to