-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Add in RenameTableRequest for the RESTCatalog #4448
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
Conversation
core/src/main/java/org/apache/iceberg/rest/requests/RenameTableRequest.java
Outdated
Show resolved
Hide resolved
8ba9b83 to
f701064
Compare
rdblue
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.
Mostly looks good. I think we should allow empty namespaces and add the additional tests. Thanks, @kbendick!
f701064 to
5db9e19
Compare
| err -> { | ||
| if (err instanceof SQLIntegrityConstraintViolationException) { | ||
| if (err instanceof SQLIntegrityConstraintViolationException || | ||
| err.getMessage() != null && err.getMessage().contains("UNIQUE constraint failed")) { |
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.
I don't think this test is going to hold up for most JDBC databases.
There's a SQLCode on the error, but it was SQLIte specific in the test runs.
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.
We looked into this and there isn't a good way to do it. In JdbcTableOperations, we do the same thing but check for just "constraint failed". I pasted some links for background in my other 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.
Updated to use the referenced code (with the same comment).
| Preconditions.checkArgument(source != null, "Invalid source table: null"); | ||
| Preconditions.checkArgument(destination != null, "Invalid destination table: null"); | ||
| Preconditions.checkArgument(!source.equals(destination), | ||
| "Invalid rename table request: source must not be the same as destination"); |
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.
Should this be invalid or a no-op?
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.
I suppose it can be a no-op given we've been somewhat permissive in terms of what is allowed to come through the requests (so that implementors can have discretion as to how they respond to these situations).
I looked at the Glue catalog, and it doesn't specifically check for this case at all. Though I imagine their server fails at the end.
In terms of making it a no-op, should we just let the client send the request and allow the server to deal with it? Maybe log a warning? Seems somewhat difficult to adjust the control flow from the validate function.
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.
Allowing it to go through and the server can deal with it.
This is in line with some of the other catalogs.
| } | ||
|
|
||
| public static void renameTable(Catalog catalog, RenameTableRequest request) { | ||
| request.validate(); |
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.
I don't think other methods in CatalogHandlers run validate. I think that should be done before passing it in here.
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.
Oh good point they don't. Since we're building them via the builder, it's not really necessary. Plus validate is called in the constructor anyway.
| catalog.createNamespace(NS); | ||
| } | ||
|
|
||
| Assert.assertFalse("Source table should not exist before create", catalog.tableExists(TABLE)); |
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.
create -> rename.
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
Outdated
Show resolved
Hide resolved
|
|
||
| catalog.dropTable(TABLE); | ||
| catalog.dropTable(RENAMED_TABLE); | ||
| assertEmpty("Should not contain table after drop", catalog, NS); |
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.
These get cleaned up with the catalog, so no need to drop and assert.
rdblue
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.
@kbendick, this looks ready to go to me, except for the unfinished changes from the JDBC catalog issue. If you remove the comments in tests and update the contains check, I'll merge this.
Cool. I figured that the JDBC catalog issue was something there wasn't a clean way to resolve. I will make the changes so we can merge this. |
3e21a33 to
bfe4884
Compare
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
Outdated
Show resolved
Hide resolved
| String sourceTableUUID = ((HasTableOperations) catalog.loadTable(TABLE)).operations().current().uuid(); | ||
| String destinationTableUUID = ((HasTableOperations) catalog.loadTable(RENAMED_TABLE)).operations().current().uuid(); | ||
| Assert.assertNotEquals("Source and destination table should remain distinct after failed rename", | ||
| sourceTableUUID, destinationTableUUID); |
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.
Looks good.
rdblue
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.
Looks great. I think there was a WIP comment accidentally left in, but overall looks good to merge.
Just noticed it. Removed! |
13a0049 to
aa7a5cc
Compare
|
This should be good to go when you get a chance. Rebased and removed unnecessary commits. |
Adds
RenameTableRequestas a request for theRESTCatalogand adds the call forrenameTableto theRESTCatalog.