Skip to content

Commit

Permalink
[Enhancement] (nereids)implement showTriggersCommand in nereids
Browse files Browse the repository at this point in the history
  • Loading branch information
Vallishp committed Nov 19, 2024
1 parent 701573c commit 9b85bdd
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ supportedShowStatement
| SHOW CREATE MATERIALIZED VIEW mvName=identifier
ON tableName=multipartIdentifier #showCreateMaterializedView
| SHOW BACKENDS #showBackends
| SHOW FULL? TRIGGERS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showTriggers
| SHOW FRONTENDS name=identifier? #showFrontends
| SHOW TABLE tableId=INTEGER_VALUE #showTableId
| SHOW WHITELIST #showWhitelist
Expand Down Expand Up @@ -261,7 +262,6 @@ unsupportedShowStatement
| SHOW FULL? VIEWS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showViews
| SHOW FULL? PROCESSLIST #showProcessList
| SHOW (GLOBAL | SESSION | LOCAL)? STATUS wildWhere? #showStatus
| SHOW FULL? TRIGGERS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showTriggers
| SHOW EVENTS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showEvents
| SHOW BRIEF? CREATE TABLE name=multipartIdentifier #showCreateTable
| SHOW CREATE VIEW name=multipartIdentifier #showCreateView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
import org.apache.doris.nereids.DorisParser.ShowSqlBlockRuleContext;
import org.apache.doris.nereids.DorisParser.ShowStorageEnginesContext;
import org.apache.doris.nereids.DorisParser.ShowTableIdContext;
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.ShowWhitelistContext;
Expand Down Expand Up @@ -466,6 +467,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowSqlBlockRuleCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowStorageEnginesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTableIdCommand;
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.ShowWhiteListCommand;
Expand Down Expand Up @@ -4142,6 +4144,7 @@ public LogicalPlan visitShowBackends(ShowBackendsContext ctx) {
return new ShowBackendsCommand();
}

@Override
public LogicalPlan visitShowPlugins(ShowPluginsContext ctx) {
return new ShowPluginsCommand();
}
Expand All @@ -4155,6 +4158,11 @@ public LogicalPlan visitShowSqlBlockRule(ShowSqlBlockRuleContext ctx) {
return new ShowSqlBlockRuleCommand(ruleName);
}

@Override
public LogicalPlan visitShowTriggers(ShowTriggersContext ctx) {
return new ShowTriggersCommand();
}

@Override
public LogicalPlan visitShowRepositories(ShowRepositoriesContext ctx) {
return new ShowRepositoriesCommand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public enum PlanType {
SHOW_ROLE_COMMAND,
SHOW_STORAGE_ENGINES_COMMAND,
SHOW_TABLE_ID_COMMAND,
SHOW_TRIGGERS_COMMAND,
SHOW_VARIABLES_COMMAND,
SHOW_AUTHORS_COMMAND,
SHOW_VIEW_COMMAND,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// 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;

/**
* show triggers command
*/
public class ShowTriggersCommand extends ShowCommand {
private static final ShowResultSetMetaData META_DATA =
ShowResultSetMetaData.builder()
.addColumn(new Column("Trigger", ScalarType.createVarchar(64)))
.addColumn(new Column("Event", ScalarType.createVarchar(10)))
.addColumn(new Column("Table", ScalarType.createVarchar(80)))
.addColumn(new Column("Statement", ScalarType.createVarchar(64)))
.addColumn(new Column("Timing", ScalarType.createVarchar(80)))
.addColumn(new Column("Created", ScalarType.createVarchar(80)))
.addColumn(new Column("sql_mode", ScalarType.createVarchar(80)))
.addColumn(new Column("Definer", ScalarType.createVarchar(80)))
.addColumn(new Column("character_set_client", ScalarType.createVarchar(80)))
.addColumn(new Column("collation_connection", ScalarType.createVarchar(80)))
.addColumn(new Column("Database Collation", ScalarType.createVarchar(80)))
.build();

public ShowTriggersCommand() {
super(PlanType.SHOW_TRIGGERS_COMMAND);
}

@Override
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
return visitor.visitShowTriggersCommand(this, context);
}

@Override
public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor) throws Exception {
List<List<String>> rowSet = Lists.newArrayList();
return new ShowResultSet(META_DATA, rowSet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowSqlBlockRuleCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowStorageEnginesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowTableIdCommand;
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.ShowWhiteListCommand;
Expand Down Expand Up @@ -295,6 +296,10 @@ default R visitShowPluginsCommand(ShowPluginsCommand showPluginsCommand, C conte
return visitCommand(showPluginsCommand, context);
}

default R visitShowTriggersCommand(ShowTriggersCommand showTriggersCommand, C context) {
return visitCommand(showTriggersCommand, context);
}

default R visitShowRepositoriesCommand(ShowRepositoriesCommand showRepositoriesCommand, C context) {
return visitCommand(showRepositoriesCommand, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ suite("test_show_commands_nereids") {
checkNereidsExecute("""show frontends;""")
checkNereidsExecute("""show backends;""")
checkNereidsExecute("""show whitelist;""")
checkNereidsExecute("""show triggers;""")

}

0 comments on commit 9b85bdd

Please sign in to comment.