MCPcopy Create free account
hub / github.com/apache/arrow / ReplaceSchema

Method ReplaceSchema

cpp/src/arrow/record_batch.cc:375–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375Result<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
394std::vector<std::string> RecordBatch::ColumnNames() const {
395 std::vector<std::string> names(num_columns());

Callers 2

TEST_FFunction · 0.45

Calls 11

columnsFunction · 0.85
InvalidFunction · 0.70
MakeFunction · 0.70
num_rowsFunction · 0.70
num_fieldsMethod · 0.45
fieldsMethod · 0.45
sizeMethod · 0.45
typeMethod · 0.45
fieldMethod · 0.45
EqualsMethod · 0.45
ToStringMethod · 0.45

Tested by 1

TEST_FFunction · 0.36