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 d2473ce37d3 [Enhancement] (nereids)implement showStorageEnginesCommand 
in nereids (#43135)
d2473ce37d3 is described below

commit d2473ce37d36270d62fe8ec50cee1ffc0d0e3e81
Author: Vallish Pai <[email protected]>
AuthorDate: Sat Nov 16 17:33:56 2024 +0530

    [Enhancement] (nereids)implement showStorageEnginesCommand in nereids 
(#43135)
    
    Issue Number: close #42734
---
 .../antlr4/org/apache/doris/nereids/DorisParser.g4 |  2 +-
 .../doris/nereids/parser/LogicalPlanBuilder.java   |  7 ++
 .../apache/doris/nereids/trees/plans/PlanType.java |  1 +
 .../plans/commands/ShowStorageEnginesCommand.java  | 87 ++++++++++++++++++++++
 .../trees/plans/visitor/CommandVisitor.java        |  5 ++
 .../nereids_p0/show/test_show_engines_nereids.out  | 19 +++++
 .../show/test_show_engines_nereids.groovy          | 24 ++++++
 7 files changed, 144 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 0b851440bfe..5bbfcfc177f 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
@@ -205,6 +205,7 @@ supportedShowStatement
     | SHOW REPOSITORIES                                                        
     #showRepositories
     | SHOW ROLES                                                               
     #showRoles        
     | SHOW PROC path=STRING_LITERAL                                            
     #showProc        
+    | SHOW STORAGE? ENGINES                                                    
     #showStorageEngines
     | SHOW CREATE MATERIALIZED VIEW mvName=identifier
         ON tableName=multipartIdentifier                                       
     #showCreateMaterializedView   
     ;
@@ -255,7 +256,6 @@ unsupportedShowStatement
     | SHOW FULL? TRIGGERS ((FROM | IN) database=multipartIdentifier)? 
wildWhere?    #showTriggers
     | SHOW EVENTS ((FROM | IN) database=multipartIdentifier)? wildWhere?       
     #showEvents
     | SHOW PLUGINS                                                             
     #showPlugins
-    | SHOW STORAGE? ENGINES                                                    
     #showStorageEngines
     | 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 a7a0c970f0b..9f362ab5e24 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
@@ -205,6 +205,7 @@ import org.apache.doris.nereids.DorisParser.ShowProcContext;
 import org.apache.doris.nereids.DorisParser.ShowProcedureStatusContext;
 import org.apache.doris.nereids.DorisParser.ShowRepositoriesContext;
 import org.apache.doris.nereids.DorisParser.ShowRolesContext;
+import org.apache.doris.nereids.DorisParser.ShowStorageEnginesContext;
 import org.apache.doris.nereids.DorisParser.ShowVariablesContext;
 import org.apache.doris.nereids.DorisParser.ShowViewContext;
 import org.apache.doris.nereids.DorisParser.SimpleColumnDefContext;
@@ -445,6 +446,7 @@ 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;
 import org.apache.doris.nereids.trees.plans.commands.ShowRolesCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowStorageEnginesCommand;
 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.UnsetDefaultStorageVaultCommand;
@@ -4097,6 +4099,11 @@ public class LogicalPlanBuilder extends 
DorisParserBaseVisitor<Object> {
         return new ShowProcCommand(path);
     }
 
+    @Override
+    public LogicalPlan visitShowStorageEngines(ShowStorageEnginesContext ctx) {
+        return new ShowStorageEnginesCommand();
+    }
+
     @Override
     public LogicalPlan 
visitShowCreateMaterializedView(ShowCreateMaterializedViewContext ctx) {
         List<String> nameParts = visitMultipartIdentifier(ctx.tableName);
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 99ba411f1e8..71832ab23b8 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
@@ -182,6 +182,7 @@ public enum PlanType {
     SHOW_PROC_COMMAND,
     SHOW_REPOSITORIES_COMMAND,
     SHOW_ROLE_COMMAND,
+    SHOW_STORAGE_ENGINES_COMMAND,
     SHOW_VARIABLES_COMMAND,
     SHOW_AUTHORS_COMMAND,
     SHOW_VIEW_COMMAND,
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowStorageEnginesCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowStorageEnginesCommand.java
new file mode 100644
index 00000000000..e57d3d40916
--- /dev/null
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowStorageEnginesCommand.java
@@ -0,0 +1,87 @@
+// 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 org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.List;
+
+/**
+ * show storage engines command
+ */
+public class ShowStorageEnginesCommand extends ShowCommand {
+    public static final Logger LOG = 
LogManager.getLogger(ShowStorageEnginesCommand.class);
+
+    /**
+     * constructor
+     */
+    public ShowStorageEnginesCommand() {
+        super(PlanType.SHOW_STORAGE_ENGINES_COMMAND);
+    }
+
+    /**
+     * get meta for show tableId
+     */
+    public ShowResultSetMetaData getMetaData() {
+        ShowResultSetMetaData.Builder builder = 
ShowResultSetMetaData.builder();
+        builder.addColumn(new Column("Engine", ScalarType.createVarchar(64)));
+        builder.addColumn(new Column("Support", ScalarType.createVarchar(8)));
+        builder.addColumn(new Column("Comment", ScalarType.createVarchar(80)));
+        builder.addColumn(new Column("Transactions", 
ScalarType.createVarchar(3)));
+        builder.addColumn(new Column("XA", ScalarType.createVarchar(3)));
+        builder.addColumn(new Column("Savepoints", 
ScalarType.createVarchar(3)));
+        return builder.build();
+    }
+
+    private ShowResultSet handleShowEngines(ConnectContext ctx, StmtExecutor 
executor) throws Exception {
+        List<List<String>> rowSet = Lists.newArrayList();
+        rowSet.add(Lists.newArrayList("Olap engine", "YES", "Default storage 
engine of palo", "NO", "NO", "NO"));
+        rowSet.add(Lists.newArrayList("MySQL", "YES", "MySQL server which data 
is in it", "NO", "NO", "NO"));
+        rowSet.add(Lists.newArrayList("ELASTICSEARCH", "YES", "ELASTICSEARCH 
cluster which data is in it",
+                "NO", "NO", "NO"));
+        rowSet.add(Lists.newArrayList("HIVE", "YES", "HIVE database which data 
is in it", "NO", "NO", "NO"));
+        rowSet.add(Lists.newArrayList("ICEBERG", "YES", "ICEBERG data lake 
which data is in it", "NO", "NO", "NO"));
+        rowSet.add(Lists.newArrayList("ODBC", "YES", "ODBC driver which data 
we can connect", "NO", "NO", "NO"));
+        rowSet.add(Lists.newArrayList("HUDI", "YES", "HUDI data lake which 
data is in it", "NO", "NO", "NO"));
+
+        // Only success
+        ShowResultSet resultSet = new ShowResultSet(getMetaData(), rowSet);
+        return resultSet;
+    }
+
+    @Override
+    public ShowResultSet doRun(ConnectContext ctx, StmtExecutor executor) 
throws Exception {
+        return handleShowEngines(ctx, executor);
+    }
+
+    @Override
+    public <R, C> R accept(PlanVisitor<R, C> visitor, C context) {
+        return visitor.visitShowStorageEnginesCommand(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 b38684582a1..f10bedffc6c 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
@@ -61,6 +61,7 @@ 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;
 import org.apache.doris.nereids.trees.plans.commands.ShowRolesCommand;
+import org.apache.doris.nereids.trees.plans.commands.ShowStorageEnginesCommand;
 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.UnsetDefaultStorageVaultCommand;
@@ -272,6 +273,10 @@ public interface CommandVisitor<R, C> {
         return visitCommand(showProcCommand, context);
     }
 
+    default R visitShowStorageEnginesCommand(ShowStorageEnginesCommand 
showStorageEnginesCommand, C context) {
+        return visitCommand(showStorageEnginesCommand, context);
+    }
+
     default R 
visitShowCreateMaterializedViewCommand(ShowCreateMaterializedViewCommand 
showCreateMtlzViewCommand,
                         C context) {
         return visitCommand(showCreateMtlzViewCommand, context);
diff --git a/regression-test/data/nereids_p0/show/test_show_engines_nereids.out 
b/regression-test/data/nereids_p0/show/test_show_engines_nereids.out
new file mode 100644
index 00000000000..93face908dc
--- /dev/null
+++ b/regression-test/data/nereids_p0/show/test_show_engines_nereids.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !cmd_1 --
+Olap engine    YES     Default storage engine of palo  NO      NO      NO
+MySQL  YES     MySQL server which data is in it        NO      NO      NO
+ELASTICSEARCH  YES     ELASTICSEARCH cluster which data is in it       NO      
NO      NO
+HIVE   YES     HIVE database which data is in it       NO      NO      NO
+ICEBERG        YES     ICEBERG data lake which data is in it   NO      NO      
NO
+ODBC   YES     ODBC driver which data we can connect   NO      NO      NO
+HUDI   YES     HUDI data lake which data is in it      NO      NO      NO
+
+-- !cmd_2 --
+Olap engine    YES     Default storage engine of palo  NO      NO      NO
+MySQL  YES     MySQL server which data is in it        NO      NO      NO
+ELASTICSEARCH  YES     ELASTICSEARCH cluster which data is in it       NO      
NO      NO
+HIVE   YES     HIVE database which data is in it       NO      NO      NO
+ICEBERG        YES     ICEBERG data lake which data is in it   NO      NO      
NO
+ODBC   YES     ODBC driver which data we can connect   NO      NO      NO
+HUDI   YES     HUDI data lake which data is in it      NO      NO      NO
+
diff --git 
a/regression-test/suites/nereids_p0/show/test_show_engines_nereids.groovy 
b/regression-test/suites/nereids_p0/show/test_show_engines_nereids.groovy
new file mode 100644
index 00000000000..4ef725a4adf
--- /dev/null
+++ b/regression-test/suites/nereids_p0/show/test_show_engines_nereids.groovy
@@ -0,0 +1,24 @@
+// 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_engines_nereids") {
+    checkNereidsExecute("show engines;")
+    qt_cmd_1("show engines;")
+    checkNereidsExecute("show storage engines;")
+    qt_cmd_2("show storage engines;")    
+    // can not use qt to check, the output may change.
+}


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

Reply via email to