anilkumgopalap commented on code in PR #14862:
URL: https://github.com/apache/gravitino/pull/14862#discussion_r4603257138
##########
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:
I looked into moving it in this PR, but for tables the format can reject the
request after the provider has already released the location.
`DeltaTableOperations.purgeTable` always throws, and Lance rejects purging an
external table unless `lance.allow-external-table-purge` is set. In both cases
the table and its data stay, but the provider would treat the location as free
and could hand it to another table. Schemas don't have this problem, because
the tables are already gone when the schema callback runs. Doing it safely
needs a format-level "can this drop/purge proceed" check before the provider is
called, so I'd prefer a follow-up issue for that. Happy to open it.
--
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]