This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 7b123b5941 [core] Fix unexpected full clustering when no history
partitions qualify (#11224)
7b123b5941 is described below
commit 7b123b594194078f47efb929992ca2adaeb9868b
Author: sanshi <[email protected]>
AuthorDate: Tue Nov 17 23:26:46 2026 +0800
[core] Fix unexpected full clustering when no history partitions qualify
(#11224)
---
.../append/cluster/HistoryPartitionCluster.java | 5 +++++
.../cluster/HistoryPartitionClusterTest.java | 26 ++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/append/cluster/HistoryPartitionCluster.java
b/paimon-core/src/main/java/org/apache/paimon/append/cluster/HistoryPartitionCluster.java
index 8acbb8e778..4850d2bed3 100644
---
a/paimon-core/src/main/java/org/apache/paimon/append/cluster/HistoryPartitionCluster.java
+++
b/paimon-core/src/main/java/org/apache/paimon/append/cluster/HistoryPartitionCluster.java
@@ -39,6 +39,7 @@ import java.time.Duration;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
@@ -144,6 +145,10 @@ public class HistoryPartitionCluster {
.map(PartitionEntry::partition)
.collect(Collectors.toList());
+ if (historyPartitions.isEmpty()) {
+ return Collections.emptyMap();
+ }
+
// read dataFileMeta for history partitions
List<DataSplit> historyDataSplits =
table.newSnapshotReader()
diff --git
a/paimon-core/src/test/java/org/apache/paimon/append/cluster/HistoryPartitionClusterTest.java
b/paimon-core/src/test/java/org/apache/paimon/append/cluster/HistoryPartitionClusterTest.java
index 2d64663f9a..c23c949dbd 100644
---
a/paimon-core/src/test/java/org/apache/paimon/append/cluster/HistoryPartitionClusterTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/append/cluster/HistoryPartitionClusterTest.java
@@ -103,6 +103,32 @@ public class HistoryPartitionClusterTest {
assertThat(historyPartitionCluster).isNull();
}
+ @Test
+ public void testNoHistoryPartitionsDoesNotClusterActivePartition() throws
Exception {
+ FileStoreTable table =
+ createTable(
+ Collections.singletonMap(
+
CoreOptions.CLUSTERING_HISTORY_PARTITION_IDLE_TIME.key(), "365d"),
+ Collections.singletonList("f2"));
+ writeOnce(
+ table,
+ GenericRow.of(
+ 1, 1, BinaryString.fromString("pt1"),
BinaryString.fromString("test")));
+ writeOnce(
+ table,
+ GenericRow.of(
+ 1, 1, BinaryString.fromString("pt2"),
BinaryString.fromString("test")));
+
+ IncrementalClusterManager manager =
+ new IncrementalClusterManager(
+ table,
+ PartitionPredicate.fromMultiple(
+ RowType.of(DataTypes.STRING()),
+
Collections.singletonList(BinaryRow.singleColumn("pt1"))));
+ assertThat(manager.createCompactUnits(true).keySet())
+ .containsExactly(BinaryRow.singleColumn("pt1"));
+ }
+
protected FileStoreTable createTable(
Map<String, String> customOptions, List<String> partitionKeys)
throws Exception {
Map<String, String> options = new HashMap<>();