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

Method ReplaceSchema

cpp/src/arrow/record_batch.cc:376–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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