diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 index fdad6baccdc056..7217aabaa8e04b 100644 --- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 +++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 @@ -271,6 +271,7 @@ supportedShowStatement | SHOW TABLE CREATION ((FROM | IN) database=multipartIdentifier)? (LIKE STRING_LITERAL)? #showTableCreation | SHOW TABLET STORAGE FORMAT VERBOSE? #showTabletStorageFormat + | SHOW QUERY PROFILE queryIdPath=STRING_LITERAL #showQueryProfile ; supportedLoadStatement @@ -359,7 +360,6 @@ unsupportedShowStatement (FROM |IN) tableName=multipartIdentifier ((FROM | IN) database=multipartIdentifier)? #showIndex | SHOW TRANSACTION ((FROM | IN) database=multipartIdentifier)? wildWhere? #showTransaction - | SHOW QUERY PROFILE queryIdPath=STRING_LITERAL #showQueryProfile | SHOW CACHE HOTSPOT tablePath=STRING_LITERAL #showCacheHotSpot | SHOW SYNC JOB ((FROM | IN) database=multipartIdentifier)? #showSyncJob | SHOW CATALOG RECYCLE BIN wildWhere? #showCatalogRecycleBin diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java index 95dbbb504712f8..a9ed31930794ac 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java @@ -266,6 +266,7 @@ import org.apache.doris.nereids.DorisParser.ShowProcContext; import org.apache.doris.nereids.DorisParser.ShowProcedureStatusContext; import org.apache.doris.nereids.DorisParser.ShowProcessListContext; +import org.apache.doris.nereids.DorisParser.ShowQueryProfileContext; import org.apache.doris.nereids.DorisParser.ShowReplicaDistributionContext; import org.apache.doris.nereids.DorisParser.ShowRepositoriesContext; import org.apache.doris.nereids.DorisParser.ShowRolesContext; @@ -571,6 +572,7 @@ import org.apache.doris.nereids.trees.plans.commands.ShowProcCommand; import org.apache.doris.nereids.trees.plans.commands.ShowProcedureStatusCommand; import org.apache.doris.nereids.trees.plans.commands.ShowProcessListCommand; +import org.apache.doris.nereids.trees.plans.commands.ShowQueryProfileCommand; import org.apache.doris.nereids.trees.plans.commands.ShowReplicaDistributionCommand; import org.apache.doris.nereids.trees.plans.commands.ShowRepositoriesCommand; import org.apache.doris.nereids.trees.plans.commands.ShowRolesCommand; @@ -5014,5 +5016,11 @@ public LogicalPlan visitAdminShowTabletStorageFormat(AdminShowTabletStorageForma public LogicalPlan visitShowTabletStorageFormat(ShowTabletStorageFormatContext ctx) { return new ShowTabletStorageFormatCommand(ctx.VERBOSE() != null); } + + @Override + public LogicalPlan visitShowQueryProfile(ShowQueryProfileContext ctx) { + String queryIdPath = stripQuotes(ctx.queryIdPath.getText()); + return new ShowQueryProfileCommand(queryIdPath); + } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java index 91ec3591003500..cf8928ae08b947 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java @@ -251,5 +251,6 @@ public enum PlanType { CREATE_WORKLOAD_GROUP_COMMAND, CREATE_FILE_COMMAND, CREATE_ROUTINE_LOAD_COMMAND, - SHOW_TABLE_CREATION_COMMAND + SHOW_TABLE_CREATION_COMMAND, + SHOW_QUERY_PROFILE_COMMAND } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowQueryProfileCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowQueryProfileCommand.java new file mode 100644 index 00000000000000..1fe63619d0125e --- /dev/null +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowQueryProfileCommand.java @@ -0,0 +1,55 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.nereids.trees.plans.commands; + +import org.apache.doris.catalog.Env; +import org.apache.doris.common.AnalysisException; +import org.apache.doris.common.Config; +import org.apache.doris.nereids.trees.plans.PlanType; +import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor; +import org.apache.doris.qe.ConnectContext; +import org.apache.doris.qe.ShowResultSet; +import org.apache.doris.qe.StmtExecutor; + +/** + * Represents the command for SHOW COLLATION + */ +public class ShowQueryProfileCommand extends ShowCommand { + String queryIdPath; + + public ShowQueryProfileCommand(String queryIdPath) { + super(PlanType.SHOW_QUERY_PROFILE_COMMAND); + this.queryIdPath = queryIdPath; + } + + @Override + public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor) throws Exception { + String selfHost = Env.getCurrentEnv().getSelfNode().getHost(); + int httpPort = Config.http_port; + String terminalMsg = String.format( + "try visit http://%s:%d/QueryProfile, show query/load profile syntax is a deprecated feature", + selfHost, httpPort); + throw new AnalysisException(terminalMsg); + } + + @Override + public R accept(PlanVisitor visitor, C context) { + return visitor.visitShowQueryProfileCommand(this, context); + } + +} diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java index 5da741f303fed4..9b66baffcf8fbe 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java @@ -110,6 +110,7 @@ import org.apache.doris.nereids.trees.plans.commands.ShowProcCommand; import org.apache.doris.nereids.trees.plans.commands.ShowProcedureStatusCommand; import org.apache.doris.nereids.trees.plans.commands.ShowProcessListCommand; +import org.apache.doris.nereids.trees.plans.commands.ShowQueryProfileCommand; import org.apache.doris.nereids.trees.plans.commands.ShowReplicaDistributionCommand; import org.apache.doris.nereids.trees.plans.commands.ShowRepositoriesCommand; import org.apache.doris.nereids.trees.plans.commands.ShowRolesCommand; @@ -621,4 +622,9 @@ default R visitShowTabletStorageFormatCommand(ShowTabletStorageFormatCommand sho C context) { return visitCommand(showTabletStorageFormatCommand, context); } + + default R visitShowQueryProfileCommand(ShowQueryProfileCommand showQueryProfileCommand, + C context) { + return visitCommand(showQueryProfileCommand, context); + } } diff --git a/regression-test/suites/nereids_p0/show/test_show_commands_nereids.groovy b/regression-test/suites/nereids_p0/show/test_show_commands_nereids.groovy index ee243b42d3209a..92367db345a254 100644 --- a/regression-test/suites/nereids_p0/show/test_show_commands_nereids.groovy +++ b/regression-test/suites/nereids_p0/show/test_show_commands_nereids.groovy @@ -28,4 +28,5 @@ suite("test_show_commands_nereids") { checkNereidsExecute("""show triggers;""") checkNereidsExecute("""show events;""") checkNereidsExecute("""show load profile "/";""") + checkNereidsExecute("""show query profile "/";""") }