-
Notifications
You must be signed in to change notification settings - Fork 74
feat: Add error collection pattern to PendingUpdate #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/iceberg/pending_update.h
Outdated
| void AddError(ErrorKind kind, std::string message) { | ||
| errors_.emplace_back(kind, std::move(message)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can add void AddError(Error err) to directly add an existing error without change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
src/iceberg/pending_update.h
Outdated
| /// Apply() can be used to validate and inspect the uncommitted changes before | ||
| /// committing. Commit() applies the changes and commits them to the table. | ||
| /// | ||
| /// Error Collection Pattern: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can make it a separate class so that other builders can leverage this as well? For example, TableMetadataBuilder uses the same pattern: https://github.com/apache/iceberg-cpp/blob/main/src/iceberg/table_metadata.cc#L279
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense
Address review comments from wgtmac on PR apache#358: 1. Add AddError(Error err) overload to accept existing Error objects This allows propagating errors from other components without deconstructing and reconstructing them. 2. Extract error collection into reusable ErrorCollector utility class This eliminates code duplication between PendingUpdateTyped and TableMetadataBuilder, and provides a reusable pattern for other builders in the codebase. Changes: - Add src/iceberg/util/error_collector.h with ErrorCollector class - Update PendingUpdateTyped to use ErrorCollector internally - Update TableMetadataBuilder to use ErrorCollector instead of std::vector<Error> - Add test for AddError(Error err) overload - Add comprehensive documentation with usage examples All 12 tests pass.
Address review comments from wgtmac on PR apache#358: 1. Add AddError(Error err) overload to accept existing Error objects This allows propagating errors from other components without deconstructing and reconstructing them. 2. Extract error collection into reusable ErrorCollector utility class This eliminates code duplication between PendingUpdateTyped and TableMetadataBuilder, and provides a reusable pattern for other builders in the codebase. Changes: - Add src/iceberg/util/error_collector.h with ErrorCollector class - Update PendingUpdateTyped to use ErrorCollector internally - Update TableMetadataBuilder to use ErrorCollector instead of std::vector<Error> - Add test for AddError(Error err) overload - Add comprehensive documentation with usage examples All 12 tests pass.
f5c45f3 to
ead726d
Compare
Implement error vector collection pattern in PendingUpdateTyped to allow builder methods to accumulate validation errors instead of failing fast. This enables users to see all validation issues at once rather than fixing them one by one. Changes: - Add protected error collection methods (AddError, CheckErrors, HasErrors, ClearErrors) to PendingUpdateTyped base class - Add std::vector<Error> errors_ member to collect validation errors - Update PendingUpdate documentation with usage examples - Add 6 comprehensive unit tests demonstrating error collection Pattern follows TableMetadataBuilder implementation. All tests pass (11/11).
Address review comments from wgtmac on PR apache#358: 1. Add AddError(Error err) overload to accept existing Error objects This allows propagating errors from other components without deconstructing and reconstructing them. 2. Extract error collection into reusable ErrorCollector utility class This eliminates code duplication between PendingUpdateTyped and TableMetadataBuilder, and provides a reusable pattern for other builders in the codebase. Changes: - Add src/iceberg/util/error_collector.h with ErrorCollector class - Update PendingUpdateTyped to use ErrorCollector internally - Update TableMetadataBuilder to use ErrorCollector instead of std::vector<Error> - Add test for AddError(Error err) overload - Add comprehensive documentation with usage examples All 12 tests pass.
ead726d to
7bb446d
Compare
wgtmac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shangxinli for working on this! Let's move forward.
Implement error vector collection pattern in PendingUpdateTyped to allow builder methods to accumulate validation errors instead of failing fast. This enables users to see all validation issues at once rather than fixing them one by one.
Changes:
Pattern follows TableMetadataBuilder implementation.
All tests pass (11/11).