pvary commented on a change in pull request #2219:
URL: https://github.com/apache/hive/pull/2219#discussion_r622302285



##########
File path: 
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java
##########
@@ -254,6 +263,34 @@ public void 
commitAlterTable(org.apache.hadoop.hive.metastore.api.Table hmsTable
     }
   }
 
+  @Override
+  public void rollbackAlterTable(org.apache.hadoop.hive.metastore.api.Table 
hmsTable, EnvironmentContext context)
+      throws MetaException {
+    if 
(Boolean.valueOf(context.getProperties().getOrDefault(MIGRATE_HIVE_TO_ICEBERG, 
"false"))) {
+      LOG.debug("Initiating rollback for table {} at location {}",
+          hmsTable.getTableName(), hmsTable.getSd().getLocation());
+      context.getProperties().put(INITIALIZE_ROLLBACK_MIGRATION, "true");
+      this.catalogProperties = getCatalogProperties(hmsTable);
+      try {
+        this.icebergTable = Catalogs.loadTable(conf, catalogProperties);
+      } catch (NoSuchTableException nte) {
+        // iceberg table was not yet created, no need to delete the metadata 
dir separately
+        return;
+      }
+
+      // we want to keep the data files but get rid of the metadata directory
+      String metadataLocation = ((BaseTable) 
this.icebergTable).operations().current().metadataFileLocation();

Review comment:
       I wanted to put a comment here, but not sure if I have done it or forget 
it 😄
   Could we create some `CatalogUtil.dropTableMetaData(deleteIo, 
deleteMetadata);` based on `CatalogUtil.dropTableData(deleteIo, 
deleteMetadata);`?




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

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