diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/HiveMetastoreTableOperations.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/HiveMetastoreTableOperations.java index fbe9f9945d05..3950a4c54277 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/HiveMetastoreTableOperations.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/HiveMetastoreTableOperations.java @@ -88,21 +88,15 @@ protected void commitToExistingTable(TableMetadata base, TableMetadata metadata) .setParameter(METADATA_LOCATION_PROP, newMetadataLocation) .setParameter(PREVIOUS_METADATA_LOCATION_PROP, currentMetadataLocation) .build(); + + // todo privileges should not be replaced for an alter + PrincipalPrivileges privileges = table.getOwner().map(MetastoreUtil::buildInitialPrivilegeSet).orElse(NO_PRIVILEGES); + metastore.replaceTable(database, tableName, table, privileges); } catch (RuntimeException e) { - try { - io().deleteFile(newMetadataLocation); - } - catch (RuntimeException ex) { - e.addSuppressed(ex); - } // CommitFailedException is handled as a special case in the Iceberg library. This commit will automatically retry throw new CommitFailedException(e, "Failed to commit to table %s.%s", database, tableName); } - - // todo privileges should not be replaced for an alter - PrincipalPrivileges privileges = table.getOwner().map(MetastoreUtil::buildInitialPrivilegeSet).orElse(NO_PRIVILEGES); - metastore.replaceTable(database, tableName, table, privileges); } finally { thriftMetastore.releaseTableLock(identity, lockId);