-
Notifications
You must be signed in to change notification settings - Fork 66
feat: implement validation for table update requirements #294
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
Merged
+224
−15
Conversation
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
de779ff to
35e88f7
Compare
zhjwpku
approved these changes
Nov 6, 2025
Collaborator
zhjwpku
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.
LGTM
wgtmac
reviewed
Nov 7, 2025
5a33e96 to
180486f
Compare
Implement Validate() methods for remaining table requirement classes: - AssertDoesNotExist: validates table doesn't exist - AssertRefSnapshotID: validates snapshot references (branches/tags) - AssertLastAssignedFieldId: validates last assigned field ID - AssertLastAssignedPartitionId: validates last assigned partition ID - AssertDefaultSpecID: validates default partition spec ID - AssertDefaultSortOrderID: validates default sort order ID All implementations follow the pattern established in AssertCurrentSchemaID and provide descriptive error messages for validation failures.
Add tests for all newly implemented table requirement validation methods: - AssertDoesNotExist: 2 tests (success, table exists) - AssertRefSnapshotID: 6 tests (success, mismatch, missing ref, null base, nullopt success, nullopt but exists) - AssertLastAssignedFieldId: 3 tests (success, mismatch, null base) - AssertLastAssignedPartitionId: 3 tests (success, mismatch, null base) - AssertDefaultSpecID: 3 tests (success, mismatch, null base) - AssertDefaultSortOrderID: 3 tests (success, mismatch, null base) Total: 20 new tests added. All tests pass (73 tests in table_test suite).
404937c to
8f29947
Compare
Changes based on review feedback from @wgtmac: 1. AssertRefSnapshotID: Updated to match Java implementation - Removed null base check (Java doesn't check, assumes base exists) - Updated error messages to match Java version - "was created concurrently" when ref shouldn't exist but does - "has changed: expected id X != Y" when snapshot IDs don't match - "is missing, expected X" when ref should exist but doesn't 2. AssertLastAssignedFieldId: Allow null base metadata - Changed to "if (base && ...)" pattern - Null base is valid for new tables 3. AssertLastAssignedPartitionId: Allow null base metadata - Changed to "if (base && ...)" pattern - Null base is valid for new tables 4. AssertDefaultSpecID: Updated to match Java implementation - Removed null base check (assumes base is never null) - Updated error message: "default partition spec changed: expected id X != Y" 5. AssertDefaultSortOrderID: Updated to match Java implementation - Removed null base check (assumes base is never null) - Updated error message: "default sort order changed: expected id X != Y" All implementations now follow Java patterns from: iceberg-java/core/src/main/java/org/apache/iceberg/UpdateRequirement.java Updated tests to match new behavior: - Updated error message assertions - Removed NullBase tests for methods that don't check null (would cause segfault) - Changed NullBase tests to expect success for methods that allow null base
8f29947 to
793e6df
Compare
wgtmac
approved these changes
Nov 11, 2025
Member
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 a lot @shangxinli!
I just made a push to add some missing checks and removed strange comments generated by AI. :)
wgtmac
reviewed
Nov 11, 2025
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 Validate() methods for remaining table requirement classes:
All implementations follow the pattern established in AssertCurrentSchemaID and provide descriptive error messages for validation failures.