feat: Add error collection pattern to PendingUpdate - #358
Merged
Conversation
wgtmac
reviewed
Nov 28, 2025
Comment on lines
+128
to
+130
| void AddError(ErrorKind kind, std::string message) { | ||
| errors_.emplace_back(kind, std::move(message)); | ||
| } |
Member
There was a problem hiding this comment.
nit: we can add void AddError(Error err) to directly add an existing error without change.
wgtmac
reviewed
Nov 28, 2025
| /// 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: |
Member
There was a problem hiding this comment.
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
shangxinli
added a commit
to shangxinli/iceberg-cpp
that referenced
this pull request
Nov 28, 2025
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.
shangxinli
added a commit
to shangxinli/iceberg-cpp
that referenced
this pull request
Nov 28, 2025
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.
shangxinli
force-pushed
the
error-vector-collection
branch
from
November 28, 2025 14:27
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.
wgtmac
force-pushed
the
error-vector-collection
branch
from
December 1, 2025 15:33
ead726d to
7bb446d
Compare
wgtmac
approved these changes
Dec 2, 2025
wgtmac
left a comment
Member
There was a problem hiding this comment.
Thanks @shangxinli for working on this! Let's move forward.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).