diff --git a/core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java b/core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java index fc8384d48b70..d297fc738317 100644 --- a/core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java +++ b/core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java @@ -223,7 +223,7 @@ public static LoadTableResponse createTable( } public static void dropTable(Catalog catalog, TableIdentifier ident) { - boolean dropped = catalog.dropTable(ident); + boolean dropped = catalog.dropTable(ident, false); if (!dropped) { throw new NoSuchTableException("Table does not exist: %s", ident); } diff --git a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java index f191d9c4b945..c0f6515ca7fc 100644 --- a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java +++ b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java @@ -820,6 +820,31 @@ public void testDropTableWithPurge() { Assert.assertFalse("Table should not exist after drop", catalog.tableExists(TABLE)); } + @Test + public void testDropTableWithoutPurge() { + C catalog = catalog(); + + if (requiresNamespaceCreate()) { + catalog.createNamespace(NS); + } + + Assert.assertFalse("Table should not exist before create", catalog.tableExists(TABLE)); + + Table table = catalog.buildTable(TABLE, SCHEMA).create(); + Assert.assertTrue("Table should exist after create", catalog.tableExists(TABLE)); + Set actualMetadataFileLocations = ReachableFileUtil.metadataFileLocations(table, false); + + boolean dropped = catalog.dropTable(TABLE, false); + Assert.assertTrue("Should drop a table that does exist", dropped); + Assert.assertFalse("Table should not exist after drop", catalog.tableExists(TABLE)); + Set expectedMetadataFileLocations = + ReachableFileUtil.metadataFileLocations(table, false); + Assertions.assertThat(actualMetadataFileLocations) + .hasSameElementsAs(expectedMetadataFileLocations) + .hasSize(1) + .as("Should have one metadata file"); + } + @Test public void testDropMissingTable() { C catalog = catalog();