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