You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2026/03/18 14:10:14 UTC
(paimon) branch master updated: [flink] Split btree index build and execute (#7471)
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 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 e3314edaed [flink] Split btree index build and execute (#7471)
e3314edaed is described below
commit e3314edaedb7d8a0316d93b30df49c7b8297c358
Author: YeJunHao <41...@users.noreply.github.com>
AuthorDate: Wed Mar 18 22:10:08 2026 +0800
[flink] Split btree index build and execute (#7471)
---
.../apache/paimon/flink/btree/BTreeIndexTopoBuilder.java | 16 +++++++++-------
.../flink/procedure/CreateGlobalIndexProcedure.java | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/btree/BTreeIndexTopoBuilder.java b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/btree/BTreeIndexTopoBuilder.java
index 0a8cda3baf..c98f7452f7 100644
--- a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/btree/BTreeIndexTopoBuilder.java
+++ b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/btree/BTreeIndexTopoBuilder.java
@@ -72,7 +72,7 @@ import static org.apache.paimon.globalindex.btree.BTreeGlobalIndexBuilder.splitB
/** The {@link BTreeIndexTopoBuilder} for BTree index in Flink. */
public class BTreeIndexTopoBuilder {
- public static void buildIndex(
+ public static boolean buildIndex(
StreamExecutionEnvironment env,
Supplier<BTreeGlobalIndexBuilder> indexBuilderSupplier,
FileStoreTable table,
@@ -90,12 +90,12 @@ public class BTreeIndexTopoBuilder {
List<DataSplit> splits = splitByContiguousRowRange(indexBuilder.scan());
if (splits.isEmpty()) {
- return;
+ return false;
}
Map<BinaryRow, Map<Range, List<DataSplit>>> partitionRangeSplits =
groupSplitsByRange(splits);
if (partitionRangeSplits.isEmpty()) {
- return;
+ return false;
}
// 2. Select necessary columns (index field + ROW_ID)
@@ -160,23 +160,25 @@ public class BTreeIndexTopoBuilder {
commit(table, allCommitMessages);
}
- env.execute("Create btree global index for table: " + table.name());
+ return true;
}
- public static void buildIndex(
+ public static void buildIndexAndExecute(
StreamExecutionEnvironment env,
FileStoreTable table,
String indexColumn,
PartitionPredicate partitionPredicate,
Options userOptions)
throws Exception {
- buildIndex(
+ if (buildIndex(
env,
() -> new BTreeGlobalIndexBuilder(table),
table,
Collections.singletonList(indexColumn),
partitionPredicate,
- userOptions);
+ userOptions)) {
+ env.execute("Create btree global index for table: " + table.name());
+ }
}
protected static DataStream<Committable> executeForPartitionRange(
diff --git a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateGlobalIndexProcedure.java b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateGlobalIndexProcedure.java
index 56675c18e4..664b69be4f 100644
--- a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateGlobalIndexProcedure.java
+++ b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/CreateGlobalIndexProcedure.java
@@ -119,7 +119,7 @@ public class CreateGlobalIndexProcedure extends ProcedureBase {
// Build global index based on index type
indexType = indexType.toLowerCase().trim();
if ("btree".equals(indexType)) {
- BTreeIndexTopoBuilder.buildIndex(
+ BTreeIndexTopoBuilder.buildIndexAndExecute(
procedureContext.getExecutionEnvironment(),
table,
indexColumn,