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

Method SelectColumns

cpp/src/arrow/table.cc:372–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372Result<std::shared_ptr<Table>> Table::SelectColumns(
373 const std::vector<int>& indices) const {
374 int n = static_cast<int>(indices.size());
375
376 std::vector<std::shared_ptr<ChunkedArray>> columns(n);
377 std::vector<std::shared_ptr<Field>> fields(n);
378 for (int i = 0; i < n; i++) {
379 int pos = indices[i];
380 if (pos < 0 || pos > num_columns() - 1) {
381 return Status::Invalid("Invalid column index ", pos, " to select columns.");
382 }
383 columns[i] = column(pos);
384 fields[i] = field(pos);
385 }
386
387 auto new_schema =
388 std::make_shared<arrow::Schema>(std::move(fields), schema()->metadata());
389 return Table::Make(std::move(new_schema), std::move(columns), num_rows());
390}
391
392std::string Table::ToString() const {
393 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