Skip to content
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

Merged
merged 4 commits into from
Apr 24, 2023

Conversation

munendrasn
Copy link
Contributor

Without getting the string value of the attribute, the formed the defaultWarehousePath is not in expected format.

cc @amogh-jahagirdar @jackye1995 @yyanyy

@github-actions github-actions bot added the AWS label Apr 16, 2023
@@ -379,6 +379,21 @@ public void testRegisterTable() {
Assertions.assertThat(catalog.dropNamespace(namespace)).isTrue();
}

@Test
public void testDefaultWarehousePathWithLocation() {
Copy link
Contributor

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:

@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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

@jackye1995 jackye1995 left a 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

Copy link
Contributor

@JonasJ-ap JonasJ-ap left a 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);
Copy link
Contributor

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?

Suggested change
Assert.assertEquals(WAREHOUSE_PATH + "/db.db/table", location);
Assertions.assertThat(location).isEqualTo(WAREHOUSE_PATH + "/db.db/table");

Copy link
Contributor Author

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.*;
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a 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"));
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

@JonasJ-ap JonasJ-ap left a 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.

@jackye1995
Copy link
Contributor

Thanks, merging

@jackye1995 jackye1995 merged commit 69c3249 into apache:master Apr 24, 2023
33 checks passed
coufon pushed a commit to coufon/iceberg that referenced this pull request Apr 25, 2023
manisin pushed a commit to Snowflake-Labs/iceberg that referenced this pull request May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants