bkietz commented on a change in pull request #7704: URL: https://github.com/apache/arrow/pull/7704#discussion_r453228008
########## File path: cpp/src/parquet/arrow/schema.h ########## @@ -163,24 +165,28 @@ struct PARQUET_EXPORT SchemaManifest { return it->second; } - bool GetFieldIndices(const std::vector<int>& column_indices, std::vector<int>* out) { + ::arrow::Result<std::vector<int>> GetFieldIndices( + const std::vector<int>& column_indices) { // Coalesce a list of schema field indices which are the roots of the // columns referred to by a list of column indices const schema::GroupNode* group = descr->group_node(); std::unordered_set<int> already_added; - out->clear(); - for (auto& column_idx : column_indices) { + + std::vector<int> out; + for (int column_idx : column_indices) { + if (column_idx < 0 || column_idx >= descr->num_columns()) { + return ::arrow::Status::IndexError("Column index ", column_idx, " is not valid"); + } auto field_node = descr->GetColumnRoot(column_idx); auto field_idx = group->FieldIndex(*field_node); if (field_idx < 0) { Review comment: Worth noting: replacing this check with an assertion locally broke no tests in C++ or python. I'll leave it as an assertion for now and see what CI thinks ---------------------------------------------------------------- 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: us...@infra.apache.org