This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 8c3b95c523 [Fix](multi-catalog) sync default catalog when forwarding query to master. (#22684) 8c3b95c523 is described below commit 8c3b95c5237d4d6282c2e093fc7411c4333e2dd0 Author: Xiangyu Wang <dut.xian...@gmail.com> AuthorDate: Fri Aug 11 14:59:04 2023 +0800 [Fix](multi-catalog) sync default catalog when forwarding query to master. (#22684) Assume that there is a hive catalog named hive_ctl, a hive db named db1 and a table named tbl1, if we connect a slave FE and execute following commands: 1. `switch hive_ctl` 2. `show partitions from db1.tbl1` Then we will meet the error like this: ``` MySQL [(none)]> show partitions from db1.tbl1; ERROR 1049 (42000): errCode = 2, detailMessage = Unknown database 'default_cluster:db1' ``` The reason is that the slave FE will forward the `ShowPartitionStmt` to master FE but we do not sync the default catalog information, so the parser can not find the db and throws this exception. This is just one case, some other simillar cases will failed too. --- fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java | 3 +++ fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java | 1 + gensrc/thrift/FrontendService.thrift | 1 + 3 files changed, 5 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java index 7b4a60a5a1..2a6b15573e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java @@ -753,6 +753,9 @@ public class ConnectProcessor { int idx = request.isSetStmtIdx() ? request.getStmtIdx() : 0; executor = new StmtExecutor(ctx, new OriginStatement(request.getSql(), idx), true); ctx.setExecutor(executor); + if (request.isSetDefaultCatalog()) { + ctx.getEnv().changeCatalog(ctx, request.getDefaultCatalog()); + } TUniqueId queryId; // This query id will be set in ctx if (request.isSetQueryId()) { queryId = request.getQueryId(); diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java index 6e3d9d268c..05fc4e2d21 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java @@ -167,6 +167,7 @@ public class MasterOpExecutor { params.setSql(originStmt.originStmt); params.setStmtIdx(originStmt.idx); params.setUser(ctx.getQualifiedUser()); + params.setDefaultCatalog(ctx.getDefaultCatalog()); params.setDb(ctx.getDatabase()); params.setUserIp(ctx.getRemoteIP()); params.setStmtId(ctx.getStmtId()); diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift index d72814b879..1f67f16bac 100644 --- a/gensrc/thrift/FrontendService.thrift +++ b/gensrc/thrift/FrontendService.thrift @@ -469,6 +469,7 @@ struct TMasterOpRequest { 22: optional string clientNodeHost 23: optional i32 clientNodePort 24: optional bool syncJournalOnly // if set to true, this request means to do nothing but just sync max journal id of master + 25: optional string defaultCatalog } struct TColumnDefinition { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org