jorisvandenbossche commented on a change in pull request #7272:
URL: https://github.com/apache/arrow/pull/7272#discussion_r443582903
##########
File path: cpp/src/arrow/table.cc
##########
@@ -362,6 +362,23 @@ Result<std::shared_ptr<Table>> Table::RenameColumns(
return Table::Make(::arrow::schema(std::move(fields)), std::move(columns),
num_rows());
}
+Result<std::shared_ptr<Table>> Table::SelectColumns(
+ const std::vector<int>& indices) const {
+ int n = indices.size();
+
+ std::vector<std::shared_ptr<ChunkedArray>> columns(n);
+ std::vector<std::shared_ptr<Field>> fields(n);
+ for (int i = 0; i < n; i++) {
+ int pos = indices[i];
+ columns[i] = column(pos);
+ fields[i] = field(pos);
+ }
+
+ auto new_schema =
+ std::make_shared<arrow::Schema>(std::move(fields), schema()->metadata());
Review comment:
I am not fully sure here about ownership of the metadata. Or since
metadata are immutabe (I think?), passing it as a shared ptr is fine?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]