This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new b017239  support postgresql analyze & load statement (#10382)
b017239 is described below

commit b017239ec9a9133b060a1e6b1ad409142a52c0cd
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Wed May 19 16:11:41 2021 +0800

    support postgresql analyze & load statement (#10382)
    
    * support postgresql analyze & load statement
    
    * fix checkstyle
---
 .../src/test/resources/sharding/analyze.xml        | 178 +++++++++++++++++++++
 .../engine/type/ShardingRouteEngineFactory.java    |  16 +-
 .../infra/binder/SQLStatementContextFactory.java   |   5 +
 .../dal/AnalyzeTableStatementContext.java          |  46 ++++++
 .../impl/MySQLDALStatementSQLVisitor.java          |   6 +-
 .../main/antlr4/imports/postgresql/DALStatement.g4 |   2 +-
 .../sql/parser/autogen/PostgreSQLStatement.g4      |   2 +
 .../impl/PostgreSQLDALStatementSQLVisitor.java     |  38 ++++-
 .../sql/parser/core/visitor/SQLVisitorRule.java    |   4 +
 .../statement/dal/AnalyzeTableStatement.java       |  10 ++
 .../postgresql/dal/PostgreSQLLoadStatement.java}   |  10 +-
 11 files changed, 303 insertions(+), 14 deletions(-)

diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/analyze.xml
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/analyze.xml
new file mode 100644
index 0000000..5e3c272
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-rewrite/src/test/resources/sharding/analyze.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<rewrite-assertions yaml-rule="yaml/sharding/sharding-rule.yaml">
+    <rewrite-assertion id="analyze_current_database_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE" />
+        <output sql="ANALYZE" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_data_node_sharding_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_order" />
+        <output sql="ANALYZE t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_multi_data_node_sharding_table_for_postgresql" db-type="PostgreSQL">
+        <input sql="ANALYZE t_account" />
+        <output sql="ANALYZE t_account_0" />
+        <output sql="ANALYZE t_account_1" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_broadcast_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_config" />
+        <output sql="ANALYZE t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_single" />
+        <output sql="ANALYZE t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_data_node_binding_table_for_postgresql" db-type="PostgreSQL">
+        <input sql="ANALYZE t_order, t_order_item" />
+        <output sql="ANALYZE t_order_0, t_order_item_0" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_data_node_unbinding_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_order, t_order_extend" />
+        <output sql="ANALYZE t_order_0, t_order_extend_0" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_multi_data_node_and_single_data_node_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_account, t_order" />
+        <output sql="ANALYZE t_account_0, t_order_0" />
+        <output sql="ANALYZE t_account_1, t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_multi_data_node_binding_table_for_postgresql" db-type="PostgreSQL">
+        <input sql="ANALYZE t_account, t_account_detail" />
+        <output sql="ANALYZE t_account_0, t_account_detail_0" />
+        <output sql="ANALYZE t_account_1, t_account_detail_1" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_data_node_and_broadcast_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_order, t_config" />
+        <output sql="ANALYZE t_order_0, t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_multi_data_node_and_broadcast_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_account, t_config" />
+        <output sql="ANALYZE t_account_0, t_config" />
+        <output sql="ANALYZE t_account_1, t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_data_node_and_single_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_order, t_single" />
+        <output sql="ANALYZE t_order_0, t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_multi_data_node_and_single_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_account, t_single" />
+        <output sql="ANALYZE t_account_0, t_single" />
+        <output sql="ANALYZE t_account_1, t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_broadcast_and_single_data_node_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_config, t_order" />
+        <output sql="ANALYZE t_config, t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_broadcast_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_config, t_order_type" />
+        <output sql="ANALYZE t_config, t_order_type" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_broadcast_and_single_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_config, t_single" />
+        <output sql="ANALYZE t_config, t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_and_single_data_node_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_single, t_order" />
+        <output sql="ANALYZE t_single, t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_and_broadcast_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_single, t_config" />
+        <output sql="ANALYZE t_single, t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_table_for_postgresql" 
db-type="PostgreSQL">
+        <input sql="ANALYZE t_single, t_single_extend" />
+        <output sql="ANALYZE t_single, t_single_extend" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_data_node_sharding_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_order" />
+        <output sql="ANALYZE TABLE t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_multi_data_node_sharding_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_account" />
+        <output sql="ANALYZE TABLE t_account_0" />
+        <output sql="ANALYZE TABLE t_account_1" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_broadcast_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_config" />
+        <output sql="ANALYZE TABLE t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_single" />
+        <output sql="ANALYZE TABLE t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_data_node_binding_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_order, t_order_item" />
+        <output sql="ANALYZE TABLE t_order_0, t_order_item_0" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_data_node_unbinding_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_order, t_order_extend" />
+        <output sql="ANALYZE TABLE t_order_0, t_order_extend_0" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_multi_data_node_and_single_data_node_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_account, t_order" />
+        <output sql="ANALYZE TABLE t_account_0, t_order_0" />
+        <output sql="ANALYZE TABLE t_account_1, t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_multi_data_node_binding_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_account, t_account_detail" />
+        <output sql="ANALYZE TABLE t_account_0, t_account_detail_0" />
+        <output sql="ANALYZE TABLE t_account_1, t_account_detail_1" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_data_node_and_broadcast_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_order, t_config" />
+        <output sql="ANALYZE TABLE t_order_0, t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_multi_data_node_and_broadcast_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_account, t_config" />
+        <output sql="ANALYZE TABLE t_account_0, t_config" />
+        <output sql="ANALYZE TABLE t_account_1, t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_data_node_and_single_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_order, t_single" />
+        <output sql="ANALYZE TABLE t_order_0, t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_multi_data_node_and_single_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_account, t_single" />
+        <output sql="ANALYZE TABLE t_account_0, t_single" />
+        <output sql="ANALYZE TABLE t_account_1, t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_broadcast_and_single_data_node_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_config, t_order" />
+        <output sql="ANALYZE TABLE t_config, t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_broadcast_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_config, t_order_type" />
+        <output sql="ANALYZE TABLE t_config, t_order_type" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_broadcast_and_single_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_config, t_single" />
+        <output sql="ANALYZE TABLE t_config, t_single" />
+    </rewrite-assertion>
+    <rewrite-assertion 
id="analyze_single_and_single_data_node_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_single, t_order" />
+        <output sql="ANALYZE TABLE t_single, t_order_0" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_and_broadcast_table_for_mysql" 
db-type="MySQL">
+        <input sql="ANALYZE TABLE t_single, t_config" />
+        <output sql="ANALYZE TABLE t_single, t_config" />
+    </rewrite-assertion>
+    <rewrite-assertion id="analyze_single_table_for_mysql" db-type="MySQL">
+        <input sql="ANALYZE TABLE t_single, t_single_extend" />
+        <output sql="ANALYZE TABLE t_single, t_single_extend" />
+    </rewrite-assertion>
+</rewrite-assertions>
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
index c9ff9bf..0e1bdc4 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/ShardingRouteEngineFactory.java
@@ -37,6 +37,7 @@ import 
org.apache.shardingsphere.sharding.route.engine.type.standard.ShardingSta
 import 
org.apache.shardingsphere.sharding.route.engine.type.unicast.ShardingUnicastRoutingEngine;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.AnalyzeTableStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.SetStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dcl.DCLStatement;
@@ -52,6 +53,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectState
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.tcl.TCLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLShowDatabasesStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLUseStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLLoadStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLResetParameterStatement;
 
 import java.util.Collection;
@@ -76,7 +78,6 @@ public final class ShardingRouteEngineFactory {
     public static ShardingRouteEngine newInstance(final ShardingRule 
shardingRule, final ShardingSphereMetaData metaData,
                                                   final SQLStatementContext<?> 
sqlStatementContext, final ShardingConditions shardingConditions, final 
ConfigurationProperties props) {
         SQLStatement sqlStatement = sqlStatementContext.getSqlStatement();
-        Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
         if (sqlStatement instanceof TCLStatement) {
             return new ShardingDatabaseBroadcastRoutingEngine();
         }
@@ -84,11 +85,12 @@ public final class ShardingRouteEngineFactory {
             return getDDLRoutingEngine(shardingRule, metaData, 
sqlStatementContext);
         }
         if (sqlStatement instanceof DALStatement) {
-            return getDALRoutingEngine(shardingRule, sqlStatement, tableNames);
+            return getDALRoutingEngine(shardingRule, metaData, 
sqlStatementContext);
         }
         if (sqlStatement instanceof DCLStatement) {
             return getDCLRoutingEngine(shardingRule, metaData, 
sqlStatementContext);
         }
+        Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
         return getDQLRoutingEngine(shardingRule, sqlStatementContext, 
shardingConditions, props, sqlStatement, tableNames);
     }
     
@@ -108,16 +110,22 @@ public final class ShardingRouteEngineFactory {
         return new ShardingTableBroadcastRoutingEngine(metaData.getSchema(), 
sqlStatementContext);
     }
     
-    private static ShardingRouteEngine getDALRoutingEngine(final ShardingRule 
shardingRule, final SQLStatement sqlStatement, final Collection<String> 
tableNames) {
+    private static ShardingRouteEngine getDALRoutingEngine(final ShardingRule 
shardingRule, final ShardingSphereMetaData metaData, final 
SQLStatementContext<?> sqlStatementContext) {
+        SQLStatement sqlStatement = sqlStatementContext.getSqlStatement();
+        Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
         if (sqlStatement instanceof MySQLUseStatement) {
             return new ShardingIgnoreRoutingEngine();
         }
-        if (sqlStatement instanceof SetStatement || sqlStatement instanceof 
PostgreSQLResetParameterStatement || sqlStatement instanceof 
MySQLShowDatabasesStatement) {
+        if (sqlStatement instanceof SetStatement || sqlStatement instanceof 
PostgreSQLResetParameterStatement 
+                || sqlStatement instanceof MySQLShowDatabasesStatement || 
sqlStatement instanceof PostgreSQLLoadStatement) {
             return new ShardingDatabaseBroadcastRoutingEngine();
         }
         if (!tableNames.isEmpty() && 
!shardingRule.tableRuleExists(tableNames)) {
             return new SingleTablesRoutingEngine(tableNames, sqlStatement);
         }
+        if (sqlStatement instanceof AnalyzeTableStatement) {
+            return tableNames.isEmpty() ? new 
ShardingDatabaseBroadcastRoutingEngine() : new 
ShardingTableBroadcastRoutingEngine(metaData.getSchema(), sqlStatementContext);
+        }
         if (!tableNames.isEmpty()) {
             return new ShardingUnicastRoutingEngine(tableNames);
         }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
index 6dbfd55..77841b6 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/SQLStatementContextFactory.java
@@ -21,6 +21,7 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
+import 
org.apache.shardingsphere.infra.binder.statement.dal.AnalyzeTableStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.ExplainStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.ShowColumnsStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.dal.ShowCreateTableStatementContext;
@@ -48,6 +49,7 @@ import 
org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementConte
 import 
org.apache.shardingsphere.infra.binder.statement.dml.UpdateStatementContext;
 import org.apache.shardingsphere.infra.metadata.schema.ShardingSphereSchema;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.AnalyzeTableStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.ExplainStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dcl.DCLStatement;
@@ -198,6 +200,9 @@ public final class SQLStatementContextFactory {
         if (sqlStatement instanceof MySQLShowIndexStatement) {
             return new ShowIndexStatementContext((MySQLShowIndexStatement) 
sqlStatement);
         }
+        if (sqlStatement instanceof AnalyzeTableStatement) {
+            return new AnalyzeTableStatementContext((AnalyzeTableStatement) 
sqlStatement);
+        }
         return new CommonSQLStatementContext<>(sqlStatement);
     }
 }
diff --git 
a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dal/AnalyzeTableStatementContext.java
 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dal/AnalyzeTableStatementContext.java
new file mode 100644
index 0000000..fa9df79
--- /dev/null
+++ 
b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dal/AnalyzeTableStatementContext.java
@@ -0,0 +1,46 @@
+/*
+ * 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.shardingsphere.infra.binder.statement.dal;
+
+import lombok.Getter;
+import org.apache.shardingsphere.infra.binder.segment.table.TablesContext;
+import 
org.apache.shardingsphere.infra.binder.statement.CommonSQLStatementContext;
+import org.apache.shardingsphere.infra.binder.type.TableAvailable;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.AnalyzeTableStatement;
+
+import java.util.Collection;
+
+/**
+ * Analyze table statement context.
+ */
+@Getter
+public final class AnalyzeTableStatementContext extends 
CommonSQLStatementContext<AnalyzeTableStatement> implements TableAvailable {
+    
+    private final TablesContext tablesContext;
+    
+    public AnalyzeTableStatementContext(final AnalyzeTableStatement 
sqlStatement) {
+        super(sqlStatement);
+        tablesContext = new TablesContext(sqlStatement.getTables());
+    }
+    
+    @Override
+    public Collection<SimpleTableSegment> getAllTables() {
+        return getSqlStatement().getTables();
+    }
+}
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
index f7f7ed3..70ba2d3 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLDALStatementSQLVisitor.java
@@ -78,6 +78,7 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableSegme
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.collection.CollectionValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.sql.common.value.literal.impl.StringLiteralValue;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLAnalyzeTableStatement;
@@ -202,9 +203,12 @@ public final class MySQLDALStatementSQLVisitor extends 
MySQLStatementSQLVisitor
         return new MySQLRepairTableStatement();
     }
     
+    @SuppressWarnings("unchecked")
     @Override
     public ASTNode visitAnalyzeTable(final AnalyzeTableContext ctx) {
-        return new MySQLAnalyzeTableStatement();
+        MySQLAnalyzeTableStatement result = new MySQLAnalyzeTableStatement();
+        result.getTables().addAll(((CollectionValue<SimpleTableSegment>) 
visit(ctx.tableList())).getValue());
+        return result;
     }
     
     @Override
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4
index 9bdf62c..4c352cd 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/imports/postgresql/DALStatement.g4
@@ -98,7 +98,7 @@ constraintsSetList
     : ALL | qualifiedNameList
     ;
 
-analyze
+analyzeTable
     : analyzeKeyword (VERBOSE? | LP_ vacAnalyzeOptionList RP_) 
vacuumRelationList?
     ;
 
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4
index 735667a..931a3c3 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/antlr4/org/apache/shardingsphere/sql/parser/autogen/PostgreSQLStatement.g4
@@ -72,5 +72,7 @@ execute
     | executeStmt
     | deallocate
     | explain
+    | analyzeTable
+    | load
     ) SEMI_?
     ;
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDALStatementSQLVisitor.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDALStatementSQLVisitor.java
index e1de9c9..83d2455 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDALStatementSQLVisitor.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-postgresql/src/main/java/org/apache/shardingsphere/sql/parser/postgresql/visitor/statement/impl/PostgreSQLDALStatementSQLVisitor.java
@@ -21,19 +21,27 @@ import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
 import 
org.apache.shardingsphere.sql.parser.api.visitor.operation.SQLStatementVisitor;
 import org.apache.shardingsphere.sql.parser.api.visitor.type.DALSQLVisitor;
-import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AnalyzeContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.AnalyzeTableContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.ColIdContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.ConfigurationParameterClauseContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.ExplainContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.ExplainableStmtContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.LoadContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.ResetParameterContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.SetContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.ShowContext;
 import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.VacuumContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.VacuumRelationContext;
+import 
org.apache.shardingsphere.sql.parser.autogen.PostgreSQLStatementParser.VacuumRelationListContext;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableAssignSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.dal.VariableSegment;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.collection.CollectionValue;
+import 
org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLAnalyzeTableStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLExplainStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLLoadStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLResetParameterStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLSetStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal.PostgreSQLShowStatement;
@@ -97,14 +105,34 @@ public final class PostgreSQLDALStatementSQLVisitor 
extends PostgreSQLStatementS
         return new PostgreSQLResetParameterStatement();
     }
     
+    @SuppressWarnings("unchecked")
     @Override
-    public ASTNode visitAnalyze(final AnalyzeContext ctx) {
-        return new PostgreSQLAnalyzeTableStatement();
+    public ASTNode visitAnalyzeTable(final AnalyzeTableContext ctx) {
+        PostgreSQLAnalyzeTableStatement result = new 
PostgreSQLAnalyzeTableStatement();
+        if (null != ctx.vacuumRelationList()) {
+            result.getTables().addAll(((CollectionValue<SimpleTableSegment>) 
visit(ctx.vacuumRelationList())).getValue());
+        }
+        return result;
     }
     
-    @Override 
+    @Override
+    public ASTNode visitVacuumRelationList(final VacuumRelationListContext 
ctx) {
+        CollectionValue<SimpleTableSegment> result = new CollectionValue<>();
+        for (VacuumRelationContext each : ctx.vacuumRelation()) {
+            ColIdContext colId = each.qualifiedName().colId();
+            result.getValue().add(new 
SimpleTableSegment(colId.start.getStartIndex(), colId.stop.getStopIndex(), new 
IdentifierValue(colId.getText())));
+        }
+        return result;
+    }
+    
+    @Override
+    public ASTNode visitLoad(final LoadContext ctx) {
+        return new PostgreSQLLoadStatement();
+    }
+    
+    @Override
     public ASTNode visitVacuum(final VacuumContext ctx) {
-        return new PostgreSQLVacuumStatement(); 
+        return new PostgreSQLVacuumStatement();
     }
     
     @Override
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
index 3af934b..d5875ea 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-engine/src/main/java/org/apache/shardingsphere/sql/parser/core/visitor/SQLVisitorRule.java
@@ -214,6 +214,10 @@ public enum SQLVisitorRule {
     
     CREATE_LOADABLE_FUNCTION("CreateLoadableFunction", SQLStatementType.DAL),
     
+    ANALYZE("AnalyzeTable", SQLStatementType.DAL),
+    
+    LOAD("Load", SQLStatementType.DAL),
+    
     CALL("Call", SQLStatementType.DML),
     
     CHANGE_MASTER("ChangeMaster", SQLStatementType.RL), 
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/AnalyzeTableStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/AnalyzeTableStatement.java
index a312819..1eab64b 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/AnalyzeTableStatement.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/AnalyzeTableStatement.java
@@ -17,10 +17,20 @@
 
 package org.apache.shardingsphere.sql.parser.sql.common.statement.dal;
 
+import lombok.Getter;
+import lombok.ToString;
+import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
 
+import java.util.Collection;
+import java.util.LinkedList;
+
 /**
  * Analyze table statement.
  */
+@Getter
+@ToString
 public abstract class AnalyzeTableStatement extends AbstractSQLStatement 
implements DALStatement {
+    
+    private final Collection<SimpleTableSegment> tables = new LinkedList<>();
 }
diff --git 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/AnalyzeTableStatement.java
 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/dal/PostgreSQLLoadStatement.java
similarity index 66%
copy from 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/AnalyzeTableStatement.java
copy to 
shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/dal/PostgreSQLLoadStatement.java
index a312819..b37d6a3 100644
--- 
a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/statement/dal/AnalyzeTableStatement.java
+++ 
b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/statement/postgresql/dal/PostgreSQLLoadStatement.java
@@ -15,12 +15,16 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sql.parser.sql.common.statement.dal;
+package 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.dal;
 
+import lombok.ToString;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.DALStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
 
 /**
- * Analyze table statement.
+ * PostgreSQL load statement.
  */
-public abstract class AnalyzeTableStatement extends AbstractSQLStatement 
implements DALStatement {
+@ToString
+public final class PostgreSQLLoadStatement extends AbstractSQLStatement 
implements DALStatement, PostgreSQLStatement {
 }

Reply via email to