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 a9ce09371e4 [Enhancement] (nereids)implement showWaringErrorsCommand
in nereids (#44816)
a9ce09371e4 is described below
commit a9ce09371e4b017a984546a092f09e531180cb3d
Author: Sridhar R Manikarnike <[email protected]>
AuthorDate: Wed Dec 11 12:06:55 2024 +0530
[Enhancement] (nereids)implement showWaringErrorsCommand in nereids (#44816)
Issue Number: close #42752
---
.../antlr4/org/apache/doris/nereids/DorisParser.g4 | 4 +-
.../doris/nereids/parser/LogicalPlanBuilder.java | 18 ++++++
.../apache/doris/nereids/trees/plans/PlanType.java | 1 +
.../plans/commands/ShowWarningErrorsCommand.java | 64 ++++++++++++++++++++++
.../trees/plans/visitor/CommandVisitor.java | 5 ++
.../show/test_show_warning_errors_command.out | 5 ++
.../show/test_show_warning_errors_command.groovy | 27 +++++++++
7 files changed, 122 insertions(+), 2 deletions(-)
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 c833e7d4b62..a385e1e5ddb 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
@@ -255,7 +255,8 @@ supportedShowStatement
| SHOW SQL_BLOCK_RULE (FOR ruleName=identifier)?
#showSqlBlockRule
| SHOW CREATE VIEW name=multipartIdentifier
#showCreateView
| SHOW CREATE MATERIALIZED VIEW mvName=identifier
- ON tableName=multipartIdentifier
#showCreateMaterializedView
+ ON tableName=multipartIdentifier
#showCreateMaterializedView
+ | SHOW (WARNINGS | ERRORS) limitClause?
#showWarningErrors
| SHOW BACKENDS
#showBackends
| SHOW REPLICA DISTRIBUTION FROM baseTableRef
#showReplicaDistribution
| SHOW FULL? TRIGGERS ((FROM | IN) database=multipartIdentifier)?
wildWhere? #showTriggers
@@ -327,7 +328,6 @@ unsupportedShowStatement
((FROM | IN) database=multipartIdentifier)? wildWhere?
#showColumns
| SHOW ((CHAR SET) | CHARSET) wildWhere?
#showCharset
| SHOW COUNT LEFT_PAREN ASTERISK RIGHT_PAREN (WARNINGS | ERRORS)
#showWaringErrorCount
- | SHOW (WARNINGS | ERRORS) limitClause?
#showWaringErrors
| SHOW LOAD WARNINGS ((((FROM | IN) database=multipartIdentifier)?
wildWhere? limitClause?) | (ON url=STRING_LITERAL))
#showLoadWarings
| SHOW STREAM? LOAD ((FROM | IN) database=multipartIdentifier)? wildWhere?
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 a825f80f4e0..12ae62bac10 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
@@ -280,6 +280,7 @@ import
org.apache.doris.nereids.DorisParser.ShowTrashContext;
import org.apache.doris.nereids.DorisParser.ShowTriggersContext;
import org.apache.doris.nereids.DorisParser.ShowVariablesContext;
import org.apache.doris.nereids.DorisParser.ShowViewContext;
+import org.apache.doris.nereids.DorisParser.ShowWarningErrorsContext;
import org.apache.doris.nereids.DorisParser.ShowWhitelistContext;
import org.apache.doris.nereids.DorisParser.SimpleColumnDefContext;
import org.apache.doris.nereids.DorisParser.SimpleColumnDefsContext;
@@ -586,6 +587,7 @@ import
org.apache.doris.nereids.trees.plans.commands.ShowTrashCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTriggersCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowVariablesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowViewCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowWarningErrorsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowWhiteListCommand;
import org.apache.doris.nereids.trees.plans.commands.SyncCommand;
import
org.apache.doris.nereids.trees.plans.commands.UnsetDefaultStorageVaultCommand;
@@ -4838,6 +4840,22 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
return new RecoverDatabaseCommand(dbName, dbId, newDbName);
}
+ @Override
+ public LogicalPlan visitShowWarningErrors(ShowWarningErrorsContext ctx) {
+ boolean isWarning = ctx.WARNINGS() != null;
+
+ // Extract the limit value if present
+ long limit = 0;
+ Optional<LimitClauseContext> limitCtx =
Optional.ofNullable(ctx.limitClause());
+ if (ctx.limitClause() != null) {
+ limit = Long.parseLong(limitCtx.get().limit.getText());
+ if (limit < 0) {
+ throw new ParseException("Limit requires non-negative number",
limitCtx.get());
+ }
+ }
+ return new ShowWarningErrorsCommand(isWarning, limit);
+ }
+
@Override
public RecoverTableCommand visitRecoverTable(RecoverTableContext ctx) {
List<String> dbTblNameParts = visitMultipartIdentifier(ctx.name);
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 b0e475a8161..9bab39c946b 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
@@ -241,6 +241,7 @@ public enum PlanType {
SHOW_VARIABLES_COMMAND,
SHOW_AUTHORS_COMMAND,
SHOW_VIEW_COMMAND,
+ SHOW_WARNING_ERRORS_COMMAND,
SHOW_WHITE_LIST_COMMAND,
SHOW_TABLETS_BELONG_COMMAND,
SYNC_COMMAND,
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowWarningErrorsCommand.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowWarningErrorsCommand.java
new file mode 100644
index 00000000000..09814a34b71
--- /dev/null
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowWarningErrorsCommand.java
@@ -0,0 +1,64 @@
+// 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;
+
+/**
+ * Represents the command for SHOW WARNINGS or SHOW ERRORS.
+ */
+public class ShowWarningErrorsCommand extends ShowCommand {
+ private static final ShowResultSetMetaData META_DATA =
+ ShowResultSetMetaData.builder()
+ .addColumn(new Column("Level",
ScalarType.createVarchar(20)))
+ .addColumn(new Column("Code",
ScalarType.createVarchar(10)))
+ .addColumn(new Column("Message",
ScalarType.createVarchar(100)))
+ .build();
+
+ private final boolean isWarning;
+ private final long limit;
+
+ public ShowWarningErrorsCommand(boolean isWarning, long limit) {
+ super(PlanType.SHOW_WARNING_ERRORS_COMMAND);
+ this.isWarning = isWarning;
+ this.limit = limit;
+ }
+
+ @Override
+ public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor)
throws Exception {
+ List<List<String>> rowSet = Lists.newArrayList();
+ // Only success
+ return new ShowResultSet(META_DATA, rowSet);
+ }
+
+ @Override
+ public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+ return visitor.visitShowWarningErrorsCommand(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 3634732077b..085b510b095 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.ShowTrashCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTriggersCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowVariablesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowViewCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowWarningErrorsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowWhiteListCommand;
import org.apache.doris.nereids.trees.plans.commands.SyncCommand;
import
org.apache.doris.nereids.trees.plans.commands.UnsetDefaultStorageVaultCommand;
@@ -302,6 +303,10 @@ public interface CommandVisitor<R, C> {
return visitCommand(showProcedureStatusCommand, context);
}
+ default R visitShowWarningErrorsCommand(ShowWarningErrorsCommand
showWarningErrorsCommand, C context) {
+ return visitCommand(showWarningErrorsCommand, context);
+ }
+
default R visitShowCreateProcedureCommand(ShowCreateProcedureCommand
showCreateProcedureCommand, C context) {
return visitCommand(showCreateProcedureCommand, context);
}
diff --git
a/regression-test/data/nereids_p0/show/test_show_warning_errors_command.out
b/regression-test/data/nereids_p0/show/test_show_warning_errors_command.out
new file mode 100644
index 00000000000..b62a27211f6
--- /dev/null
+++ b/regression-test/data/nereids_p0/show/test_show_warning_errors_command.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !cmd --
+
+-- !cmd --
+
diff --git
a/regression-test/suites/nereids_p0/show/test_show_warning_errors_command.groovy
b/regression-test/suites/nereids_p0/show/test_show_warning_errors_command.groovy
new file mode 100644
index 00000000000..b731caee95c
--- /dev/null
+++
b/regression-test/suites/nereids_p0/show/test_show_warning_errors_command.groovy
@@ -0,0 +1,27 @@
+// 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_warning_errors_command", "query,warnings_errors") {
+ // Execute the SHOW WARNINGS command and verify the output
+ checkNereidsExecute("SHOW ERRORS;")
+ qt_cmd("SHOW ERRORS;")
+
+
+ // Execute the SHOW WARNINGS command and verify the output
+ checkNereidsExecute("SHOW WARNINGS LIMIT 5;")
+ qt_cmd("SHOW WARNINGS LIMIT 5;")
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]