Fix temporary table deletion for exchange materialization
@@ -1622,7 +1622,11 @@ public class SemiTransactionalHiveMetastore
{
for (DeclaredIntentionToWrite declaredIntentionToWrite : declaredIntentionsToWrite) {
if (declaredIntentionToWrite.isTemporaryTable()) {
- deleteRecursivelyIfExists(declaredIntentionToWrite.getContext(), hdfsEnvironment, declaredIntentionToWrite.getStagingPathRoot());
+ String tableName = declaredIntentionToWrite.getSchemaTableName().getTableName();
+ // table path is set to _presto_temporary_table_${uuid}/${uuid}/ for temporary table
+ Path tablePath = declaredIntentionToWrite.getStagingPathRoot().getParent();
+ checkState(tablePath.getName().equalsIgnoreCase(tableName));
+ deleteRecursivelyIfExists(declaredIntentionToWrite.getContext(), hdfsEnvironment, tablePath);
}
}
}
