| 364 | } |
| 365 | |
| 366 | Result<std::shared_ptr<Table>> Table::RenameColumns( |
| 367 | const std::vector<std::string>& names) const { |
| 368 | if (names.size() != static_cast<size_t>(num_columns())) { |
| 369 | return Status::Invalid("tried to rename a table of ", num_columns(), |
| 370 | " columns but only ", names.size(), " names were provided"); |
| 371 | } |
| 372 | std::vector<std::shared_ptr<ChunkedArray>> columns(num_columns()); |
| 373 | std::vector<std::shared_ptr<Field>> fields(num_columns()); |
| 374 | for (int i = 0; i < num_columns(); ++i) { |
| 375 | columns[i] = column(i); |
| 376 | fields[i] = field(i)->WithName(names[i]); |
| 377 | } |
| 378 | return Table::Make(::arrow::schema(std::move(fields)), std::move(columns), num_rows()); |
| 379 | } |
| 380 | |
| 381 | Result<std::shared_ptr<Table>> Table::SelectColumns( |
| 382 | const std::vector<int>& indices) const { |