You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2023/01/05 06:29:17 UTC
[iceberg] branch master updated: Core: Fix drop table without purge for REST session catalog (#6511)
This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new 50c736b33a Core: Fix drop table without purge for REST session catalog (#6511)
50c736b33a is described below
commit 50c736b33a87cd95ac263b76d90b5ae7380eb73f
Author: Vikash Kumar <vi...@starburstdata.com>
AuthorDate: Thu Jan 5 11:59:11 2023 +0530
Core: Fix drop table without purge for REST session catalog (#6511)
---
.../org/apache/iceberg/rest/CatalogHandlers.java | 2 +-
.../org/apache/iceberg/catalog/CatalogTests.java | 25 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
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 fc8384d48b..d297fc7383 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 class CatalogHandlers {
}
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 f191d9c4b9..c0f6515ca7 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 abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
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<String> 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<String> 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();