From 7ba1a3e0ea2889033ef85f507ef0b0465056cc8e Mon Sep 17 00:00:00 2001 From: zhuangchong Date: Fri, 7 Feb 2025 08:53:14 +0800 Subject: [PATCH] fix ut error --- .../org/apache/paimon/hive/HiveCatalog.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index 4f767b32a5ca..43e0ce6dc55c 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -357,8 +357,8 @@ public void createPartitions(Identifier identifier, List> pa } int currentTime = (int) (System.currentTimeMillis() / 1000); - String dataFilePath = getDataFilePath(tableIdentifier, hmsTable); StorageDescriptor sd = hmsTable.getSd(); + String dataFilePath = getDataFilePath(tableIdentifier, hmsTable); List hivePartitions = new ArrayList<>(); for (Map partitionSpec : partitions) { Partition hivePartition = new Partition(); @@ -391,18 +391,12 @@ public void dropPartitions(Identifier identifier, List> part tagToPart ? partitions : removePartitionsExistsInOtherBranches(identifier, partitions); + Table hmsTable = getHmsTable(identifier); + boolean externalTable = isExternalTable(hmsTable); + String dataFilePath = getDataFilePath(identifier, hmsTable); for (Map part : metaPartitions) { List partitionValues = new ArrayList<>(part.values()); try { - Partition partition = - clients.run( - client -> - client.getPartition( - identifier.getDatabaseName(), - identifier.getTableName(), - partitionValues)); - String partitionLocation = locationHelper.getPartitionLocation(partition); - locationHelper.dropPathIfRequired(new Path(partitionLocation), fileIO); clients.execute( client -> client.dropPartition( @@ -410,6 +404,11 @@ public void dropPartitions(Identifier identifier, List> part identifier.getTableName(), partitionValues, false)); + + if (!externalTable) { + String partitionLocation = getPartitionLocation(dataFilePath, part); + locationHelper.dropPathIfRequired(new Path(partitionLocation), fileIO); + } } catch (NoSuchObjectException e) { // do nothing if the partition not exists } catch (Exception e) {