-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Core: Check table UUID in RESTTableOperations #14363
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thank you for the change @ebyhr
it would be really nice to add an UT for it.
| if (current == null | ||
| || !Objects.equals(current.metadataFileLocation(), response.metadataLocation())) { | ||
| this.current = response.tableMetadata(); | ||
| this.current = checkUUID(current, response.tableMetadata()); |
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.
This seems reasonable to me
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.
+1 for this fix. Also +1 for adding a test
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 for the suggestion. Added a unit test.
| String newUUID = newMetadata.uuid(); | ||
| if (currentMetadata != null && currentMetadata.uuid() != null && newUUID != null) { | ||
| Preconditions.checkState( | ||
| newUUID.equals(currentMetadata.uuid()), | ||
| "Table UUID does not match: current=%s != refreshed=%s", | ||
| currentMetadata.uuid(), | ||
| newUUID); | ||
| } | ||
|
|
||
| return newMetadata; |
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.
[optional to consider] wonder if we can move this to some place common validate(current, newMetadata) so that both BaseMetaStoreOperation and TableOperation (may be an util or just default impl of TableOps) can share it, but seems too much for ROI.
| catalog.createNamespace(TABLE.namespace()); | ||
| catalog.createTable(TABLE, SCHEMA); | ||
|
|
||
| // inject the wrong table UUID |
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: simulate drop and re-create the table with same name
a5e470f to
e914843
Compare
|
Rebased on main to resolve conflicts. |
Fixes #14337