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

zhaojinchao 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 1ec407a263c Remove useless ShardingSphereMetaDataValidateUtils for 
table exist check logic (#29852)
1ec407a263c is described below

commit 1ec407a263c167de598222a4d2981e2fa6f03b4c
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Thu Jan 25 16:56:04 2024 +0800

    Remove useless ShardingSphereMetaDataValidateUtils for table exist check 
logic (#29852)
---
 .../ShardingStatementValidatorFactory.java         |  5 --
 .../dml/impl/ShardingDeleteStatementValidator.java |  2 -
 .../dml/impl/ShardingInsertStatementValidator.java |  2 -
 .../dml/impl/ShardingSelectStatementValidator.java | 46 -----------------
 .../dml/impl/ShardingUpdateStatementValidator.java |  4 +-
 .../dml/ShardingDeleteStatementValidatorTest.java  |  8 ---
 .../dml/ShardingInsertStatementValidatorTest.java  | 21 --------
 .../dml/ShardingUpdateStatementValidatorTest.java  | 12 -----
 .../ShardingSphereMetaDataValidateUtils.java       | 60 ----------------------
 .../single/route/SingleSQLRouter.java              | 11 ----
 10 files changed, 1 insertion(+), 170 deletions(-)

diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
index 9684f6476da..906a67431cb 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/ShardingStatementValidatorFactory.java
@@ -38,7 +38,6 @@ import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.Shardi
 import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingInsertStatementValidator;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingLoadDataStatementValidator;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingLoadXMLStatementValidator;
-import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingSelectStatementValidator;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingUpdateStatementValidator;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterIndexStatement;
@@ -58,7 +57,6 @@ import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.CopyStateme
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DMLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLLoadDataStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLLoadXMLStatement;
@@ -139,9 +137,6 @@ public final class ShardingStatementValidatorFactory {
         if (sqlStatement instanceof DeleteStatement) {
             return Optional.of(new ShardingDeleteStatementValidator());
         }
-        if (sqlStatement instanceof SelectStatement) {
-            return Optional.of(new ShardingSelectStatementValidator());
-        }
         if (sqlStatement instanceof CopyStatement) {
             return Optional.of(new ShardingCopyStatementValidator());
         }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
index b12eab4bac8..4f228c2454d 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingDeleteStatementValidator.java
@@ -21,7 +21,6 @@ import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementCont
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.hint.HintValueContext;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.connection.validator.ShardingSphereMetaDataValidateUtils;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import 
org.apache.shardingsphere.sharding.exception.syntax.DMLMultipleDataNodesWithLimitException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.ShardingDMLStatementValidator;
@@ -39,7 +38,6 @@ public final class ShardingDeleteStatementValidator extends 
ShardingDMLStatement
     @Override
     public void preValidate(final ShardingRule shardingRule, final 
SQLStatementContext sqlStatementContext,
                             final List<Object> params, final 
ShardingSphereDatabase database, final ConfigurationProperties props) {
-        
ShardingSphereMetaDataValidateUtils.validateTableExist(sqlStatementContext, 
database);
         validateMultipleTable(shardingRule, sqlStatementContext);
     }
     
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
index 1d7405ad28f..e80137d66aa 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingInsertStatementValidator.java
@@ -22,7 +22,6 @@ import 
org.apache.shardingsphere.infra.binder.context.segment.table.TablesContex
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.dml.InsertStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import 
org.apache.shardingsphere.infra.connection.validator.ShardingSphereMetaDataValidateUtils;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.hint.HintValueContext;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -59,7 +58,6 @@ public final class ShardingInsertStatementValidator extends 
ShardingDMLStatement
     @Override
     public void preValidate(final ShardingRule shardingRule, final 
SQLStatementContext sqlStatementContext,
                             final List<Object> params, final 
ShardingSphereDatabase database, final ConfigurationProperties props) {
-        
ShardingSphereMetaDataValidateUtils.validateTableExist(sqlStatementContext, 
database);
         if (null == ((InsertStatementContext) 
sqlStatementContext).getInsertSelectContext()) {
             validateMultipleTable(shardingRule, sqlStatementContext);
         }
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingSelectStatementValidator.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingSelectStatementValidator.java
deleted file mode 100644
index b0b347d542c..00000000000
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingSelectStatementValidator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.route.engine.validator.dml.impl;
-
-import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import 
org.apache.shardingsphere.infra.connection.validator.ShardingSphereMetaDataValidateUtils;
-import org.apache.shardingsphere.infra.hint.HintValueContext;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.route.context.RouteContext;
-import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.ShardingDMLStatementValidator;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-
-import java.util.List;
-
-/**
- * Sharding select statement validator.
- */
-public final class ShardingSelectStatementValidator extends 
ShardingDMLStatementValidator {
-    
-    @Override
-    public void preValidate(final ShardingRule shardingRule, final 
SQLStatementContext sqlStatementContext, final List<Object> params, final 
ShardingSphereDatabase database,
-                            final ConfigurationProperties props) {
-        
ShardingSphereMetaDataValidateUtils.validateTableExist(sqlStatementContext, 
database);
-    }
-    
-    @Override
-    public void postValidate(final ShardingRule shardingRule, final 
SQLStatementContext sqlStatementContext, final HintValueContext 
hintValueContext, final List<Object> params,
-                             final ShardingSphereDatabase database, final 
ConfigurationProperties props, final RouteContext routeContext) {
-    }
-}
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
index a110161e54d..62034404d8f 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/impl/ShardingUpdateStatementValidator.java
@@ -19,11 +19,10 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl;
 
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import 
org.apache.shardingsphere.infra.connection.validator.ShardingSphereMetaDataValidateUtils;
+import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import org.apache.shardingsphere.infra.hint.HintValueContext;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
-import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.sharding.exception.syntax.DMLMultipleDataNodesWithLimitException;
 import 
org.apache.shardingsphere.sharding.exception.syntax.UnsupportedUpdatingShardingValueException;
 import 
org.apache.shardingsphere.sharding.route.engine.condition.ShardingConditions;
@@ -44,7 +43,6 @@ public final class ShardingUpdateStatementValidator extends 
ShardingDMLStatement
     @Override
     public void preValidate(final ShardingRule shardingRule, final 
SQLStatementContext sqlStatementContext, final List<Object> params, final 
ShardingSphereDatabase database,
                             final ConfigurationProperties props) {
-        
ShardingSphereMetaDataValidateUtils.validateTableExist(sqlStatementContext, 
database);
         validateMultipleTable(shardingRule, sqlStatementContext);
     }
     
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
index db835eaef32..e487575ab0e 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingDeleteStatementValidatorTest.java
@@ -20,7 +20,6 @@ package 
org.apache.shardingsphere.sharding.route.engine.validator.dml;
 import 
org.apache.shardingsphere.infra.binder.context.statement.dml.DeleteStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import 
org.apache.shardingsphere.sharding.exception.syntax.DMLWithMultipleShardingTablesException;
 import 
org.apache.shardingsphere.sharding.route.engine.validator.dml.impl.ShardingDeleteStatementValidator;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -45,7 +44,6 @@ import java.util.Collections;
 import java.util.HashSet;
 
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -90,12 +88,6 @@ class ShardingDeleteStatementValidatorTest {
         when(shardingRule.isAllShardingTables(tableNames)).thenReturn(false);
         when(shardingRule.containsShardingTable(tableNames)).thenReturn(true);
         ShardingSphereDatabase database = mock(ShardingSphereDatabase.class);
-        ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
-        when(schema.containsTable("user")).thenReturn(true);
-        when(schema.containsTable("order")).thenReturn(true);
-        when(schema.containsTable("order_item")).thenReturn(true);
         DeleteStatementContext sqlStatementContext = new 
DeleteStatementContext(sqlStatement);
         new ShardingDeleteStatementValidator().preValidate(shardingRule, 
sqlStatementContext, Collections.emptyList(), database, 
mock(ConfigurationProperties.class));
     }
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
index 5ad4bd52849..84885a565e4 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingInsertStatementValidatorTest.java
@@ -77,7 +77,6 @@ import java.util.Optional;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -96,18 +95,12 @@ class ShardingInsertStatementValidatorTest {
     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
     private ShardingSphereDatabase database;
     
-    @Mock
-    private ShardingSphereSchema schema;
-    
     @Test
     void assertPreValidateWhenInsertMultiTables() {
         SQLStatementContext sqlStatementContext = 
createInsertStatementContext(Collections.singletonList(1), 
createInsertStatement());
         Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
         when(shardingRule.isAllShardingTables(tableNames)).thenReturn(false);
         when(shardingRule.containsShardingTable(tableNames)).thenReturn(true);
-        when(schema.containsTable("user")).thenReturn(true);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
         
when(database.getRuleMetaData().findRules(TableContainedRule.class)).thenReturn(Collections.emptyList());
         assertThrows(DMLWithMultipleShardingTablesException.class, () -> new 
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
                 sqlStatementContext, Collections.emptyList(), database, 
mock(ConfigurationProperties.class)));
@@ -126,9 +119,6 @@ class ShardingInsertStatementValidatorTest {
         when(shardingRule.isGenerateKeyColumn("id", "user")).thenReturn(false);
         SQLStatementContext sqlStatementContext = 
createInsertStatementContext(Collections.singletonList(1), 
createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTableNames().addAll(createSingleTablesContext().getTableNames());
-        when(schema.containsTable("user")).thenReturn(true);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
         assertThrows(MissingGenerateKeyColumnWithInsertSelectException.class, 
() -> new 
ShardingInsertStatementValidator(shardingConditions).preValidate(shardingRule,
                 sqlStatementContext, Collections.emptyList(), database, 
mock(ConfigurationProperties.class)));
     }
@@ -139,9 +129,6 @@ class ShardingInsertStatementValidatorTest {
         when(shardingRule.isGenerateKeyColumn("id", "user")).thenReturn(true);
         SQLStatementContext sqlStatementContext = 
createInsertStatementContext(Collections.singletonList(1), 
createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTableNames().addAll(createSingleTablesContext().getTableNames());
-        when(schema.containsTable("user")).thenReturn(true);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
         assertDoesNotThrow(() -> new 
ShardingInsertStatementValidator(shardingConditions).preValidate(
                 shardingRule, sqlStatementContext, Collections.emptyList(), 
database, mock(ConfigurationProperties.class)));
     }
@@ -155,10 +142,6 @@ class ShardingInsertStatementValidatorTest {
         
when(shardingRule.containsShardingTable(multiTablesContext.getTableNames())).thenReturn(true);
         SQLStatementContext sqlStatementContext = 
createInsertStatementContext(Collections.singletonList(1), 
createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTableNames().addAll(multiTablesContext.getTableNames());
-        when(schema.containsTable("user")).thenReturn(true);
-        when(schema.containsTable("order")).thenReturn(true);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
         assertThrows(InsertSelectTableViolationException.class, () -> new 
ShardingInsertStatementValidator(shardingConditions).preValidate(
                 shardingRule, sqlStatementContext, Collections.emptyList(), 
database, mock(ConfigurationProperties.class)));
     }
@@ -170,10 +153,6 @@ class ShardingInsertStatementValidatorTest {
         TablesContext multiTablesContext = createMultiTablesContext();
         SQLStatementContext sqlStatementContext = 
createInsertStatementContext(Collections.singletonList(1), 
createInsertSelectStatement());
         
sqlStatementContext.getTablesContext().getTableNames().addAll(multiTablesContext.getTableNames());
-        when(schema.containsTable("user")).thenReturn(true);
-        when(schema.containsTable("order")).thenReturn(true);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
         assertDoesNotThrow(() -> new 
ShardingInsertStatementValidator(shardingConditions).preValidate(
                 shardingRule, sqlStatementContext, Collections.emptyList(), 
database, mock(ConfigurationProperties.class)));
     }
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
index e08eb426ace..9336e1a29ea 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/dml/ShardingUpdateStatementValidatorTest.java
@@ -22,7 +22,6 @@ import 
org.apache.shardingsphere.infra.binder.context.statement.dml.UpdateStatem
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.hint.HintValueContext;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
 import org.apache.shardingsphere.infra.route.context.RouteContext;
 import org.apache.shardingsphere.infra.route.context.RouteMapper;
 import org.apache.shardingsphere.infra.route.context.RouteUnit;
@@ -61,7 +60,6 @@ import java.util.Optional;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
@@ -74,9 +72,6 @@ class ShardingUpdateStatementValidatorTest {
     @Mock
     private ShardingSphereDatabase database;
     
-    @Mock
-    private ShardingSphereSchema schema;
-    
     @Test
     void assertPreValidateWhenUpdateSingleTable() {
         UpdateStatement updateStatement = createUpdateStatement();
@@ -85,9 +80,6 @@ class ShardingUpdateStatementValidatorTest {
         Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
         when(shardingRule.isAllShardingTables(tableNames)).thenReturn(true);
         when(shardingRule.containsShardingTable(tableNames)).thenReturn(true);
-        when(schema.containsTable("user")).thenReturn(true);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
         assertDoesNotThrow(() -> new 
ShardingUpdateStatementValidator().preValidate(
                 shardingRule, sqlStatementContext, Collections.emptyList(), 
database, mock(ConfigurationProperties.class)));
     }
@@ -103,10 +95,6 @@ class ShardingUpdateStatementValidatorTest {
         Collection<String> tableNames = 
sqlStatementContext.getTablesContext().getTableNames();
         when(shardingRule.isAllShardingTables(tableNames)).thenReturn(false);
         when(shardingRule.containsShardingTable(tableNames)).thenReturn(true);
-        when(schema.containsTable("user")).thenReturn(true);
-        when(schema.containsTable("order")).thenReturn(true);
-        when(database.getSchema(any())).thenReturn(schema);
-        when(database.getName()).thenReturn("sharding_db");
         assertThrows(DMLWithMultipleShardingTablesException.class, () -> new 
ShardingUpdateStatementValidator().preValidate(
                 shardingRule, sqlStatementContext, Collections.emptyList(), 
database, mock(ConfigurationProperties.class)));
     }
diff --git 
a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/validator/ShardingSphereMetaDataValidateUtils.java
 
b/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/validator/ShardingSphereMetaDataValidateUtils.java
deleted file mode 100644
index 88699265929..00000000000
--- 
a/infra/context/src/main/java/org/apache/shardingsphere/infra/connection/validator/ShardingSphereMetaDataValidateUtils.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.connection.validator;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import 
org.apache.shardingsphere.infra.exception.dialect.exception.syntax.table.NoSuchTableException;
-import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseTypeRegistry;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-/**
- * ShardingSphere meta data validate utility class.
- */
-// TODO consider add common ShardingSphereMetaDataValidateEngine for all 
features
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingSphereMetaDataValidateUtils {
-    
-    private static final Collection<String> EXCLUDE_VALIDATE_TABLES = new 
HashSet<>(1, 1F);
-    
-    static {
-        EXCLUDE_VALIDATE_TABLES.add("DUAL");
-    }
-    
-    /**
-     * Validate table exist.
-     *
-     * @param sqlStatementContext sql statement context
-     * @param database database
-     * @throws NoSuchTableException no such table exception
-     */
-    public static void validateTableExist(final SQLStatementContext 
sqlStatementContext, final ShardingSphereDatabase database) {
-        String defaultSchemaName = new 
DatabaseTypeRegistry(sqlStatementContext.getDatabaseType()).getDefaultSchemaName(database.getName());
-        ShardingSphereSchema schema = 
sqlStatementContext.getTablesContext().getSchemaName().map(database::getSchema).orElseGet(()
 -> database.getSchema(defaultSchemaName));
-        for (String each : 
sqlStatementContext.getTablesContext().getTableNames()) {
-            if (!EXCLUDE_VALIDATE_TABLES.contains(each.toUpperCase()) && 
!schema.containsTable(each)) {
-                throw new NoSuchTableException(each);
-            }
-        }
-    }
-}
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
index 6293ffadc26..9a169dca5f4 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
+++ 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/route/SingleSQLRouter.java
@@ -19,7 +19,6 @@ package org.apache.shardingsphere.single.route;
 
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
-import 
org.apache.shardingsphere.infra.connection.validator.ShardingSphereMetaDataValidateUtils;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
 import org.apache.shardingsphere.infra.metadata.database.schema.QualifiedTable;
@@ -34,7 +33,6 @@ import 
org.apache.shardingsphere.single.route.engine.SingleRouteEngineFactory;
 import 
org.apache.shardingsphere.single.route.validator.SingleMetaDataValidatorFactory;
 import org.apache.shardingsphere.single.rule.SingleRule;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTableStatement;
-import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DMLStatement;
 
 import java.util.Collection;
 import java.util.LinkedList;
@@ -54,18 +52,10 @@ public final class SingleSQLRouter implements 
SQLRouter<SingleRule> {
         SQLStatementContext sqlStatementContext = 
queryContext.getSqlStatementContext();
         
SingleMetaDataValidatorFactory.newInstance(sqlStatementContext.getSqlStatement()).ifPresent(optional
 -> optional.validate(rule, sqlStatementContext, database));
         Collection<QualifiedTable> singleTables = getSingleTables(database, 
rule, result, sqlStatementContext);
-        validateSingleTableMetaData(database, sqlStatementContext, 
singleTables);
         SingleRouteEngineFactory.newInstance(singleTables, 
sqlStatementContext.getSqlStatement()).ifPresent(optional -> 
optional.route(result, rule));
         return result;
     }
     
-    private void validateSingleTableMetaData(final ShardingSphereDatabase 
database, final SQLStatementContext sqlStatementContext, final 
Collection<QualifiedTable> singleTables) {
-        // TODO move single table metadata validate logic to infra validator
-        if (!singleTables.isEmpty() && sqlStatementContext.getSqlStatement() 
instanceof DMLStatement) {
-            
ShardingSphereMetaDataValidateUtils.validateTableExist(sqlStatementContext, 
database);
-        }
-    }
-    
     private Collection<QualifiedTable> getSingleTables(final 
ShardingSphereDatabase database, final SingleRule rule, final RouteContext 
result, final SQLStatementContext sqlStatementContext) {
         Collection<QualifiedTable> qualifiedTables = 
rule.getQualifiedTables(sqlStatementContext, database);
         return result.getRouteUnits().isEmpty() && 
sqlStatementContext.getSqlStatement() instanceof CreateTableStatement ? 
qualifiedTables : rule.getSingleTables(qualifiedTables);
@@ -76,7 +66,6 @@ public final class SingleSQLRouter implements 
SQLRouter<SingleRule> {
                                      final SingleRule rule, final 
ConfigurationProperties props, final ConnectionContext connectionContext) {
         SQLStatementContext sqlStatementContext = 
queryContext.getSqlStatementContext();
         Collection<QualifiedTable> singleTables = getSingleTables(database, 
rule, routeContext, sqlStatementContext);
-        validateSingleTableMetaData(database, sqlStatementContext, 
singleTables);
         SingleRouteEngineFactory.newInstance(singleTables, 
sqlStatementContext.getSqlStatement()).ifPresent(optional -> 
optional.route(routeContext, rule));
     }
     

Reply via email to