anilkumgopalap commented on code in PR #14862:
URL: https://github.com/apache/gravitino/pull/14862#discussion_r4643558136
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -218,18 +251,42 @@ public boolean dropSchema(NameIdentifier ident, boolean
cascade) throws NonEmpty
"Schema %s is not empty, cannot drop it without cascade", ident);
}
+ Schema schema = loadSchema(ident);
+
// 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);
- }
+ // once per table: every table here has the same parent.
+ boolean dataRetained = false;
+ for (NameIdentifier tableIdent : tableIdents) {
+ dataRetained |=
+ dropOrPurgeTable(tableIdent, false /* purge */, schema)
+ == TableDropOutcome.DROPPED_DATA_RETAINED;
}
+ if (dataRetained) {
+ LOG.warn(
+ "Schema {} had external tables whose data was left in place, so its
location '{}' is "
+ + "not handed back to location provider '{}'.",
+ ident,
+ schema.properties().get(Schema.PROPERTY_LOCATION),
+ locationProvider.name());
+ } else {
+ boolean released =
+ locationProvider.unprovisionSchemaLocation(
+ SchemaLocationContext.builder()
+ .withSchemaIdentifier(ident)
+ .withSchemaProperties(schema.properties())
+ .withCatalogProperties(catalogProperties)
+ .build());
+ if (!released) {
+ LOG.debug(
Review Comment:
I'd keep this at DEBUG: `false` is the normal result for the built-in setup.
`DefaultLocationProvider.unprovisionTableLocation` and the default
`unprovisionSchemaLocation` both return false, so WARN would fire on every
table and schema drop in every catalog that doesn't use a custom provider.
Actual failures (the provider throwing) are already logged at WARN, and so is
the skipped schema release when external data was kept. If you'd still like it
louder, INFO would be a compromise.
##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -443,12 +500,18 @@ private boolean dropOrPurgeTable(NameIdentifier ident,
boolean purge, Schema sch
// Use the same effective ownership as the format, including legacy Lance
registrations.
boolean external =
LancePropertiesUtils.isExternalTable(context.tableProperties());
if (dropped && (purge || !external)) {
- TableLocationProvider provider = tableLocationProvider;
+ LocationProvider provider = locationProvider;
try {
- provider.unprovisionTableLocation(context);
+ if (!provider.unprovisionTableLocation(context)) {
+ LOG.debug(
Review Comment:
I'd keep this at DEBUG: `false` is the normal result for the built-in setup.
`DefaultLocationProvider.unprovisionTableLocation` and the default
`unprovisionSchemaLocation` both return false, so WARN would fire on every
table and schema drop in every catalog that doesn't use a custom provider.
Actual failures (the provider throwing) are already logged at WARN, and so is
the skipped schema release when external data was kept. If you'd still like it
louder, INFO would be a compromise.
--
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]