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

Method RenameColumns

cpp/src/arrow/record_batch.cc:403–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403Result<std::shared_ptr<RecordBatch>> RecordBatch::RenameColumns(
404 const std::vector<std::string>& names) const {
405 int n = num_columns();
406
407 if (static_cast<int>(names.size()) != n) {
408 return Status::Invalid("tried to rename a record batch of ", n, " columns but only ",
409 names.size(), " names were provided");
410 }
411
412 ArrayVector columns(n);
413 FieldVector fields(n);
414
415 for (int i = 0; i < n; ++i) {
416 columns[i] = column(i);
417 fields[i] = schema()->field(i)->WithName(names[i]);
418 }
419
420 return RecordBatch::Make(::arrow::schema(std::move(fields)), num_rows(),
421 std::move(columns), GetSyncEvent());
422}
423
424Result<std::shared_ptr<RecordBatch>> RecordBatch::SelectColumns(
425 const std::vector<int>& indices) const {

Callers

nothing calls this directly

Calls 8

WithNameMethod · 0.80
num_columnsFunction · 0.70
InvalidFunction · 0.70
schemaFunction · 0.70
MakeFunction · 0.70
num_rowsFunction · 0.70
sizeMethod · 0.45
fieldMethod · 0.45

Tested by

no test coverage detected