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 9aee53de09 [core] Fix incremental clustering with mixed-schema runs
(#11217)
9aee53de09 is described below
commit 9aee53de09cdf090ada82b48dd79001a41097243
Author: sanshi <[email protected]>
AuthorDate: Tue Nov 17 13:35:21 2026 +0800
[core] Fix incremental clustering with mixed-schema runs (#11217)
---
.../append/cluster/IncrementalClusterStrategy.java | 18 ++++++++++++++----
.../append/cluster/IncrementalClusterStrategyTest.java | 17 +++++++++++++++++
2 files changed, 31 insertions(+), 4 deletions(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/append/cluster/IncrementalClusterStrategy.java
b/paimon-core/src/main/java/org/apache/paimon/append/cluster/IncrementalClusterStrategy.java
index 1a90c16ce3..d72f243fc8 100644
---
a/paimon-core/src/main/java/org/apache/paimon/append/cluster/IncrementalClusterStrategy.java
+++
b/paimon-core/src/main/java/org/apache/paimon/append/cluster/IncrementalClusterStrategy.java
@@ -71,10 +71,20 @@ public class IncrementalClusterStrategy {
}
if (runs.size() == 1 && runs.get(0).level() == maxLevel) {
- long schemaId = runs.get(0).run().files().get(0).schemaId();
- CoreOptions coreOptions =
CoreOptions.fromMap(schemaManager.schema(schemaId).options());
- // only one sorted run in the maxLevel with the same cluster key
- if (coreOptions.clusteringColumns().equals(clusterKeys)) {
+ boolean allFilesHaveSameClusterKeys =
+ runs.get(0).run().files().stream()
+ .map(file -> file.schemaId())
+ .distinct()
+ .allMatch(
+ schemaId ->
+ CoreOptions.fromMap(
+ schemaManager
+
.schema(schemaId)
+ .options())
+ .clusteringColumns()
+ .equals(clusterKeys));
+ // Only skip compaction when all files in the run have the same
cluster keys.
+ if (allFilesHaveSameClusterKeys) {
if (LOG.isDebugEnabled()) {
LOG.debug(
"only one sorted run in the maxLevel with the same
cluster key, no need to compact");
diff --git
a/paimon-core/src/test/java/org/apache/paimon/append/cluster/IncrementalClusterStrategyTest.java
b/paimon-core/src/test/java/org/apache/paimon/append/cluster/IncrementalClusterStrategyTest.java
index 9f87b5c276..0fe083e88f 100644
---
a/paimon-core/src/test/java/org/apache/paimon/append/cluster/IncrementalClusterStrategyTest.java
+++
b/paimon-core/src/test/java/org/apache/paimon/append/cluster/IncrementalClusterStrategyTest.java
@@ -179,6 +179,23 @@ public class IncrementalClusterStrategyTest {
assertThat(result.get().files()).hasSize(3);
}
+ @Test
+ public void testPickFullCompactionWithMixedSchemasInSingleRun() {
+ int maxLevel = 2;
+ DataFileMeta matchingFile = createFile(1, 0L, maxLevel);
+ DataFileMeta nonMatchingFile = createFile(2, 1L, maxLevel);
+ LevelSortedRun run =
+ new LevelSortedRun(
+ maxLevel,
+ SortedRun.fromSorted(Arrays.asList(matchingFile,
nonMatchingFile)));
+
+ Optional<CompactUnit> result =
+ incrementalClusterStrategy.pickFullCompaction(3,
Collections.singletonList(run));
+ assertThat(result.isPresent()).isTrue();
+ assertThat(result.get().outputLevel()).isEqualTo(maxLevel);
+ assertThat(result.get().files()).hasSize(2);
+ }
+
private static void prepareSchema() throws Exception {
// schema-0
Map<String, String> options = new HashMap<>();