mkroll-db commented on code in PR #18203:
URL: https://github.com/apache/iceberg/pull/18203#discussion_r4153253736


##########
core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java:
##########
@@ -297,6 +301,39 @@ protected String defaultWarehouseLocation(TableIdentifier 
table) {
     return SLASH.join(defaultNamespaceLocation(table.namespace()), 
tableLocation);
   }
 
+  @Override
+  public Table unregisterTable(TableIdentifier identifier) {
+    Preconditions.checkArgument(
+        identifier != null && isValidIdentifier(identifier), "Invalid 
identifier: %s", identifier);
+    TableOperations ops = newTableOps(identifier);
+    TableMetadata metadata = ops.current();
+
+    if (metadata == null) {
+      throw new NoSuchTableException("Table does not exist: %s", identifier);
+    }
+
+    if (dropTableIfMetadataMatches(identifier, 
metadata.metadataFileLocation()) == 0) {
+      throw new CommitFailedException(
+          "Cannot unregister table %s: metadata location has changed or table 
was dropped",
+          identifier);
+    }
+
+    StaticTableOperations staticOps =
+        new StaticTableOperations(metadata, ops.io(), ops.locationProvider());
+    return new BaseTable(staticOps, identifier.name(), metricsReporter());
+  }
+
+  int dropTableIfMetadataMatches(TableIdentifier identifier, String 
metadataLocation) {

Review Comment:
   Yes. I agree. This is much better.
   Fixed in 998f32de6



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to