Skip to content

Commit

Permalink
[Enhancement] (nereids)implement showEventsCommand in nereids (apache…
Browse files Browse the repository at this point in the history
…#44499)

Issue Number: close apache#42732
  • Loading branch information
Vallishp authored Nov 27, 2024
1 parent bf67d44 commit 9c640d8
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ supportedShowStatement
| SHOW AUTHORS #showAuthors
| SHOW BROKER #showBroker
| SHOW DYNAMIC PARTITION TABLES ((FROM | IN) database=multipartIdentifier)? #showDynamicPartition
| SHOW EVENTS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showEvents
| SHOW LAST INSERT #showLastInsert
| SHOW DELETE ((FROM | IN) database=multipartIdentifier)? #showDelete
| SHOW ALL? GRANTS #showGrants
Expand Down Expand Up @@ -287,7 +288,6 @@ unsupportedShowStatement
| SHOW FULL? VIEWS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showViews
| SHOW FULL? PROCESSLIST #showProcessList
| SHOW (GLOBAL | SESSION | LOCAL)? STATUS wildWhere? #showStatus
| SHOW EVENTS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showEvents
| SHOW CREATE VIEW name=multipartIdentifier #showCreateView
| SHOW CREATE MATERIALIZED VIEW name=multipartIdentifier #showMaterializedView
| SHOW CREATE (DATABASE | SCHEMA) name=multipartIdentifier #showCreateDatabase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
import org.apache.doris.nereids.DorisParser.ShowCreateTableContext;
import org.apache.doris.nereids.DorisParser.ShowDeleteContext;
import org.apache.doris.nereids.DorisParser.ShowDynamicPartitionContext;
import org.apache.doris.nereids.DorisParser.ShowEventsContext;
import org.apache.doris.nereids.DorisParser.ShowFrontendsContext;
import org.apache.doris.nereids.DorisParser.ShowGrantsContext;
import org.apache.doris.nereids.DorisParser.ShowGrantsForUserContext;
Expand Down Expand Up @@ -493,6 +494,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowCreateTableCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowDeleteCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowDynamicPartitionCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowEventsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowFrontendsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowGrantsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowLastInsertCommand;
Expand Down Expand Up @@ -4013,6 +4015,11 @@ public LogicalPlan visitShowAuthors(ShowAuthorsContext ctx) {
return new ShowAuthorsCommand();
}

@Override
public LogicalPlan visitShowEvents(ShowEventsContext ctx) {
return new ShowEventsCommand();
}

@Override
public LogicalPlan visitShowConfig(ShowConfigContext ctx) {
ShowConfigCommand command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public enum PlanType {
SHOW_CREATE_TABLE_COMMAND,
SHOW_DELETE_COMMAND,
SHOW_DYNAMIC_PARTITION_COMMAND,
SHOW_EVENTS_COMMAND,
SHOW_FRONTENDS_COMMAND,
SHOW_GRANTS_COMMAND,
SHOW_LAST_INSERT_COMMAND,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// 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 events
*/
public class ShowEventsCommand extends ShowCommand {
private static final ShowResultSetMetaData META_DATA =
ShowResultSetMetaData.builder()
.addColumn(new Column("Db", ScalarType.createVarchar(20)))
.addColumn(new Column("Name", ScalarType.createVarchar(30)))
.addColumn(new Column("Definer", ScalarType.createVarchar(20)))
.addColumn(new Column("Time", ScalarType.createVarchar(20)))
.addColumn(new Column("Type", ScalarType.createVarchar(20)))
.addColumn(new Column("Execute at", ScalarType.createVarchar(20)))
.addColumn(new Column("Interval value", ScalarType.createVarchar(30)))
.addColumn(new Column("Interval field", ScalarType.createVarchar(30)))
.addColumn(new Column("Status", ScalarType.createVarchar(30)))
.addColumn(new Column("Ends", ScalarType.createVarchar(30)))
.addColumn(new Column("Status", ScalarType.createVarchar(30)))
.addColumn(new Column("Originator", ScalarType.createVarchar(30)))
.addColumn(new Column("character_set_client", ScalarType.createVarchar(30)))
.addColumn(new Column("collation_connection", ScalarType.createVarchar(30)))
.addColumn(new Column("Database Collation", ScalarType.createVarchar(30)))
.build();

public ShowEventsCommand() {
super(PlanType.SHOW_EVENTS_COMMAND);
}

@Override
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
return visitor.visitShowEventsCommand(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 @@ -77,6 +77,7 @@
import org.apache.doris.nereids.trees.plans.commands.ShowCreateTableCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowDeleteCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowDynamicPartitionCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowEventsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowFrontendsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowGrantsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowLastInsertCommand;
Expand Down Expand Up @@ -457,6 +458,10 @@ default R visitSyncCommand(SyncCommand syncCommand, C context) {
return visitCommand(syncCommand, context);
}

default R visitShowEventsCommand(ShowEventsCommand showEventsCommand, C context) {
return visitCommand(showEventsCommand, context);
}

default R visitShowDeleteCommand(ShowDeleteCommand showDeleteCommand, C context) {
return visitCommand(showDeleteCommand, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ suite("test_show_commands_nereids") {
checkNereidsExecute("""show backends;""")
checkNereidsExecute("""show whitelist;""")
checkNereidsExecute("""show triggers;""")
checkNereidsExecute("""show events;""")
checkNereidsExecute("""show load profile \"\\";""")
}

0 comments on commit 9c640d8

Please sign in to comment.