deniskuzZ commented on code in PR #6977:
URL: https://github.com/apache/hive/pull/6977#discussion_r4695295299


##########
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:
##########
@@ -424,16 +426,27 @@ private void renameTableOrView(
       Table table = clients.run(client -> client.getTable(fromDatabase, 
fromName));
       validateTableIsIcebergTableOrView(contentType, table, 
CatalogUtil.fullTableName(name, from));
 
+      String metadataLocation = 
table.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);
       table.setDbName(toDatabase);
       table.setTableName(to.name());
 
       clients.run(client -> {
-        MetastoreUtil.alterTable(client, fromDatabase, fromName, table);
+        MetastoreUtil.alterTable(client, fromDatabase, fromName, table,
+            
HiveOperationsBase.expectedMetadataLocationContext(metadataLocation));
         return null;
       });
 
       LOG.info("Renamed {} from {}, to {}", contentType.value(), from, to);
 
+    } catch (MetaException e) {
+      if (e.getMessage() != null && e.getMessage().startsWith(
+          "The table has been modified. The parameter value for key '" +
+              BaseMetastoreTableOperations.METADATA_LOCATION_PROP + "' is")) {
+        throw new CommitFailedException(

Review Comment:
   Through the HMS REST catalog this surfaces as the wrong error. 
HMSCatalogAdapter maps CommitFailedException to 409, and Iceberg's REST client 
turns a 409 on rename into AlreadyExistsException, so engines report "table 
already exists" and don't retry. A rename doesn't depend on the table contents, 
and the failed alter wrote nothing. 
   
   Could renameTableOrView re-read and retry a few times on a CAS failure, and 
throw only when the attempts run out?



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