Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix: reject missing Glue table deletes (#1323)

David Phillipscf761a96981f
diff --git a/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats b/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats
index 76b5f8a559..2ab77b1c17 100644
--- a/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats
+++ b/compatibility-tests/sdk-test-awscli/test/glue-catalog.bats
@@ -339,6 +339,12 @@ function_input() {
--database-name "$DB_NAME" \
--name "$TABLE_NAME"
assert_failure
+
+ run aws_cmd glue delete-table \
+ --database-name "$DB_NAME" \
+ --name "$TABLE_NAME"
+ assert_failure
+ [[ "$output" == *"EntityNotFoundException"* ]]
}
@test "Glue catalog: batch delete table" {
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java
index 21bf83915b..6e5ff90a3d 100644
--- a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/GlueCatalogTest.java
@@ -455,6 +455,11 @@ class GlueCatalogTest {
.name(TABLE_NAME)
.build()))
.isInstanceOf(EntityNotFoundException.class);
+ assertThatThrownBy(() -> glue.deleteTable(DeleteTableRequest.builder()
+ .databaseName(DATABASE_NAME)
+ .name(TABLE_NAME)
+ .build()))
+ .isInstanceOf(EntityNotFoundException.class);
glue.deleteDatabase(DeleteDatabaseRequest.builder()
.name(DATABASE_NAME)
diff --git a/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java b/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java
index 7c6dbb0010..54dffa52af 100644
--- a/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/glue/GlueService.java
@@ -236,6 +236,7 @@ public class GlueService {
}
public void deleteTable(String databaseName, String tableName) {
+ getTable(databaseName, tableName);
String key = tableKey(databaseName, tableName);
tableStore.delete(key);
tableVersionStore.keys().stream()
diff --git a/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java
index f0210c1c3c..5099d47f85 100644
--- a/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/glue/GlueServiceTest.java
@@ -575,6 +575,15 @@ class GlueServiceTest {
assertEquals("EntityNotFoundException", ex.getErrorCode());
}
+ @Test
+ void deleteTableForMissingTableThrows() {
+ AwsException ex = assertThrows(AwsException.class,
+ () -> glueService.deleteTable("db1", "missing_table"));
+
+ assertEquals("EntityNotFoundException", ex.getErrorCode());
+ assertTrue(ex.getMessage().contains("db1.missing_table"));
+ }
+
@Test
void updateTableWithCurrentVersionIdSucceedsAndIncrementsVersionId() {
Table table = new Table();