mbrobbel commented on a change in pull request #11877: URL: https://github.com/apache/arrow/pull/11877#discussion_r763731186
########## File path: cpp/src/arrow/type.cc ########## @@ -787,6 +787,30 @@ std::vector<std::shared_ptr<Field>> StructType::GetAllFieldsByName( return result; } +Result<std::shared_ptr<StructType>> StructType::AddField( + int i, const std::shared_ptr<Field>& field) const { + if (i < 0 || i > this->num_fields()) { + return Status::Invalid("Invalid column index to add field."); + } + return std::make_shared<StructType>(internal::AddVectorElement(children_, i, field)); +} + +Result<std::shared_ptr<StructType>> StructType::RemoveField(int i) const { + if (i < 0 || i >= this->num_fields()) { + return Status::Invalid("Invalid column index to remove field."); + } + return std::make_shared<StructType>(internal::DeleteVectorElement(children_, i)); +} + +Result<std::shared_ptr<StructType>> StructType::SetField( + int i, const std::shared_ptr<Field>& field) const { + if (i < 0 || i > this->num_fields()) { + return Status::Invalid("Invalid column index to add field."); Review comment: ```suggestion return Status::Invalid("Invalid column index to set field."); ``` -- 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. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org