diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoRestCatalog.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoRestCatalog.java index e1f1a1f8e0ce..3f5b411abf8f 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoRestCatalog.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/rest/TrinoRestCatalog.java @@ -214,7 +214,7 @@ public void registerTable(ConnectorSession session, SchemaTableName tableName, S @Override public void dropTable(ConnectorSession session, SchemaTableName schemaTableName) { - if (!restSessionCatalog.dropTable(convert(session), toIdentifier(schemaTableName))) { + if (!restSessionCatalog.purgeTable(convert(session), toIdentifier(schemaTableName))) { throw new TrinoException(ICEBERG_CATALOG_ERROR, format("Failed to drop table: %s", schemaTableName)); } } diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java index 13d0fb63af19..b0b73d531784 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/BaseIcebergConnectorTest.java @@ -5045,6 +5045,21 @@ public void testDroppingIcebergAndCreatingANewTableWithTheSameNameShouldBePossib dropTable("test_iceberg_recreate"); } + @Test + public void testDropTableDeleteData() + { + String tableName = "test_drop_table_delete_data" + randomNameSuffix(); + assertUpdate("CREATE TABLE " + tableName + " (a_int) AS VALUES (1)", 1); + String tableLocation = getTableLocation(tableName); + assertUpdate("DROP TABLE " + tableName); + + // Create a new table with the same location to verify the data was deleted in the above DROP TABLE + assertUpdate("CREATE TABLE " + tableName + "(a_int INTEGER) WITH (location = '" + tableLocation + "')"); + assertQueryReturnsEmptyResult("SELECT * FROM " + tableName); + + assertUpdate("DROP TABLE " + tableName); + } + @Test public void testPathHiddenColumn() {