Skip to content

Commit bb42e85

Browse files
committed
docs: add explicit error codes for commit failure categories
Add ValidationFailed error code and document specific error codes returned by Apply() and Commit() methods: - ValidationFailed: update cannot be applied to current metadata - CommitFailed: update cannot be committed due to conflicts - CommitStateUnknown: commit success state is unknown - InvalidArgument: pending changes are conflicting This allows callers to distinguish between different failure types, matching the Java exception categories (ValidationException, CommitFailedException, CommitStateUnknownException). Addresses feedback from gty404 about defining explicit Status codes.
1 parent 4e2504e commit bb42e85

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/iceberg/pending_update.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ class ICEBERG_EXPORT PendingUpdateBase {
4646
///
4747
/// Once the commit is successful, the updated table will be refreshed.
4848
///
49-
/// \return Status::OK if the commit was successful, or an error status if
50-
/// validation failed or the commit encountered conflicts
49+
/// \return Status::OK if the commit was successful, or an error:
50+
/// - ValidationFailed: if update cannot be applied to current metadata
51+
/// - CommitFailed: if update cannot be committed due to conflicts
52+
/// - CommitStateUnknown: if commit success state is unknown
5153
virtual Status Commit() = 0;
5254

5355
// Non-copyable, movable
@@ -80,16 +82,19 @@ class ICEBERG_EXPORT PendingUpdate : public PendingUpdateBase {
8082
///
8183
/// This does not result in a permanent update.
8284
///
83-
/// \return the uncommitted changes that would be committed, or an error if
84-
/// the pending changes cannot be applied to the current table metadata
85+
/// \return the uncommitted changes that would be committed, or an error:
86+
/// - ValidationFailed: if pending changes cannot be applied
87+
/// - InvalidArgument: if pending changes are conflicting
8588
virtual Result<T> Apply() = 0;
8689

8790
/// \brief Apply and commit the pending changes to the table
8891
///
8992
/// Implements PendingUpdateBase::Commit().
9093
///
91-
/// \return Status::OK if the commit was successful, or an error status if
92-
/// validation failed or the commit encountered conflicts
94+
/// \return Status::OK if the commit was successful, or an error:
95+
/// - ValidationFailed: if update cannot be applied to current metadata
96+
/// - CommitFailed: if update cannot be committed due to conflicts
97+
/// - CommitStateUnknown: if commit success state is unknown
9398
Status Commit() override = 0;
9499

95100
protected:

src/iceberg/result.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ enum class ErrorKind {
3535
kDecompressError,
3636
kInvalid, // For general invalid errors
3737
kInvalidArgument,
38+
kValidationFailed,
3839
kInvalidArrowData,
3940
kInvalidExpression,
4041
kInvalidSchema,
@@ -84,6 +85,7 @@ DEFINE_ERROR_FUNCTION(CommitStateUnknown)
8485
DEFINE_ERROR_FUNCTION(DecompressError)
8586
DEFINE_ERROR_FUNCTION(Invalid)
8687
DEFINE_ERROR_FUNCTION(InvalidArgument)
88+
DEFINE_ERROR_FUNCTION(ValidationFailed)
8789
DEFINE_ERROR_FUNCTION(InvalidArrowData)
8890
DEFINE_ERROR_FUNCTION(InvalidExpression)
8991
DEFINE_ERROR_FUNCTION(InvalidSchema)

0 commit comments

Comments
 (0)