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

Method RenameColumns

cpp/src/arrow/record_batch.cc:402–421  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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