(#5532) RollupJobV2 support identify cluster when replay (#5533)

This commit is contained in:
wangbo
2021-03-23 09:34:51 +08:00
committed by GitHub
parent 4e0775c3df
commit ae3e9df8c7

View File

@ -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 {