From f42db08cccbf913bfd0ec8b28670e886a47829b8 Mon Sep 17 00:00:00 2001 From: ElvinWei Date: Fri, 7 Apr 2023 13:35:03 +0800 Subject: [PATCH] [fix](Nereids) Fixed a problem with completing ClusterName (#18366) --- .../doris/nereids/rules/analysis/BindRelation.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java index cfabf0a7bb..80bad0c800 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java @@ -27,6 +27,7 @@ import org.apache.doris.catalog.View; import org.apache.doris.catalog.external.EsExternalTable; import org.apache.doris.catalog.external.HMSExternalTable; import org.apache.doris.catalog.external.JdbcExternalTable; +import org.apache.doris.cluster.ClusterNamespace; import org.apache.doris.common.util.Util; import org.apache.doris.datasource.CatalogIf; import org.apache.doris.nereids.CascadesContext; @@ -150,8 +151,8 @@ public class BindRelation extends OneAnalysisRuleFactory { String catalogName = cascadesContext.getConnectContext().getCurrentCatalog().getName(); // if the relation is view, nameParts.get(0) is dbName. String dbName = nameParts.get(0); - if (!dbName.equals(connectContext.getDatabase())) { - dbName = connectContext.getClusterName() + ":" + dbName; + if (!dbName.contains(ClusterNamespace.CLUSTER_DELIMITER)) { + dbName = connectContext.getClusterName() + ClusterNamespace.CLUSTER_DELIMITER + dbName; } String tableName = nameParts.get(1); TableIf table = getTable(catalogName, dbName, tableName, connectContext.getEnv()); @@ -165,8 +166,8 @@ public class BindRelation extends OneAnalysisRuleFactory { ConnectContext connectContext = cascadesContext.getConnectContext(); String catalogName = nameParts.get(0); String dbName = nameParts.get(1); - if (!dbName.equals(connectContext.getDatabase())) { - dbName = connectContext.getClusterName() + ":" + dbName; + if (!dbName.contains(ClusterNamespace.CLUSTER_DELIMITER)) { + dbName = connectContext.getClusterName() + ClusterNamespace.CLUSTER_DELIMITER + dbName; } String tableName = nameParts.get(2); TableIf table = getTable(catalogName, dbName, tableName, connectContext.getEnv());