aokolnychyi commented on a change in pull request #2328:
URL: https://github.com/apache/iceberg/pull/2328#discussion_r593417830
##########
File path:
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
##########
@@ -199,29 +203,68 @@ protected void doCommit(TableMetadata base, TableMetadata
metadata) {
setHmsTableParameters(newMetadataLocation, tbl, metadata.properties(),
removedProps, hiveEngineEnabled);
persistTable(tbl, updateHiveTable);
- threw = false;
} catch (org.apache.hadoop.hive.metastore.api.AlreadyExistsException e) {
+ canCleanupMetadata = true;
throw new AlreadyExistsException("Table already exists: %s.%s",
database, tableName);
} catch (TException | UnknownHostException e) {
Review comment:
I think it may be sufficient to do this:
```
try {
persistTable(tbl, updateHiveTable);
} catch (Exception commitException) {
try {
canCleanupMetadata = !isCommitted(newMetadataLocation);
} catch (Exception checkException) {
LOG.error("Cannot determine if commit was successful", checkException);
throw new CommitStateUnknownException(commitException);
}
}
```
```
private boolean isCommitted(String newMetadataLocation) {
TableMetadata metadata = refresh();
String metadataLocation = metadata.metadataFileLocation();
return metadataLocation.equals(newMetadataLocation) ||
metadata.previousFiles().stream().anyMatch(log ->
log.file().equals(newMetadataLocation));
}
```
Then we don't need extra checks in catch clauses.
----------------------------------------------------------------
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]