Skip to content

Conversation

@shangxinli
Copy link
Contributor

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.

@shangxinli shangxinli force-pushed the implement_update_requirements branch from de779ff to 35e88f7 Compare November 4, 2025 16:34
Copy link
Collaborator

@zhjwpku zhjwpku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shangxinli shangxinli force-pushed the implement_update_requirements branch from 5a33e96 to 180486f Compare November 10, 2025 17:10
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).
@shangxinli shangxinli force-pushed the implement_update_requirements branch 2 times, most recently from 404937c to 8f29947 Compare November 10, 2025 18:20
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
@shangxinli shangxinli force-pushed the implement_update_requirements branch from 8f29947 to 793e6df Compare November 10, 2025 18:27
Copy link
Member

@wgtmac wgtmac left a 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 wgtmac merged commit 8388f32 into apache:main Nov 12, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants