Skip to content

Commit

Permalink
[Feat](Nereids) support show authors command
Browse files Browse the repository at this point in the history
  • Loading branch information
GentleCold committed Nov 10, 2024
1 parent 9c66acd commit 675e1e5
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ supportedDropStatement

supportedShowStatement
: SHOW (GLOBAL | SESSION | LOCAL)? VARIABLES wildWhere? #showVariables
| SHOW AUTHORS #showAuthors
| SHOW VIEW
(FROM |IN) tableName=multipartIdentifier
((FROM | IN) database=identifier)? #showView
Expand Down Expand Up @@ -243,7 +244,6 @@ unsupportedShowStatement
| SHOW EVENTS ((FROM | IN) database=multipartIdentifier)? wildWhere? #showEvents
| SHOW PLUGINS #showPlugins
| SHOW STORAGE? ENGINES #showStorageEngines
| SHOW AUTHORS #showAuthors
| SHOW BRIEF? CREATE TABLE name=multipartIdentifier #showCreateTable
| SHOW CREATE VIEW name=multipartIdentifier #showCreateView
| SHOW CREATE MATERIALIZED VIEW name=multipartIdentifier #showMaterializedView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
import org.apache.doris.nereids.DorisParser.SetUserPropertiesContext;
import org.apache.doris.nereids.DorisParser.SetUserVariableContext;
import org.apache.doris.nereids.DorisParser.SetVariableWithTypeContext;
import org.apache.doris.nereids.DorisParser.ShowAuthorsContext;
import org.apache.doris.nereids.DorisParser.ShowConfigContext;
import org.apache.doris.nereids.DorisParser.ShowConstraintContext;
import org.apache.doris.nereids.DorisParser.ShowCreateMTMVContext;
Expand Down Expand Up @@ -422,6 +423,7 @@
import org.apache.doris.nereids.trees.plans.commands.SetOptionsCommand;
import org.apache.doris.nereids.trees.plans.commands.SetTransactionCommand;
import org.apache.doris.nereids.trees.plans.commands.SetUserPropertiesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowAuthorsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowConfigCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowConstraintsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowCreateMTMVCommand;
Expand Down Expand Up @@ -3879,6 +3881,11 @@ public LogicalPlan visitCreateTableLike(CreateTableLikeContext ctx) {
return new CreateTableLikeCommand(info);
}

@Override
public LogicalPlan visitShowAuthors(ShowAuthorsContext ctx) {
return new ShowAuthorsCommand();
}

@Override
public LogicalPlan visitShowConfig(ShowConfigContext ctx) {
ShowConfigCommand command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public enum PlanType {
EXECUTE_COMMAND,
SHOW_CONFIG_COMMAND,
SHOW_VARIABLES_COMMAND,
SHOW_AUTHORS_COMMAND,
SHOW_VIEW_COMMAND,
REPLAY_COMMAND
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// 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;

/**
* ShowAuthorsCommand
*/
public class ShowAuthorsCommand extends ShowCommand {
private static final ShowResultSetMetaData META_DATA =
ShowResultSetMetaData.builder()
.addColumn(new Column("Name", ScalarType.createVarchar(30)))
.addColumn(new Column("Location", ScalarType.createVarchar(30)))
.addColumn(new Column("Comment", ScalarType.createVarchar(30)))
.build();

public ShowAuthorsCommand() {
super(PlanType.SHOW_AUTHORS_COMMAND);
}

@Override
public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
return visitor.visitShowAuthorsCommand(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 @@ -47,6 +47,7 @@
import org.apache.doris.nereids.trees.plans.commands.SetOptionsCommand;
import org.apache.doris.nereids.trees.plans.commands.SetTransactionCommand;
import org.apache.doris.nereids.trees.plans.commands.SetUserPropertiesCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowAuthorsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowConfigCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowConstraintsCommand;
import org.apache.doris.nereids.trees.plans.commands.ShowCreateMTMVCommand;
Expand Down Expand Up @@ -215,6 +216,10 @@ default R visitCreateTableLikeCommand(CreateTableLikeCommand createTableLikeComm
return visitCommand(createTableLikeCommand, context);
}

default R visitShowAuthorsCommand(ShowAuthorsCommand showAuthorsCommand, C context) {
return visitCommand(showAuthorsCommand, context);
}

default R visitShowConfigCommand(ShowConfigCommand showConfigCommand, C context) {
return visitCommand(showConfigCommand, context);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !cmd --

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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("show_authors_command") {
checkNereidsExecute("""show authors;""")
qt_cmd("""show authors;""")
}

0 comments on commit 675e1e5

Please sign in to comment.