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

Method SelectColumns

cpp/src/arrow/table.cc:381–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381Result<std::shared_ptr<Table>> Table::SelectColumns(
382 const std::vector<int>& indices) const {
383 int n = static_cast<int>(indices.size());
384
385 std::vector<std::shared_ptr<ChunkedArray>> columns(n);
386 std::vector<std::shared_ptr<Field>> fields(n);
387 for (int i = 0; i < n; i++) {
388 int pos = indices[i];
389 if (pos < 0 || pos > num_columns() - 1) {
390 return Status::Invalid("Invalid column index ", pos, " to select columns.");
391 }
392 columns[i] = column(pos);
393 fields[i] = field(pos);
394 }
395
396 auto new_schema =
397 std::make_shared<arrow::Schema>(std::move(fields), schema()->metadata());
398 return Table::Make(std::move(new_schema), std::move(columns), num_rows());
399}
400
401std::string Table::ToString() const {
402 std::stringstream ss;

Callers 8

table_test.ccFile · 0.45
ASSERT_OK_AND_ASSIGNFunction · 0.45
CheckRoundTripResultFunction · 0.45
CheckValidTestCasesFunction · 0.45
CheckWholeAggregateCaseFunction · 0.45
Table__SelectColumnsFunction · 0.45

Calls 8

num_columnsFunction · 0.70
InvalidFunction · 0.70
fieldFunction · 0.70
schemaFunction · 0.70
MakeFunction · 0.70
num_rowsFunction · 0.70
sizeMethod · 0.45
metadataMethod · 0.45

Tested by 5

ASSERT_OK_AND_ASSIGNFunction · 0.36
CheckRoundTripResultFunction · 0.36
CheckValidTestCasesFunction · 0.36
CheckWholeAggregateCaseFunction · 0.36