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

duanzhengqiang 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 6dbedfae61c Add ShardingRouteException (#20561)
6dbedfae61c is described below

commit 6dbedfae61ca1a2ac7d0c3dd2f4109564595261b
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Aug 26 17:27:08 2022 +0800

    Add ShardingRouteException (#20561)
    
    * Reuse UnsupportedShardingOperationException
    
    * Reuse UnsupportedShardingOperationException
    
    * Reuse UnsupportedShardingOperationException
    
    * Add ShardingRouteException
---
 .../user-manual/error-code/sql-error-code.cn.md    |  3 ++
 .../user-manual/error-code/sql-error-code.en.md    |  1 +
 .../sharding/exception/ShardingRouteException.java | 35 ++++++++++++++++++++++
 .../impl/ShardingAlterTableStatementValidator.java |  4 +--
 .../ShardingCreateTableStatementValidator.java     |  4 +--
 .../impl/ShardingDropIndexStatementValidator.java  |  4 +--
 .../impl/ShardingDropTableStatementValidator.java  |  3 +-
 .../ShardingRenameTableStatementValidator.java     |  4 +--
 .../ShardingAlterTableStatementValidatorTest.java  |  6 ++--
 .../ShardingCreateTableStatementValidatorTest.java |  8 ++---
 .../ShardingDropIndexStatementValidatorTest.java   |  6 ++--
 .../ShardingDropTableStatementValidatorTest.java   |  5 ++--
 .../ShardingRenameTableStatementValidatorTest.java |  4 +--
 .../dml/ShardingCopyStatementValidatorTest.java    |  2 +-
 14 files changed, 65 insertions(+), 24 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md 
b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index 10d814f0089..827f88c5b37 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -40,6 +40,9 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 44000     | 20002       | Can not get uniformed table structure for logic 
table \`%s\`, it has different meta data of actual tables are as follows: %s |
 | 44000     | 20003       | Can not find table rule with logic tables \`%s\` |
 | 0A000     | 20004       | Can not support operation \`%s\` with sharding 
table \`%s\` |
+| 42S01     | 20005       | Index \`%s\` already exists |
+| 42S02     | 20006       | Index \`%s\` does not exist |
+| HY000     | 20007       | \`%s %s\` can not route correctly for %s \`%s\` |
 | 44000     | 20012       | Inline sharding algorithms expression \`%s\` and 
sharding column \`%s\` are not match |
 | HY004     | 20013       | Found different types for sharding value \`%s\` |
 | HY004     | 24000       | Encrypt algorithm \`%s\` initialize failed, reason 
is: %s |
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md 
b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 62bd587f3d3..31586d98911 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -42,6 +42,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 0A000     | 20004       | Can not support operation \`%s\` with sharding 
table \`%s\` |
 | 42S01     | 20005       | Index \`%s\` already exists |
 | 42S02     | 20006       | Index \`%s\` does not exist |
+| HY000     | 20007       | \`%s %s\` can not route correctly for %s \`%s\` |
 | 44000     | 20012       | Inline sharding algorithms expression \`%s\` and 
sharding column \`%s\` are not match |
 | HY004     | 20013       | Found different types for sharding value \`%s\` |
 | HY004     | 24000       | Encrypt algorithm \`%s\` initialize failed, reason 
is: %s |
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/exception/ShardingRouteException.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/exception/ShardingRouteException.java
new file mode 100644
index 00000000000..02166703a04
--- /dev/null
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/exception/ShardingRouteException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.sharding.exception;
+
+import 
org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
+import 
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
+
+import java.util.Collection;
+
+/**
+ * Sharding route exception.
+ */
+public final class ShardingRouteException extends ShardingSphereSQLException {
+    
+    private static final long serialVersionUID = 1611718269096645289L;
+    
+    public ShardingRouteException(final String operation, final String 
objectType, final Collection<String> objectNames) {
+        super(XOpenSQLState.GENERAL_ERROR, 20007, "`%s %s` can not route 
correctly for %s `%s`", operation, objectType, objectType, 
objectNames.toString());
+    }
+}
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
index 1dc752ae725..3ee32788cf4 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingAlterTableStatementValidator.java
@@ -20,9 +20,9 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.binder.type.TableAvailable;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.exception.UnsupportedShardingOperationException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -60,7 +60,7 @@ public final class ShardingAlterTableStatementValidator 
extends ShardingDDLState
                              final ShardingSphereDatabase database, final 
ConfigurationProperties props, final RouteContext routeContext) {
         String primaryTable = 
sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue();
         if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext, 
primaryTable)) {
-            throw new ShardingSphereException("ALTER TABLE ... statement can 
not route correctly for tables %s.", 
sqlStatementContext.getTablesContext().getTableNames());
+            throw new ShardingRouteException("ALTER", "TABLE", 
sqlStatementContext.getTablesContext().getTableNames());
         }
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
index cd2a1a1a09f..026f2870a33 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingCreateTableStatementValidator.java
@@ -20,10 +20,10 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTableStatement;
@@ -53,7 +53,7 @@ public final class ShardingCreateTableStatementValidator 
extends ShardingDDLStat
                              final ShardingSphereDatabase database, final 
ConfigurationProperties props, final RouteContext routeContext) {
         String primaryTable = 
sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue();
         if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext, 
primaryTable)) {
-            throw new ShardingSphereException("CREATE TABLE ... statement can 
not route correctly for tables %s.", 
sqlStatementContext.getTablesContext().getTableNames());
+            throw new ShardingRouteException("CREATE", "TABLE", 
sqlStatementContext.getTablesContext().getTableNames());
         }
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
index 4803f3980cf..da140a25180 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropIndexStatementValidator.java
@@ -20,11 +20,11 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.sharding.exception.IndexNotExistedException;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.index.IndexSegment;
@@ -77,7 +77,7 @@ public final class ShardingDropIndexStatementValidator 
extends ShardingDDLStatem
     private void validateDropIndexRouteUnit(final ShardingRule shardingRule, 
final RouteContext routeContext, final Collection<IndexSegment> indexSegments, 
final String logicTableName) {
         if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext, 
logicTableName)) {
             Collection<String> indexNames = indexSegments.stream().map(each -> 
each.getIndexName().getIdentifier().getValue()).collect(Collectors.toList());
-            throw new ShardingSphereException("DROP INDEX ... statement can 
not route correctly for indexes %s.", indexNames);
+            throw new ShardingRouteException("DROP", "INDEX", indexNames);
         }
     }
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
index 7219a8cfb5a..3cefd92d6fe 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingDropTableStatementValidator.java
@@ -26,6 +26,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.exception.UnsupportedShardingOperationException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -64,7 +65,7 @@ public final class ShardingDropTableStatementValidator 
extends ShardingDDLStatem
         checkTableInUsed(shardingRule, sqlStatementContext.getSqlStatement(), 
routeContext);
         for (SimpleTableSegment each : 
sqlStatementContext.getSqlStatement().getTables()) {
             if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext, 
each.getTableName().getIdentifier().getValue())) {
-                throw new ShardingSphereException("DROP TABLE ... statement 
can not route correctly for tables %s.", 
sqlStatementContext.getTablesContext().getTableNames());
+                throw new ShardingRouteException("DROP", "TABLE", 
sqlStatementContext.getTablesContext().getTableNames());
             }
         }
     }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
index c93515ea840..0c2d641a904 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/impl/ShardingRenameTableStatementValidator.java
@@ -20,9 +20,9 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.binder.type.TableAvailable;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.exception.UnsupportedShardingOperationException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.ShardingDDLStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -61,7 +61,7 @@ public final class ShardingRenameTableStatementValidator 
extends ShardingDDLStat
         for (RenameTableDefinitionSegment each : 
sqlStatementContext.getSqlStatement().getRenameTables()) {
             String primaryTable = 
each.getTable().getTableName().getIdentifier().getValue();
             if (isRouteUnitDataNodeDifferentSize(shardingRule, routeContext, 
primaryTable)) {
-                throw new ShardingSphereException("RENAME TABLE ... TO ... 
statement can not route correctly for tables %s.", 
sqlStatementContext.getTablesContext().getTableNames());
+                throw new ShardingRouteException("RENAME", "TABLE", 
sqlStatementContext.getTablesContext().getTableNames());
             }
         }
     }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
index 89e0586c7e0..626c82b9e02 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingAlterTableStatementValidatorTest.java
@@ -20,11 +20,11 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.ddl;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.ddl.AlterTableStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.exception.UnsupportedShardingOperationException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl.ShardingAlterTableStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -95,7 +95,7 @@ public final class ShardingAlterTableStatementValidatorTest {
                 Collections.emptyList(), database, 
mock(ConfigurationProperties.class), routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateAlterTableWithDifferentRouteResultShardingTableForPostgreSQL()
 {
         PostgreSQLAlterTableStatement sqlStatement = new 
PostgreSQLAlterTableStatement();
         sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 
0, new IdentifierValue("t_order"))));
@@ -122,7 +122,7 @@ public final class ShardingAlterTableStatementValidatorTest 
{
                 Collections.emptyList(), database, 
mock(ConfigurationProperties.class), routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateAlterTableWithDifferentRouteResultBroadcastTableForPostgreSQL()
 {
         PostgreSQLAlterTableStatement sqlStatement = new 
PostgreSQLAlterTableStatement();
         sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 
0, new IdentifierValue("t_config"))));
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
index b13663ea4fe..7509f36ed2a 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingCreateTableStatementValidatorTest.java
@@ -17,15 +17,15 @@
 
 package org.apache.shardingsphere.sharding.route.engine.validator.ddl;
 
+import 
org.apache.shardingsphere.dialect.exception.syntax.table.TableExistsException;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.ddl.CreateTableStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
-import 
org.apache.shardingsphere.dialect.exception.syntax.table.TableExistsException;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl.ShardingCreateTableStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sharding.rule.TableRule;
@@ -142,7 +142,7 @@ public final class 
ShardingCreateTableStatementValidatorTest {
                 new CreateTableStatementContext(sqlStatement), 
Collections.emptyList(), database, mock(ConfigurationProperties.class), 
routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateCreateTableWithDifferentRouteResultShardingTableForPostgreSQL()
 {
         PostgreSQLCreateTableStatement sqlStatement = new 
PostgreSQLCreateTableStatement(false);
         sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 
0, new IdentifierValue("t_order"))));
@@ -169,7 +169,7 @@ public final class 
ShardingCreateTableStatementValidatorTest {
                 new CreateTableStatementContext(sqlStatement), 
Collections.emptyList(), database, mock(ConfigurationProperties.class), 
routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateCreateTableWithDifferentRouteResultBroadcastTableForPostgreSQL()
 {
         PostgreSQLCreateTableStatement sqlStatement = new 
PostgreSQLCreateTableStatement(false);
         sqlStatement.setTable(new SimpleTableSegment(new TableNameSegment(0, 
0, new IdentifierValue("t_config"))));
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
index f61009de77e..cbf2340902b 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropIndexStatementValidatorTest.java
@@ -19,7 +19,6 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.ddl;
 
 import 
org.apache.shardingsphere.infra.binder.statement.ddl.DropIndexStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereIndex;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereTable;
@@ -27,6 +26,7 @@ import 
org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
 import org.apache.shardingsphere.sharding.exception.IndexNotExistedException;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl.ShardingDropIndexStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sharding.rule.TableRule;
@@ -112,7 +112,7 @@ public final class ShardingDropIndexStatementValidatorTest {
                 Collections.emptyList(), database, 
mock(ConfigurationProperties.class), routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateDropIndexWithDifferentRouteResultShardingTableIndexForPostgreSQL()
 {
         PostgreSQLDropIndexStatement sqlStatement = new 
PostgreSQLDropIndexStatement(false);
         sqlStatement.getIndexes().add(new IndexSegment(0, 0, new 
IndexNameSegment(0, 0, new IdentifierValue("t_order_index"))));
@@ -153,7 +153,7 @@ public final class ShardingDropIndexStatementValidatorTest {
                 Collections.emptyList(), database, 
mock(ConfigurationProperties.class), routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateDropIndexWithDifferentRouteResultBroadcastTableIndexForPostgreSQL()
 {
         PostgreSQLDropIndexStatement sqlStatement = new 
PostgreSQLDropIndexStatement(false);
         sqlStatement.getIndexes().add(new IndexSegment(0, 0, new 
IndexNameSegment(0, 0, new IdentifierValue("t_config_index"))));
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
index d6d5b0e577b..fdcc67ed472 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingDropTableStatementValidatorTest.java
@@ -27,6 +27,7 @@ import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl.ShardingDropTableStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sharding.rule.TableRule;
@@ -126,7 +127,7 @@ public final class ShardingDropTableStatementValidatorTest {
                 Collections.emptyList(), mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateDropTableWithDifferentRouteResultShardingTableForPostgreSQL() 
{
         PostgreSQLDropTableStatement sqlStatement = new 
PostgreSQLDropTableStatement(false, false);
         sqlStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order"))));
@@ -153,7 +154,7 @@ public final class ShardingDropTableStatementValidatorTest {
                 Collections.emptyList(), mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS), mock(ConfigurationProperties.class), routeContext);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void 
assertPostValidateDropTableWithDifferentRouteResultBroadcastTableForPostgreSQL()
 {
         PostgreSQLDropTableStatement sqlStatement = new 
PostgreSQLDropTableStatement(false, false);
         sqlStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_config"))));
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
index 38a6b73e75c..890c33322ec 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/ddl/ShardingRenameTableStatementValidatorTest.java
@@ -21,10 +21,10 @@ import 
org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.statement.ddl.RenameTableStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
+import org.apache.shardingsphere.sharding.exception.ShardingRouteException;
 import 
org.apache.shardingsphere.sharding.exception.UnsupportedShardingOperationException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.ddl.impl.ShardingRenameTableStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -77,7 +77,7 @@ public final class ShardingRenameTableStatementValidatorTest {
         new ShardingRenameTableStatementValidator().preValidate(shardingRule, 
sqlStatementContext, Collections.emptyList(), database);
     }
     
-    @Test(expected = ShardingSphereException.class)
+    @Test(expected = ShardingRouteException.class)
     public void assertPostValidateDifferentRouteUnitsAndDataNodesSize() {
         RouteContext routeContext = new RouteContext();
         routeContext.getRouteUnits().add(mock(RouteUnit.class));
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
index ce2c38a26ca..a32448b8483 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingCopyStatementValidatorTest.java
@@ -40,7 +40,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 @RunWith(MockitoJUnitRunner.class)
-public class ShardingCopyStatementValidatorTest {
+public final class ShardingCopyStatementValidatorTest {
     
     @Mock
     private ShardingRule shardingRule;

Reply via email to