From ae3e9df8c771c41fc01e9b79f4be0b41462afd8a Mon Sep 17 00:00:00 2001 From: wangbo <506340561@qq.com> Date: Tue, 23 Mar 2021 09:34:51 +0800 Subject: [PATCH] (#5532) RollupJobV2 support identify cluster when replay (#5533) --- .../java/org/apache/doris/alter/RollupJobV2.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java index 6548b56a5f..c0d06d1af4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java +++ b/fe/fe-core/src/main/java/org/apache/doris/alter/RollupJobV2.java @@ -815,8 +815,16 @@ public class RollupJobV2 extends AlterJobV2 implements GsonPostProcessable { SqlParser parser = new SqlParser(new SqlScanner(new StringReader(origStmt.originStmt), SqlModeHelper.MODE_DEFAULT)); ConnectContext connectContext = new ConnectContext(); - connectContext.setCluster(SystemInfoService.DEFAULT_CLUSTER); - connectContext.setDatabase(Catalog.getCurrentCatalog().getDb(dbId).getFullName()); + Database db = Catalog.getCurrentCatalog().getDb(dbId); + String clusterName = db.getClusterName(); + // It's almost impossible that db's cluster name is null, just in case + // because before user want to create database, he must first enter a cluster which means that cluster is set to current ConnectContext + // then when createDBStmt is executed, cluster name is set to Database + if (clusterName == null || clusterName.length() == 0) { + clusterName = SystemInfoService.DEFAULT_CLUSTER; + } + connectContext.setCluster(clusterName); + connectContext.setDatabase(db.getFullName()); Analyzer analyzer = new Analyzer(Catalog.getCurrentCatalog(), connectContext); CreateMaterializedViewStmt stmt = null; try {