danielcweeks commented on code in PR #18203:
URL: https://github.com/apache/iceberg/pull/18203#discussion_r4145929848


##########
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:
   ```suggestion
     private int dropTableIfMetadataMatches(TableIdentifier identifier, String 
metadataLocation) {
   ```
   
   Why not make this return boolean as opposed to int?  At least the check is 
self-contained to the method.  Also needs an access modifier on the method.



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