This is an automated email from the ASF dual-hosted git repository.
starocean999 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 ea6958cb40e [Enhancement](nereids)implement showStatusCommand in
nereids (#45427)
ea6958cb40e is described below
commit ea6958cb40e225dd3704327964436432696497eb
Author: Sridhar R Manikarnike <[email protected]>
AuthorDate: Thu Dec 19 15:01:40 2024 +0530
[Enhancement](nereids)implement showStatusCommand in nereids (#45427)
Issue Number: close #42730
---
.../antlr4/org/apache/doris/nereids/DorisParser.g4 | 2 +-
.../doris/nereids/parser/LogicalPlanBuilder.java | 16 ++++++
.../apache/doris/nereids/trees/plans/PlanType.java | 1 +
.../trees/plans/commands/ShowStatusCommand.java | 61 ++++++++++++++++++++++
.../trees/plans/visitor/CommandVisitor.java | 5 ++
.../nereids_p0/show/test_show_status_command.out | 7 +++
.../show/test_show_status_command.groovy | 31 +++++++++++
7 files changed, 122 insertions(+), 1 deletion(-)
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 93bf6050970..97876c231fe 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
@@ -274,6 +274,7 @@ supportedShowStatement
| SHOW DATABASE databaseId=INTEGER_VALUE
#showDatabaseId
| SHOW TABLE tableId=INTEGER_VALUE
#showTableId
| SHOW TRASH (ON backend=STRING_LITERAL)?
#showTrash
+ | SHOW (GLOBAL | SESSION | LOCAL)? STATUS
#showStatus
| SHOW WHITELIST
#showWhitelist
| SHOW TABLETS BELONG
tabletIds+=INTEGER_VALUE (COMMA tabletIds+=INTEGER_VALUE)*
#showTabletsBelong
@@ -325,7 +326,6 @@ unsupportedShowStatement
| SHOW TABLE STATUS ((FROM | IN) database=multipartIdentifier)? wildWhere?
#showTableStatus
| SHOW FULL? TABLES ((FROM | IN) database=multipartIdentifier)? wildWhere?
#showTables
| SHOW FULL? VIEWS ((FROM | IN) database=multipartIdentifier)? wildWhere?
#showViews
- | SHOW (GLOBAL | SESSION | LOCAL)? STATUS wildWhere?
#showStatus
| SHOW CREATE MATERIALIZED VIEW name=multipartIdentifier
#showMaterializedView
| SHOW CREATE (GLOBAL | SESSION | LOCAL)? FUNCTION functionIdentifier
LEFT_PAREN functionArguments? RIGHT_PAREN
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 34f760ff4f5..0332123f9ff 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
@@ -281,6 +281,7 @@ import
org.apache.doris.nereids.DorisParser.ShowRepositoriesContext;
import org.apache.doris.nereids.DorisParser.ShowRolesContext;
import org.apache.doris.nereids.DorisParser.ShowSmallFilesContext;
import org.apache.doris.nereids.DorisParser.ShowSqlBlockRuleContext;
+import org.apache.doris.nereids.DorisParser.ShowStatusContext;
import org.apache.doris.nereids.DorisParser.ShowStorageEnginesContext;
import org.apache.doris.nereids.DorisParser.ShowSyncJobContext;
import org.apache.doris.nereids.DorisParser.ShowTableCreationContext;
@@ -599,6 +600,7 @@ import
org.apache.doris.nereids.trees.plans.commands.ShowRepositoriesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowRolesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowSmallFilesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowSqlBlockRuleCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowStatusCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowStorageEnginesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowSyncJobCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTableCreationCommand;
@@ -5124,6 +5126,20 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
return new AdminCheckTabletsCommand(tabletIdLists, properties);
}
+ @Override
+ public LogicalPlan visitShowStatus(ShowStatusContext ctx) {
+ String scope = null;
+ if (ctx.GLOBAL() != null) {
+ scope = "GLOBAL";
+ } else if (ctx.SESSION() != null) {
+ scope = "SESSION";
+ } else if (ctx.LOCAL() != null) {
+ scope = "LOCAL";
+ }
+
+ return new ShowStatusCommand(scope);
+ }
+
@Override
public LogicalPlan visitShowDataSkew(ShowDataSkewContext ctx) {
TableRefInfo tableRefInfo =
visitBaseTableRefContext(ctx.baseTableRef());
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 8eeac54a853..dfc129f10b0 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
@@ -239,6 +239,7 @@ public enum PlanType {
SHOW_REPOSITORIES_COMMAND,
SHOW_ROLE_COMMAND,
SHOW_SMALL_FILES_COMMAND,
+ SHOW_STATUS_COMMAND,
SHOW_STORAGE_ENGINES_COMMAND,
SHOW_SYNC_JOB_COMMAND,
SHOW_TABLE_ID_COMMAND,
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowStatusCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowStatusCommand.java
new file mode 100644
index 00000000000..3ae5643e068
--- /dev/null
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowStatusCommand.java
@@ -0,0 +1,61 @@
+// 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.Column;
+import org.apache.doris.catalog.ScalarType;
+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.ShowResultSetMetaData;
+import org.apache.doris.qe.StmtExecutor;
+
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+/**
+ * Command for SHOW STATUS.
+ */
+public class ShowStatusCommand extends ShowCommand {
+ private static final ShowResultSetMetaData META_DATA =
+ ShowResultSetMetaData.builder()
+ .addColumn(new Column("Variable_name",
ScalarType.createVarchar(64)))
+ .addColumn(new Column("Value",
ScalarType.createVarchar(64)))
+ .build();
+
+ private final String scope;
+
+ public ShowStatusCommand(String scope) {
+ super(PlanType.SHOW_STATUS_COMMAND);
+ this.scope = scope;
+ }
+
+ @Override
+ public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor)
throws Exception {
+ List<List<String>> rows = Lists.newArrayList();
+ return new ShowResultSet(META_DATA, rows);
+ }
+
+ @Override
+ public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+ return visitor.visitShowStatusCommand(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 cce1f41e071..d3749e94d57 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
@@ -125,6 +125,7 @@ import
org.apache.doris.nereids.trees.plans.commands.ShowRepositoriesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowRolesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowSmallFilesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowSqlBlockRuleCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowStatusCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowStorageEnginesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowSyncJobCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTableCreationCommand;
@@ -416,6 +417,10 @@ public interface CommandVisitor<R, C> {
return visitCommand(showGrantsCommand, context);
}
+ default R visitShowStatusCommand(ShowStatusCommand showStatusCommand, C
context) {
+ return visitCommand(showStatusCommand, context);
+ }
+
default R visitShowPartitionIdCommand(ShowPartitionIdCommand
showPartitionIdCommand, C context) {
return visitCommand(showPartitionIdCommand, context);
}
diff --git a/regression-test/data/nereids_p0/show/test_show_status_command.out
b/regression-test/data/nereids_p0/show/test_show_status_command.out
new file mode 100644
index 00000000000..0fbf8d052ed
--- /dev/null
+++ b/regression-test/data/nereids_p0/show/test_show_status_command.out
@@ -0,0 +1,7 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !cmd --
+
+-- !cmd --
+
+-- !cmd --
+
diff --git
a/regression-test/suites/nereids_p0/show/test_show_status_command.groovy
b/regression-test/suites/nereids_p0/show/test_show_status_command.groovy
new file mode 100644
index 00000000000..1b611268057
--- /dev/null
+++ b/regression-test/suites/nereids_p0/show/test_show_status_command.groovy
@@ -0,0 +1,31 @@
+// 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.
+
+suite("test_show_status_command", "nereids_p0") {
+ // Verify SESSION status
+ checkNereidsExecute("SHOW SESSION STATUS")
+ qt_cmd("SHOW SESSION STATUS")
+
+ // Verify GLOBAL status
+ checkNereidsExecute("SHOW GLOBAL STATUS")
+ qt_cmd("SHOW GLOBAL STATUS")
+
+ // Verify default STATUS (SESSION)
+ checkNereidsExecute("SHOW STATUS")
+ qt_cmd("SHOW STATUS")
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]