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


##########
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:
   If you add the retry, the test changes too. With the listener committing 
once, the rename should now succeed, and the renamed table should keep the 
concurrent snapshot. To cover the give-up path, let the listener commit on 
every attempt and assert CommitFailedException after the last one.



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