shaoyu-li commented on code in PR #13058:
URL: https://github.com/apache/gravitino/pull/13058#discussion_r3985425512


##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/generic/GenericCatalogOperations.java:
##########
@@ -273,57 +299,80 @@ public Table alterTable(NameIdentifier ident, 
TableChange... changes)
 
   @Override
   public boolean purgeTable(NameIdentifier ident) {
-    boolean purged = tableOps(ident).purgeTable(ident);
-    tableFormatCache.invalidate(ident);
-    return purged;
+    return dropOrPurgeTable(ident, true /* purge */);
   }
 
   @Override
   public boolean dropTable(NameIdentifier ident) throws 
UnsupportedOperationException {
-    boolean dropped = tableOps(ident).dropTable(ident);
-    tableFormatCache.invalidate(ident);
-    return dropped;
+    return dropOrPurgeTable(ident, false /* purge */);
   }
 
-  private String calculateTableLocation(
-      Schema schema, NameIdentifier tableIdent, Map<String, String> 
tableProperties) {
-    String tableLocation =
-        (String)
-            propertiesMetadata
-                .tablePropertiesMetadata()
-                .getOrDefault(tableProperties, Table.PROPERTY_LOCATION);
-    if (StringUtils.isNotBlank(tableLocation)) {
-      return ensureTrailingSlash(tableLocation);
+  /**
+   * Drops or purges a table, and hands its location back to the {@link 
TableLocationProvider}
+   * afterwards.
+   *
+   * <p>The table properties are read before the removal, because they carry 
the location the
+   * provider has to hand back, and the unprovisioning itself happens after 
the removal so that a
+   * provider never reclaims the storage of a table that is still there. A 
provider failing to
+   * unprovision is logged at WARN rather than propagated: the table is 
already gone at that point,
+   * so failing the request would report a drop that did in fact happen as 
unsuccessful and invite a
+   * retry that cannot undo anything.
+   *
+   * @param ident the identifier of the table to drop
+   * @param purge whether to purge the table instead of dropping it
+   * @return true if the table was dropped, false if it did not exist
+   */
+  private boolean dropOrPurgeTable(NameIdentifier ident, boolean purge) {
+    Map<String, String> tableProperties;
+    try {
+      tableProperties = store.get(ident, TABLE, 
TableEntity.class).properties();
+    } catch (NoSuchEntityException e) {

Review Comment:
   Agreed the description is wrong — fixing it. Keeping the new semantics, 
since they match what
   `TableCatalog#dropTable` documents.
   
   One correction: it is covered. `testDropNonExistentTableDoesNotUnprovision` 
asserts
   `assertFalse(dropTable(...))`, and has since the first revision.



-- 
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]

Reply via email to