-
Notifications
You must be signed in to change notification settings - Fork 2k
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
AWS: Fix default warehouse path in Dynamodb catalog #7358
Conversation
@@ -379,6 +379,21 @@ public void testRegisterTable() { | |||
Assertions.assertThat(catalog.dropNamespace(namespace)).isTrue(); | |||
} | |||
|
|||
@Test | |||
public void testDefaultWarehousePathWithLocation() { |
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 your contribution. I was wondering if it would be possible to add a unit test for this change in addition to the aws integration test. like:
iceberg/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java
Lines 143 to 153 in b78d336
@Test | |
public void testDefaultWarehouseLocationDbUri() { | |
Mockito.doReturn( | |
GetDatabaseResponse.builder() | |
.database(Database.builder().name("db").locationUri("s3://bucket2/db").build()) | |
.build()) | |
.when(glue) | |
.getDatabase(Mockito.any(GetDatabaseRequest.class)); | |
String location = glueCatalog.defaultWarehouseLocation(TableIdentifier.of("db", "table")); | |
Assert.assertEquals("s3://bucket2/db/table", location); | |
} |
Since the AWS integration test is not currently run with CI, having a unit test could help catch errors more quickly and ensure that future development reflects this change accurately. What do you think?
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 adding a unit test, @munendrasn let me know if you could add that as suggested, other things looks good 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.
@JonasJ-ap @jackye1995 Thanks for the review. I will include the unit test as suggested
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 have included the unit tests, but for now, included tests only for defaultwarehouse location path in unit tests
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 to me, pending addition of unit 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.
Thank you for adding the unit tests. Just some tiny comments remaining.
I think the fix for Spark-CI is in master branch now. You can rebase and CI shall pass.
.when(dynamo) | ||
.getItem(any(GetItemRequest.class)); | ||
String location = catalogWithSlash.defaultWarehouseLocation(TableIdentifier.of("db", "table")); | ||
Assert.assertEquals(WAREHOUSE_PATH + "/db.db/table", location); |
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.
How about using Assertj
here too?
Assert.assertEquals(WAREHOUSE_PATH + "/db.db/table", location); | |
Assertions.assertThat(location).isEqualTo(WAREHOUSE_PATH + "/db.db/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.
updated
import software.amazon.awssdk.services.dynamodb.model.AttributeValue; | ||
import software.amazon.awssdk.services.dynamodb.model.GetItemRequest; | ||
import software.amazon.awssdk.services.dynamodb.model.GetItemResponse; | ||
import software.amazon.awssdk.services.glue.model.*; |
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.
Seems this is not used in any test. Could you please delete this import? I think running spotlessApply
can automatically delete this import and fix some other checkstyle issue if exists
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.
Spotless doesn't seems to be delete this unused import, maybe because of *
. I have manually deleted it
f367a21
to
9a20214
Compare
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.
Non-blocking nit in the test, everything else looks good to me, thanks @munendrasn !
Mockito.doReturn(GetItemResponse.builder().item(Maps.newHashMap()).build()) | ||
.when(dynamo) | ||
.getItem(any(GetItemRequest.class)); | ||
String location = catalogWithSlash.defaultWarehouseLocation(TableIdentifier.of("db", "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.
Nit: can we move TableIdentifier.of("db", "table") to a constant? It's used multiple times
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 review, moved it to constant
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! Thanks for the contribution.
Thanks, merging |
Without getting the string value of the attribute, the formed the defaultWarehousePath is not in expected format.
cc @amogh-jahagirdar @jackye1995 @yyanyy