Skip to content

Commit 47ae541

Browse files
committed
[hive] HiveCatalog should not delete dir for drop partition
1 parent 4762ff0 commit 47ae541

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,6 @@ public void dropPartitions(Identifier identifier, List<Map<String, String>> part
395395
tagToPart
396396
? partitions
397397
: removePartitionsExistsInOtherBranches(identifier, partitions);
398-
Table hmsTable = getHmsTable(identifier);
399-
boolean externalTable = isExternalTable(hmsTable);
400-
String dataFilePath = getDataFilePath(identifier, hmsTable);
401398
for (Map<String, String> part : metaPartitions) {
402399
List<String> partitionValues = new ArrayList<>(part.values());
403400
try {
@@ -408,21 +405,6 @@ public void dropPartitions(Identifier identifier, List<Map<String, String>> part
408405
identifier.getTableName(),
409406
partitionValues,
410407
false));
411-
412-
if (!externalTable) {
413-
Path partitionLocation = new Path(getPartitionLocation(dataFilePath, part));
414-
try {
415-
if (fileIO.exists(partitionLocation)) {
416-
fileIO.deleteDirectoryQuietly(partitionLocation);
417-
}
418-
} catch (Exception ee) {
419-
LOG.error(
420-
"Delete directory[{}] fail for table {} partition.",
421-
partitionLocation,
422-
identifier,
423-
ee);
424-
}
425-
}
426408
} catch (NoSuchObjectException e) {
427409
// do nothing if the partition not exists
428410
} catch (Exception e) {

paimon-hive/paimon-hive-connector-common/src/test/java/org/apache/paimon/hive/HiveCatalogITCaseBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,12 @@ private void testDropPartitionFromBranchImpl() throws Exception {
606606
tEnv.executeSql("ALTER TABLE `t$branch_test` DROP PARTITION (pt = 3)");
607607
assertThat(hiveShell.executeQuery("SHOW PARTITIONS t"))
608608
.containsExactlyInAnyOrder("pt=1", "pt=2", "pt=4");
609-
assertThat(fileIO.exists(new Path(tablePath, "pt=3"))).isFalse();
609+
assertThat(fileIO.exists(new Path(tablePath, "pt=3"))).isTrue();
610610

611611
tEnv.executeSql("ALTER TABLE t DROP PARTITION (pt = 1)");
612612
assertThat(hiveShell.executeQuery("SHOW PARTITIONS t"))
613613
.containsExactlyInAnyOrder("pt=2", "pt=4");
614-
assertThat(fileIO.exists(new Path(tablePath, "pt=1"))).isFalse();
614+
assertThat(fileIO.exists(new Path(tablePath, "pt=1"))).isTrue();
615615

616616
tEnv.executeSql("ALTER TABLE t DROP PARTITION (pt = 4)");
617617
assertThat(hiveShell.executeQuery("SHOW PARTITIONS t"))
@@ -620,11 +620,11 @@ private void testDropPartitionFromBranchImpl() throws Exception {
620620

621621
tEnv.executeSql("ALTER TABLE `t$branch_test` DROP PARTITION (pt = 4)");
622622
assertThat(hiveShell.executeQuery("SHOW PARTITIONS t")).containsExactlyInAnyOrder("pt=2");
623-
assertThat(fileIO.exists(new Path(tablePath, "pt=4"))).isFalse();
623+
assertThat(fileIO.exists(new Path(tablePath, "pt=4"))).isTrue();
624624

625625
tEnv.executeSql("ALTER TABLE t DROP PARTITION (pt = 2)");
626626
assertThat(hiveShell.executeQuery("SHOW PARTITIONS t")).isEmpty();
627-
assertThat(fileIO.exists(new Path(tablePath, "pt=2"))).isFalse();
627+
assertThat(fileIO.exists(new Path(tablePath, "pt=2"))).isTrue();
628628
}
629629

630630
@Test

0 commit comments

Comments
 (0)