anilkumgopalap commented on code in PR #14862:
URL: https://github.com/apache/gravitino/pull/14862#discussion_r4567521132
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -218,19 +275,40 @@ public boolean dropSchema(NameIdentifier ident, boolean
cascade) throws NonEmpty
"Schema %s is not empty, cannot drop it without cascade", ident);
}
+ TableLocationProvider provider = tableLocationProvider;
+ boolean schemaHooks = provider instanceof SupportsSchemaLocations;
+ Schema schema = null;
+ if (schemaHooks || tableIdents.length > 0) {
+ try {
+ schema = loadSchema(ident);
+ } catch (NoSuchSchemaException e) {
+ return false;
+ }
+ }
+
// Drop all tables under the schema first if cascade is true. This goes
through the same path
// as the catalog level dropTable, so that the location of each table is
unprovisioned and its
// cached format invalidated. The schema is resolved once for the whole
cascade rather than
// once per table: every table here has the same parent, and the provider
may not ask for it at
// all.
- if (tableIdents.length > 0) {
- Schema cascadedSchema = loadSchema(ident);
- for (NameIdentifier tableIdent : tableIdents) {
- dropOrPurgeTable(tableIdent, false /* purge */, cascadedSchema);
- }
+ List<NameIdentifier> tablesWithRetainedData = Lists.newArrayList();
+ for (NameIdentifier tableIdent : tableIdents) {
+ dropOrPurgeTable(tableIdent, false /* purge */, schema,
tablesWithRetainedData);
}
- return schemaOps.dropSchema(ident, cascade);
+ boolean dropped = schemaOps.dropSchema(ident, cascade);
+ if (dropped && schemaHooks) {
+ unprovisionSchemaLocation(
Review Comment:
Makes sense. Current changes aligned with table provider changes to keep it
consistent.
Unprovision now runs after the cascaded tables are dropped and before the
schema is removed, so a provider failure leaves the schema in place and the
drop can be retried. This means providers must handle being called twice for
the same schema, which I've documented.
@shaoyu-li, note this differs from the table hooks, which unprovision after
the drop. Are you OK with schemas behaving differently?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]