mkroll-db commented on code in PR #16584:
URL: https://github.com/apache/iceberg/pull/16584#discussion_r3497418649
##########
core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java:
##########
@@ -488,6 +490,27 @@ public static void dropTable(Catalog catalog,
TableIdentifier ident) {
}
}
+ public static UnregisterTableResponse unregisterTable(Catalog catalog,
TableIdentifier ident) {
+ // capture the last metadata before dropping so it can be returned for
re-registration
+ Table table = catalog.loadTable(ident);
Review Comment:
I believe there should be a check for a metadata table.
Something like:
```suggestion
if (MetadataTableType.from(ident.name()) != null) {
throw new NoSuchTableException("Table does not exist: %s", ident);
}
// capture the last metadata before dropping so it can be returned for
re-registration
Table table = catalog.loadTable(ident);
```
##########
core/src/main/java/org/apache/iceberg/rest/CatalogHandlers.java:
##########
Review Comment:
Needed by my suggestion below.
```suggestion
import org.apache.iceberg.IncrementalAppendScan;
import org.apache.iceberg.MetadataTableType;
```
##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -731,6 +732,38 @@ public Table registerTable(
ops, fullTableName(ident), metricsReporter(paths.metrics(ident),
tableClient));
}
+ /**
+ * Unregister a table from the catalog without removing its data or metadata
files.
+ *
+ * <p>This is the opposite of {@link #registerTable(SessionContext,
TableIdentifier, String)}. On
+ * success, the table no longer exists in the catalog and the returned
metadata location can be
+ * used to register the table in another catalog.
+ *
+ * @param context session context
+ * @param identifier a table identifier
+ * @return the last metadata location for the unregistered table
+ */
+ public String unregisterTable(SessionContext context, TableIdentifier
identifier) {
Review Comment:
I was wondering why not return `TableMetadata` here. But I guess having the
location is sufficient enough.
--
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]