World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#6845] fix(core): handle NonEmptyEntityException while dropSchema (#6978)
Jimmy Lee4e75f81be783
diff --git a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.javaindex 7c713fc7ec..8b84806ba8 100644--- a/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java+++ b/catalogs/catalog-jdbc-mysql/src/test/java/org/apache/gravitino/catalog/mysql/integration/test/CatalogMysqlIT.java@@ -923,6 +923,23 @@ public class CatalogMysqlIT extends BaseIT {() -> {schemas.loadSchema(schemaName);});++ // test drop inconsistent database+ catalog+ .asSchemas()+ .createSchema(schemaName, null, ImmutableMap.<String, String>builder().build());+ catalog+ .asTableCatalog()+ .createTable(+ NameIdentifier.of(schemaName, tableName),+ createColumns(),+ "Created by Gravitino client",+ ImmutableMap.<String, String>builder().build());+ // drop the table externally+ mysqlService.executeQuery("DROP TABLE " + schemaName + "." + tableName);++ // drop the schema without cascade+ Assertions.assertTrue(catalog.asSchemas().dropSchema(schemaName, false));}@Testdiff --git a/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java b/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.javaindex a388fff252..b61c99e0d7 100644--- a/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java+++ b/core/src/main/java/org/apache/gravitino/catalog/SchemaOperationDispatcher.java@@ -333,7 +333,7 @@ public class SchemaOperationDispatcher extends OperationDispatcher implements Sc// return value of the store operation into account. We only take the return value of the// catalog into account.try {- store.delete(ident, SCHEMA, cascade);+ store.delete(ident, SCHEMA, true);} catch (NoSuchEntityException e) {LOG.warn("The schema to be dropped does not exist in the store: {}", ident, e);} catch (Exception e) {