diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/AbstractMetastoreTableOperations.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/AbstractMetastoreTableOperations.java index 75abf29c9b1e..c9b552e2ce1a 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/AbstractMetastoreTableOperations.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/AbstractMetastoreTableOperations.java @@ -193,10 +193,12 @@ protected void commitNewTable(TableMetadata metadata) .setDatabaseName(database) .setTableName(tableName) .setOwner(owner) + // Table needs to be EXTERNAL, otherwise table rename in HMS would rename table directory and break table contents. .setTableType(TableType.EXTERNAL_TABLE.name()) .setDataColumns(toHiveColumns(metadata.schema().columns())) .withStorage(storage -> storage.setLocation(metadata.location())) .withStorage(storage -> storage.setStorageFormat(STORAGE_FORMAT)) + // This is a must-have property for the EXTERNAL_TABLE table type .setParameter("EXTERNAL", "TRUE") .setParameter(TABLE_TYPE_PROP, ICEBERG_TABLE_TYPE_VALUE) .setParameter(METADATA_LOCATION_PROP, newMetadataLocation);