Skip to content

Commit f725d81

Browse files
[#4814] Improvement (catalog-lakehouse-paimon): use purgeTable for Paimon instead of dropTable inGravitino (#4820)
### What changes were proposed in this pull request? the dropTable in Paimon will both delete the metadata and data and skip the trash, as discussed in #1436 , Gravitino Paimon catalog should use purgeTable not dropTable ### Why are the changes needed? #4814 ### Does this PR introduce any user-facing change? yes, updated the doc. ### How was this patch tested? existing ITs and UTs. Co-authored-by: cai can <94670132+caican00@users.noreply.github.com>
1 parent dc4c63a commit f725d81

File tree

7 files changed

+31
-27
lines changed

7 files changed

+31
-27
lines changed

catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/PaimonCatalogOperations.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,8 @@ public GravitinoPaimonTable alterTable(NameIdentifier identifier, TableChange...
438438
*/
439439
@Override
440440
public boolean dropTable(NameIdentifier identifier) {
441-
try {
442-
NameIdentifier tableIdentifier = buildPaimonNameIdentifier(identifier);
443-
paimonCatalogOps.dropTable(tableIdentifier.toString());
444-
} catch (Catalog.TableNotExistException e) {
445-
LOG.warn("Paimon table {} does not exist.", identifier);
446-
return false;
447-
}
448-
LOG.info("Dropped Paimon table {}.", identifier);
449-
return true;
441+
throw new UnsupportedOperationException(
442+
"Paimon dropTable will both remove the metadata and data, please use purgeTable instead in Gravitino.");
450443
}
451444

452445
/**
@@ -458,7 +451,15 @@ public boolean dropTable(NameIdentifier identifier) {
458451
*/
459452
@Override
460453
public boolean purgeTable(NameIdentifier identifier) throws UnsupportedOperationException {
461-
throw new UnsupportedOperationException("purgeTable is unsupported now for Paimon Catalog.");
454+
try {
455+
NameIdentifier tableIdentifier = buildPaimonNameIdentifier(identifier);
456+
paimonCatalogOps.purgeTable(tableIdentifier.toString());
457+
} catch (Catalog.TableNotExistException e) {
458+
LOG.warn("Paimon table {} does not exist.", identifier);
459+
return false;
460+
}
461+
LOG.info("Purged Paimon table {}.", identifier);
462+
return true;
462463
}
463464

464465
@Override

catalogs/catalog-lakehouse-paimon/src/main/java/org/apache/gravitino/catalog/lakehouse/paimon/ops/PaimonCatalogOps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void createTable(String tableName, Schema schema)
9090
catalog.createTable(tableIdentifier(tableName), schema, false);
9191
}
9292

93-
public void dropTable(String tableName) throws TableNotExistException {
93+
public void purgeTable(String tableName) throws TableNotExistException {
9494
catalog.dropTable(tableIdentifier(tableName), false);
9595
}
9696

catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/TestGravitinoPaimonTable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void resetSchema() {
101101
return NameIdentifier.of(
102102
Namespace.of(levels[levels.length - 1]), nameIdentifier.name());
103103
})
104-
.forEach(nameIdentifier -> paimonCatalogOperations.dropTable(nameIdentifier));
104+
.forEach(nameIdentifier -> paimonCatalogOperations.purgeTable(nameIdentifier));
105105
}
106106
paimonCatalogOperations.dropSchema(schemaIdent, false);
107107
initPaimonSchema();
@@ -358,7 +358,7 @@ void testDropPaimonTable() {
358358
new SortOrder[0]);
359359

360360
Assertions.assertTrue(paimonCatalogOperations.tableExists(tableIdentifier));
361-
paimonCatalogOperations.dropTable(tableIdentifier);
361+
paimonCatalogOperations.purgeTable(tableIdentifier);
362362
Assertions.assertFalse(paimonCatalogOperations.tableExists(tableIdentifier));
363363
}
364364

catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonBaseIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,13 +595,13 @@ void testListAndDropPaimonTable() throws DatabaseNotExistException {
595595
Assertions.assertEquals("table_1", tableIdentifiers.get(0));
596596
Assertions.assertEquals("table_2", tableIdentifiers.get(1));
597597

598-
Assertions.assertDoesNotThrow(() -> tableCatalog.dropTable(table1));
598+
Assertions.assertDoesNotThrow(() -> tableCatalog.purgeTable(table1));
599599

600600
nameIdentifiers = tableCatalog.listTables(Namespace.of(schemaName));
601601
Assertions.assertEquals(1, nameIdentifiers.length);
602602
Assertions.assertEquals("table_2", nameIdentifiers[0].name());
603603

604-
Assertions.assertDoesNotThrow(() -> tableCatalog.dropTable(table2));
604+
Assertions.assertDoesNotThrow(() -> tableCatalog.purgeTable(table2));
605605
Namespace schemaNamespace = Namespace.of(schemaName);
606606
nameIdentifiers = tableCatalog.listTables(schemaNamespace);
607607
Assertions.assertEquals(0, nameIdentifiers.length);

catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/integration/test/CatalogPaimonKerberosFilesystemIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ void testPaimonWithKerberos() {
266266
Table loadTable = catalog.asTableCatalog().loadTable(tableNameIdentifier);
267267
Assertions.assertEquals(loadTable.name(), tableNameIdentifier.name());
268268

269-
// Drop table
270-
catalog.asTableCatalog().dropTable(tableNameIdentifier);
269+
// Purge table
270+
catalog.asTableCatalog().purgeTable(tableNameIdentifier);
271271
Assertions.assertFalse(catalog.asTableCatalog().tableExists(tableNameIdentifier));
272272

273273
// Drop schema

catalogs/catalog-lakehouse-paimon/src/test/java/org/apache/gravitino/catalog/lakehouse/paimon/ops/TestPaimonCatalogOps.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ void testLoadListAndDropTableOperations() throws Exception {
153153
assertEquals(OPTIONS.get(BUCKET.key()), table.options().get(BUCKET.key()));
154154

155155
// drop table
156-
Assertions.assertDoesNotThrow(() -> paimonCatalogOps.dropTable(IDENTIFIER.toString()));
156+
Assertions.assertDoesNotThrow(() -> paimonCatalogOps.purgeTable(IDENTIFIER.toString()));
157157
Assertions.assertThrowsExactly(
158158
Catalog.TableNotExistException.class,
159-
() -> paimonCatalogOps.dropTable(IDENTIFIER.toString()));
159+
() -> paimonCatalogOps.purgeTable(IDENTIFIER.toString()));
160160

161161
// list table again
162162
Assertions.assertEquals(

docs/lakehouse-paimon-catalog.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ Please refer to [Manage Relational Metadata Using Gravitino](./manage-relational
5959

6060
### Schema properties
6161

62-
- Doesn't support specify location and store any schema properties when createSchema for FilesystemCatalog now.
63-
- Doesn't return any schema properties when loadSchema for FilesystemCatalog now.
64-
- Doesn't support store schema comment for FilesystemCatalog now.
62+
- Doesn't support specify location and store any schema properties when createSchema for FilesystemCatalog.
63+
- Doesn't return any schema properties when loadSchema for FilesystemCatalog.
64+
- Doesn't support store schema comment for FilesystemCatalog.
6565

6666
### Schema operations
6767

@@ -71,20 +71,23 @@ Please refer to [Manage Relational Metadata Using Gravitino](./manage-relational
7171

7272
### Table capabilities
7373

74-
- Supporting createTable, dropTable, alterTable, loadTable and listTable.
75-
```
76-
dropTable will delete the table location directly, similar with purgeTable.
77-
```
74+
- Supporting createTable, purgeTable, alterTable, loadTable and listTable.
7875
- Supporting Column default value through table properties, such as `fields.{columnName}.default-value`, not column expression.
79-
76+
77+
- Doesn't support dropTable.
8078
- Doesn't support table distribution and sort orders.
8179

80+
:::info
81+
Gravitino Paimon Catalog does not support dropTable, because the dropTable in Paimon will both remove the table metadata and the table location from the file system and skip the trash, we should use purgeTable instead in Gravitino.
82+
:::
83+
8284
:::info
8385
Paimon does not support auto increment column.
8486
:::
8587

8688
#### Table changes
8789

90+
- RenameTable
8891
- AddColumn
8992
- DeleteColumn
9093
- RenameColumn

0 commit comments

Comments
 (0)