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 5a1959d1c1c [Enhancement] (nereids)implement showPluginsCommand in 
nereids (#43131)
5a1959d1c1c is described below

commit 5a1959d1c1c9b0c79be70b806e357a7dda678f08
Author: Vallish Pai <[email protected]>
AuthorDate: Mon Nov 18 16:46:34 2024 +0530

    [Enhancement] (nereids)implement showPluginsCommand in nereids (#43131)
    
    Issue Number: close #42733
---
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |  2 +-
 .../doris/nereids/parser/LogicalPlanBuilder.java   |  6 ++
 .../apache/doris/nereids/trees/plans/PlanType.java |  1 +
 .../trees/plans/commands/ShowPluginsCommand.java   | 77 ++++++++++++++++++++++
 .../trees/plans/visitor/CommandVisitor.java        |  5 ++
 .../show/test_nereids_show_plugins.groovy          | 22 +++++++
 6 files changed, 112 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 56eb4174068..ff155e7672f 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
@@ -202,6 +202,7 @@ supportedShowStatement
     | SHOW VIEW
         (FROM |IN) tableName=multipartIdentifier
         ((FROM | IN) database=identifier)?                                     
     #showView
+    | SHOW PLUGINS                                                             
     #showPlugins    
     | SHOW REPOSITORIES                                                        
     #showRepositories
     | SHOW ROLES                                                               
     #showRoles        
     | SHOW PARTITION partitionId=INTEGER_VALUE                                 
     #showPartitionId
@@ -258,7 +259,6 @@ unsupportedShowStatement
     | 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 PLUGINS                                                             
     #showPlugins
     | SHOW BRIEF? CREATE TABLE name=multipartIdentifier                        
     #showCreateTable
     | SHOW CREATE VIEW name=multipartIdentifier                                
     #showCreateView
     | SHOW CREATE MATERIALIZED VIEW name=multipartIdentifier                   
     #showMaterializedView
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 2b6716d69b0..05399ab63e7 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
@@ -204,6 +204,7 @@ import 
org.apache.doris.nereids.DorisParser.ShowCreateProcedureContext;
 import org.apache.doris.nereids.DorisParser.ShowFrontendsContext;
 import org.apache.doris.nereids.DorisParser.ShowLastInsertContext;
 import org.apache.doris.nereids.DorisParser.ShowPartitionIdContext;
+import org.apache.doris.nereids.DorisParser.ShowPluginsContext;
 import org.apache.doris.nereids.DorisParser.ShowProcContext;
 import org.apache.doris.nereids.DorisParser.ShowProcedureStatusContext;
 import org.apache.doris.nereids.DorisParser.ShowRepositoriesContext;
@@ -449,6 +450,7 @@ import 
org.apache.doris.nereids.trees.plans.commands.ShowCreateProcedureCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowFrontendsCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowLastInsertCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowPartitionIdCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowPluginsCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowProcCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.ShowProcedureStatusCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowRepositoriesCommand;
@@ -4105,6 +4107,10 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
         return new ShowBackendsCommand();
     }
 
+    public LogicalPlan visitShowPlugins(ShowPluginsContext ctx) {
+        return new ShowPluginsCommand();
+    }
+
     @Override
     public LogicalPlan visitShowRepositories(ShowRepositoriesContext ctx) {
         return new ShowRepositoriesCommand();
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 ce34ee818ff..7763a85bd5e 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
@@ -183,6 +183,7 @@ public enum PlanType {
     SHOW_LAST_INSERT_COMMAND,
     SHOW_PARTITIONID_COMMAND,
     SHOW_PROC_COMMAND,
+    SHOW_PLUGINS_COMMAND,
     SHOW_REPOSITORIES_COMMAND,
     SHOW_ROLE_COMMAND,
     SHOW_STORAGE_ENGINES_COMMAND,
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowPluginsCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowPluginsCommand.java
new file mode 100644
index 00000000000..1f66e8614ec
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowPluginsCommand.java
@@ -0,0 +1,77 @@
+// 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.Env;
+import org.apache.doris.catalog.ScalarType;
+import org.apache.doris.common.ErrorCode;
+import org.apache.doris.common.ErrorReport;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+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 java.util.List;
+
+/**
+ * show plugins command
+ */
+public class ShowPluginsCommand extends ShowCommand {
+    private static final ShowResultSetMetaData META_DATA =
+            ShowResultSetMetaData.builder()
+                    .addColumn(new Column("Name", 
ScalarType.createVarchar(64)))
+                    .addColumn(new Column("Type", 
ScalarType.createVarchar(10)))
+                    .addColumn(new Column("Description", 
ScalarType.createVarchar(200)))
+                    .addColumn(new Column("Version", 
ScalarType.createVarchar(20)))
+                    .addColumn(new Column("JavaVersion", 
ScalarType.createVarchar(20)))
+                    .addColumn(new Column("ClassName", 
ScalarType.createVarchar(64)))
+                    .addColumn(new Column("SoName", 
ScalarType.createVarchar(64)))
+                    .addColumn(new Column("Sources", 
ScalarType.createVarchar(200)))
+                    .addColumn(new Column("Status", 
ScalarType.createVarchar(20)))
+                    .addColumn(new Column("Properties", 
ScalarType.createVarchar(250)))
+                    .build();
+
+    /**
+     * constructor
+     */
+
+    public ShowPluginsCommand() {
+        super(PlanType.SHOW_PLUGINS_COMMAND);
+    }
+
+    @Override
+    public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor) 
throws Exception {
+        // check auth
+        if 
(!Env.getCurrentEnv().getAccessManager().checkGlobalPriv(ConnectContext.get(), 
PrivPredicate.ADMIN)) {
+            
ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR,
+                    PrivPredicate.ADMIN.getPrivs().toString());
+        }
+
+        List<List<String>> rows = 
Env.getCurrentPluginMgr().getPluginShowInfos();
+        return new ShowResultSet(META_DATA, rows);
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitShowPluginsCommand(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 26917aeca77..db75e0de41b 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
@@ -60,6 +60,7 @@ import 
org.apache.doris.nereids.trees.plans.commands.ShowCreateProcedureCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowFrontendsCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowLastInsertCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowPartitionIdCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowPluginsCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowProcCommand;
 import 
org.apache.doris.nereids.trees.plans.commands.ShowProcedureStatusCommand;
 import org.apache.doris.nereids.trees.plans.commands.ShowRepositoriesCommand;
@@ -273,6 +274,10 @@ public interface CommandVisitor<R, C> {
         return visitCommand(showBackendsCommand, context);
     }
 
+    default R visitShowPluginsCommand(ShowPluginsCommand showPluginsCommand, C 
context) {
+        return visitCommand(showPluginsCommand, context);
+    }
+
     default R visitShowRepositoriesCommand(ShowRepositoriesCommand 
showRepositoriesCommand, C context) {
         return visitCommand(showRepositoriesCommand, context);
     }
diff --git 
a/regression-test/suites/nereids_p0/show/test_nereids_show_plugins.groovy 
b/regression-test/suites/nereids_p0/show/test_nereids_show_plugins.groovy
new file mode 100644
index 00000000000..c79d7657a95
--- /dev/null
+++ b/regression-test/suites/nereids_p0/show/test_nereids_show_plugins.groovy
@@ -0,0 +1,22 @@
+// 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_nereids_show_plugins") {
+    checkNereidsExecute("""show plugins;""")
+}
+


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to