You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ch...@apache.org on 2024/12/10 03:13:18 UTC

(shardingsphere) branch master updated: Move DuplicateIndexException and IndexNotFoundException from sharding module to infra module (#33984)

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

chengzhang 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 a778c3e3c9c Move DuplicateIndexException and IndexNotFoundException from sharding module to infra module (#33984)
a778c3e3c9c is described below

commit a778c3e3c9cfa0049e5005c82706d43d1177cf93
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Dec 10 11:13:11 2024 +0800

    Move DuplicateIndexException and IndexNotFoundException from sharding module to infra module (#33984)
---
 .../user-manual/error-code/sql-error-code.cn.md        |  4 ++--
 .../user-manual/error-code/sql-error-code.en.md        |  4 ++--
 .../sql/ddl/ShardingAlterIndexSupportedChecker.java    |  6 +++---
 .../sql/ddl/ShardingCreateIndexSupportedChecker.java   |  2 +-
 .../sql/ddl/ShardingDropIndexSupportedChecker.java     |  4 ++--
 .../ddl/ShardingAlterIndexSupportedCheckerTest.java    |  6 +++---
 .../ddl/ShardingCreateIndexSupportedCheckerTest.java   |  2 +-
 .../sql/ddl/ShardingDropIndexSupportedCheckerTest.java |  4 ++--
 .../kernel}/metadata/DuplicateIndexException.java      | 10 +++++-----
 .../kernel/metadata/IndexNotFoundException.java        | 18 +++++++++++-------
 .../type/index/AlterIndexStatementSchemaRefresher.java |  5 ++---
 .../index/CreateIndexStatementSchemaRefresher.java     |  4 ----
 12 files changed, 34 insertions(+), 35 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 c0811a31ea4..0845881f875 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
@@ -18,6 +18,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 10001       | 42S02     | Schema '%s' does not exist.                                                         |
 | 10002       | 42S02     | Table or view '%s' does not exist.                                                  |
 | 10003       | 42S02     | Unknown column '%s' in '%s'.                                                        |
+| 10004       | 42S02     | Index '%s' does not exist.                                                          |
+| 10005       | 42S01     | Index '%s' already exists.                                                          |
 | 10010       | HY000     | Rule and storage meta data mismatched, reason is: %s.                               |
 | 10100       | HY000     | Can not %s storage units '%s'.                                                      |
 | 10101       | 42S02     | There is no storage unit in database '%s'.                                          |
@@ -151,8 +153,6 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 20004       | 42S02     | Actual table '%s.%s' is not in table rule configuration.                                                                            |
 | 20005       | 42S02     | Can not find binding actual table, data source is '%s', logic table is '%s', other actual table is '%s'.                            |
 | 20006       | 44000     | Actual tables '%s' are in use.                                                                                                      |
-| 20007       | 42S01     | Index '%s' already exists.                                                                                                          |
-| 20008       | 42S02     | Index '%s' does not exist.                                                                                                          |
 | 20009       | 42S01     | View name has to bind to %s tables.                                                                                                 |
 | 20010       | 44000     | Invalid binding table configuration.                                                                                                |
 | 20011       | 44000     | Only allowed 0 or 1 sharding strategy configuration.                                                                                |
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 3fef9100249..4359e8d65c1 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
@@ -18,6 +18,8 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
 | 10001       | 42S02     | Schema '%s' does not exist.                                                         |
 | 10002       | 42S02     | Table or view '%s' does not exist.                                                  |
 | 10003       | 42S02     | Unknown column '%s' in '%s'.                                                        |
+| 10004       | 42S02     | Index '%s' does not exist.                                                          |
+| 10005       | 42S01     | Index '%s' already exists.                                                          |
 | 10010       | HY000     | Rule and storage meta data mismatched, reason is: %s.                               |
 | 10100       | HY000     | Can not %s storage units '%s'.                                                      |
 | 10101       | 42S02     | There is no storage unit in database '%s'.                                          |
@@ -151,8 +153,6 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
 | 20004       | 42S02     | Actual table '%s.%s' is not in table rule configuration.                                                                            |
 | 20005       | 42S02     | Can not find binding actual table, data source is '%s', logic table is '%s', other actual table is '%s'.                            |
 | 20006       | 44000     | Actual tables '%s' are in use.                                                                                                      |
-| 20007       | 42S01     | Index '%s' already exists.                                                                                                          |
-| 20008       | 42S02     | Index '%s' does not exist.                                                                                                          |
 | 20009       | 42S01     | View name has to bind to %s tables.                                                                                                 |
 | 20010       | 44000     | Invalid binding table configuration.                                                                                                |
 | 20011       | 44000     | Only allowed 0 or 1 sharding strategy configuration.                                                                                |
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedChecker.java
index 310c419dc51..8c6c9527f3f 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedChecker.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedChecker.java
@@ -23,8 +23,8 @@ import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.sharding.checker.sql.util.ShardingSupportedCheckUtils;
-import org.apache.shardingsphere.sharding.exception.metadata.DuplicateIndexException;
-import org.apache.shardingsphere.sharding.exception.metadata.IndexNotExistedException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.DuplicateIndexException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.IndexNotFoundException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexSegment;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.AlterIndexStatement;
@@ -47,7 +47,7 @@ public final class ShardingAlterIndexSupportedChecker implements SupportedSQLChe
         Optional<IndexSegment> index = alterIndexStatement.getIndex();
         ShardingSphereSchema schema = index.flatMap(optional -> optional.getOwner().map(owner -> database.getSchema(owner.getIdentifier().getValue()))).orElse(currentSchema);
         if (index.isPresent() && !ShardingSupportedCheckUtils.isSchemaContainsIndex(schema, index.get())) {
-            throw new IndexNotExistedException(index.get().getIndexName().getIdentifier().getValue());
+            throw new IndexNotFoundException(index.get().getIndexName().getIdentifier().getValue());
         }
         Optional<IndexSegment> renameIndex = alterIndexStatement.getRenameIndex();
         if (renameIndex.isPresent() && ShardingSupportedCheckUtils.isSchemaContainsIndex(schema, renameIndex.get())) {
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedChecker.java
index a8c3c50685a..f8cf00bcc75 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedChecker.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedChecker.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.exception.core.ShardingSpherePrecondition
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.sharding.checker.sql.common.ShardingSupportedCommonChecker;
-import org.apache.shardingsphere.sharding.exception.metadata.DuplicateIndexException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.DuplicateIndexException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CreateIndexStatement;
 
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedChecker.java
index 15e19b64d66..08f7aff26a3 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedChecker.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedChecker.java
@@ -24,7 +24,7 @@ import org.apache.shardingsphere.infra.exception.core.ShardingSpherePrecondition
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.sharding.checker.sql.util.ShardingSupportedCheckUtils;
-import org.apache.shardingsphere.sharding.exception.metadata.IndexNotExistedException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.IndexNotFoundException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexSegment;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropIndexStatement;
@@ -47,7 +47,7 @@ public final class ShardingDropIndexSupportedChecker implements SupportedSQLChec
         }
         for (IndexSegment each : dropIndexStatement.getIndexes()) {
             ShardingSphereSchema schema = each.getOwner().map(optional -> optional.getIdentifier().getValue()).map(database::getSchema).orElse(currentSchema);
-            ShardingSpherePreconditions.checkState(ShardingSupportedCheckUtils.isSchemaContainsIndex(schema, each), () -> new IndexNotExistedException(each.getIndexName().getIdentifier().getValue()));
+            ShardingSpherePreconditions.checkState(ShardingSupportedCheckUtils.isSchemaContainsIndex(schema, each), () -> new IndexNotFoundException(each.getIndexName().getIdentifier().getValue()));
         }
     }
 }
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
index 9161b8842a1..897a46822ec 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingAlterIndexSupportedCheckerTest.java
@@ -21,8 +21,8 @@ import org.apache.shardingsphere.infra.binder.context.statement.ddl.AlterIndexSt
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import org.apache.shardingsphere.sharding.exception.metadata.DuplicateIndexException;
-import org.apache.shardingsphere.sharding.exception.metadata.IndexNotExistedException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.DuplicateIndexException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.IndexNotFoundException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexNameSegment;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexSegment;
@@ -70,7 +70,7 @@ class ShardingAlterIndexSupportedCheckerTest {
         sqlStatement.setRenameIndex(new IndexSegment(0, 0, new IndexNameSegment(0, 0, new IdentifierValue("t_order_index_new"))));
         ShardingSphereTable table = mock(ShardingSphereTable.class);
         when(database.getSchema("public").getTable("t_order")).thenReturn(table);
-        assertThrows(IndexNotExistedException.class, () -> new ShardingAlterIndexSupportedChecker().check(rule, database, mock(), new AlterIndexStatementContext(sqlStatement, "foo_db")));
+        assertThrows(IndexNotFoundException.class, () -> new ShardingAlterIndexSupportedChecker().check(rule, database, mock(), new AlterIndexStatementContext(sqlStatement, "foo_db")));
     }
     
     @Test
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
index 60e86be90a0..3f115e5e965 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingCreateIndexSupportedCheckerTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.binder.context.statement.ddl.CreateIndexS
 import org.apache.shardingsphere.infra.exception.dialect.exception.syntax.table.NoSuchTableException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
-import org.apache.shardingsphere.sharding.exception.metadata.DuplicateIndexException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.DuplicateIndexException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexNameSegment;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexSegment;
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
index cbd1912f58b..c6784dd59e7 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropIndexSupportedCheckerTest.java
@@ -21,7 +21,7 @@ import org.apache.shardingsphere.infra.binder.context.statement.ddl.DropIndexSta
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import org.apache.shardingsphere.sharding.exception.metadata.IndexNotExistedException;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.IndexNotFoundException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexNameSegment;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.ddl.index.IndexSegment;
@@ -70,6 +70,6 @@ class ShardingDropIndexSupportedCheckerTest {
         ShardingSphereTable table = mock(ShardingSphereTable.class);
         when(database.getSchema("public").getAllTables()).thenReturn(Collections.singleton(table));
         when(database.getSchema("public").getTable("t_order")).thenReturn(table);
-        assertThrows(IndexNotExistedException.class, () -> new ShardingDropIndexSupportedChecker().check(rule, database, mock(), new DropIndexStatementContext(sqlStatement, "foo_db")));
+        assertThrows(IndexNotFoundException.class, () -> new ShardingDropIndexSupportedChecker().check(rule, database, mock(), new DropIndexStatementContext(sqlStatement, "foo_db")));
     }
 }
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateIndexException.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/DuplicateIndexException.java
similarity index 73%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateIndexException.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/DuplicateIndexException.java
index e11731beebb..9395a8b43ce 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/DuplicateIndexException.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/DuplicateIndexException.java
@@ -15,19 +15,19 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.exception.metadata;
+package org.apache.shardingsphere.infra.exception.kernel.metadata;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.MetaDataSQLException;
 
 /**
  * Duplicate index exception.
  */
-public final class DuplicateIndexException extends ShardingSQLException {
+public final class DuplicateIndexException extends MetaDataSQLException {
     
-    private static final long serialVersionUID = 2884666477007627873L;
+    private static final long serialVersionUID = 1463379993377506978L;
     
     public DuplicateIndexException(final String indexName) {
-        super(XOpenSQLState.DUPLICATE, 7, "Index '%s' already exists.", indexName);
+        super(XOpenSQLState.DUPLICATE, 5, "Index '%s' already exists.", indexName);
     }
 }
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/IndexNotExistedException.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/IndexNotFoundException.java
similarity index 57%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/IndexNotExistedException.java
rename to infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/IndexNotFoundException.java
index f55c354797b..3bb29788517 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/exception/metadata/IndexNotExistedException.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/exception/kernel/metadata/IndexNotFoundException.java
@@ -15,19 +15,23 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.sharding.exception.metadata;
+package org.apache.shardingsphere.infra.exception.kernel.metadata;
 
 import org.apache.shardingsphere.infra.exception.core.external.sql.sqlstate.XOpenSQLState;
-import org.apache.shardingsphere.sharding.exception.ShardingSQLException;
+import org.apache.shardingsphere.infra.exception.core.external.sql.type.kernel.category.MetaDataSQLException;
 
 /**
- * Index not existed exception.
+ * Index not found exception.
  */
-public final class IndexNotExistedException extends ShardingSQLException {
+public final class IndexNotFoundException extends MetaDataSQLException {
     
-    private static final long serialVersionUID = 206503570677185269L;
+    private static final long serialVersionUID = -4182388839280501305L;
     
-    public IndexNotExistedException(final String indexName) {
-        super(XOpenSQLState.NOT_FOUND, 8, "Index '%s' does not exist.", indexName);
+    public IndexNotFoundException(final String indexName) {
+        super(XOpenSQLState.NOT_FOUND, 4, "Index '%s' does not exist.", indexName);
+    }
+    
+    public IndexNotFoundException(final String indexName, final String schemaName) {
+        super(XOpenSQLState.NOT_FOUND, 4, "Index '%s' does not exist from schema '%s'.", indexName, schemaName);
     }
 }
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java
index 8e162d1ac7a..812a1417f2b 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/AlterIndexStatementSchemaRefresher.java
@@ -17,10 +17,10 @@
 
 package org.apache.shardingsphere.mode.metadata.refresher.type.index;
 
-import com.google.common.base.Preconditions;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
+import org.apache.shardingsphere.infra.exception.kernel.metadata.IndexNotFoundException;
 import org.apache.shardingsphere.infra.exception.kernel.metadata.SchemaNotFoundException;
 import org.apache.shardingsphere.infra.exception.kernel.metadata.TableNotFoundException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -54,8 +54,7 @@ public final class AlterIndexStatementSchemaRefresher implements MetaDataRefresh
         ShardingSpherePreconditions.checkState(database.containsSchema(actualSchemaName), () -> new SchemaNotFoundException(actualSchemaName));
         ShardingSphereSchema schema = database.getSchema(actualSchemaName);
         Optional<String> logicTableName = findLogicTableName(schema, indexName);
-        // TODO define IndexNotFoundException
-        Preconditions.checkState(logicTableName.isPresent(), "Can not find logic table by index '%s' of schema '%s'.", indexName, schemaName);
+        ShardingSpherePreconditions.checkState(logicTableName.isPresent(), () -> new IndexNotFoundException(indexName, schemaName));
         ShardingSpherePreconditions.checkState(schema.containsTable(logicTableName.get()), () -> new TableNotFoundException(logicTableName.get()));
         ShardingSphereTable table = schema.getTable(logicTableName.get());
         ShardingSphereTable newTable = new ShardingSphereTable(table.getName(), table.getAllColumns(), table.getAllIndexes(), table.getAllConstraints(), table.getType());
diff --git a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java
index a09320e35c9..fce62478ddf 100644
--- a/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java
+++ b/mode/core/src/main/java/org/apache/shardingsphere/mode/metadata/refresher/type/index/CreateIndexStatementSchemaRefresher.java
@@ -17,8 +17,6 @@
 
 package org.apache.shardingsphere.mode.metadata.refresher.type.index;
 
-import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
@@ -48,8 +46,6 @@ public final class CreateIndexStatementSchemaRefresher implements MetaDataRefres
         String indexName = null == sqlStatement.getIndex()
                 ? IndexMetaDataUtils.getGeneratedLogicIndexName(sqlStatement.getColumns())
                 : sqlStatement.getIndex().getIndexName().getIdentifier().getValue();
-        // TODO define IndexNotFoundException
-        Preconditions.checkArgument(!Strings.isNullOrEmpty(indexName), "Index name is not exist.");
         String tableName = sqlStatement.getTable().getTableName().getIdentifier().getValue();
         ShardingSpherePreconditions.checkState(database.containsSchema(schemaName), () -> new SchemaNotFoundException(schemaName));
         ShardingSphereSchema schema = database.getSchema(schemaName);