[[arrow::export]]
| 44 | |
| 45 | // [[arrow::export]] |
| 46 | std::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]] |
| 62 | std::shared_ptr<arrow::RecordBatch> RecordBatch__ReplaceSchemaMetadata( |
no test coverage detected