deniskuzZ commented on code in PR #6977:
URL: https://github.com/apache/hive/pull/6977#discussion_r4694751615
##########
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) {
Review Comment:
This is the 4th copy of the CAS message match (HiveTableOperations,
HiveViewOperations and `HiveTxnCoordinator.isCasFailure` have the others), and
the only one that uses startsWith.
Could you move `HiveTxnCoordinator.isCasFailure` into HiveOperationsBase as
a static method and check it in the existing catch (TException e) arm?
````
} catch (TException e) {
if (HiveOperationsBase.isCasFailure(e)) {
throw new CommitFailedException(e, "Cannot rename %s to %s. It has been
modified concurrently", from, to);
}
throw new RuntimeException("Failed to rename " + from + " to " + to, e);
````
That drops this arm and the MetaException import (line 36). It should also
bring the method back within Sonar's S3776 limit (it reports 17 > 15 on this
PR).
--
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]