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

Function RecordBatch__RenameColumns

r/src/recordbatch.cpp:46–59  ·  view source on GitHub ↗

[[arrow::export]]

Source from the content-addressed store, hash-verified

44
45// [[arrow::export]]
46std::shared_ptr<arrow::RecordBatch> RecordBatch__RenameColumns(
47 const std::shared_ptr<arrow::RecordBatch>& batch,
48 const std::vector<std::string>& names) {
49 int n = batch->num_columns();
50 if (names.size() != static_cast<size_t>(n)) {
51 cpp11::stop("RecordBatch has %d columns but %d names were provided", n, names.size());
52 }
53 std::vector<std::shared_ptr<arrow::Field>> fields(n);
54 for (int i = 0; i < n; i++) {
55 fields[i] = batch->schema()->field(i)->WithName(names[i]);
56 }
57 auto schema = std::make_shared<arrow::Schema>(std::move(fields));
58 return arrow::RecordBatch::Make(schema, batch->num_rows(), batch->columns());
59}
60
61// [[arrow::export]]
62std::shared_ptr<arrow::RecordBatch> RecordBatch__ReplaceSchemaMetadata(

Callers 1

Calls 9

stopFunction · 0.85
WithNameMethod · 0.80
columnsMethod · 0.80
MakeFunction · 0.50
num_columnsMethod · 0.45
sizeMethod · 0.45
fieldMethod · 0.45
schemaMethod · 0.45
num_rowsMethod · 0.45

Tested by

no test coverage detected