| 373 | } |
| 374 | |
| 375 | Result<std::shared_ptr<RecordBatch>> RecordBatch::ReplaceSchema( |
| 376 | std::shared_ptr<Schema> schema) const { |
| 377 | if (schema_->num_fields() != schema->num_fields()) |
| 378 | return Status::Invalid("RecordBatch schema fields", schema_->num_fields(), |
| 379 | ", did not match new schema fields: ", schema->num_fields()); |
| 380 | auto fields = schema_->fields(); |
| 381 | int n_fields = static_cast<int>(fields.size()); |
| 382 | for (int i = 0; i < n_fields; i++) { |
| 383 | auto old_type = fields[i]->type(); |
| 384 | auto replace_type = schema->field(i)->type(); |
| 385 | if (!old_type->Equals(replace_type)) { |
| 386 | return Status::Invalid( |
| 387 | "RecordBatch schema field index ", i, " type is ", old_type->ToString(), |
| 388 | ", did not match new schema field type: ", replace_type->ToString()); |
| 389 | } |
| 390 | } |
| 391 | return RecordBatch::Make(std::move(schema), num_rows(), columns(), GetSyncEvent()); |
| 392 | } |
| 393 | |
| 394 | std::vector<std::string> RecordBatch::ColumnNames() const { |
| 395 | std::vector<std::string> names(num_columns()); |