You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2025/06/26 08:45:34 UTC

(shardingsphere) branch master updated: Add DialectUnsupportedShardingSQLStatementProvider (#35802)

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

zhangliang 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 c91e6f61e3d Add DialectUnsupportedShardingSQLStatementProvider (#35802)
c91e6f61e3d is described below

commit c91e6f61e3d450a226e6a30fce38cd17dd876937
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jun 26 16:45:27 2025 +0800

    Add DialectUnsupportedShardingSQLStatementProvider (#35802)
    
    * Add DialectUnsupportedShardingSQLStatementProvider
    
    * Add DialectUnsupportedShardingSQLStatementProvider
---
 .../sql/ShardingSupportedSQLCheckersBuilder.java   |  8 +--
 ...ectUnsupportedShardingSQLStatementProvider.java | 38 +++++++++++++
 .../sql/dml/ShardingLoadDataSupportedChecker.java  | 46 ----------------
 .../sql/dml/ShardingLoadXmlSupportedChecker.java   | 46 ----------------
 ...ker.java => ShardingTableSupportedChecker.java} | 18 ++++---
 .../dml/ShardingLoadDataSupportedCheckerTest.java  | 63 ----------------------
 .../dml/ShardingLoadXmlSupportedCheckerTest.java   | 63 ----------------------
 ...java => ShardingTableSupportedCheckerTest.java} | 31 ++++++-----
 ...SQLUnsupportedShardingSQLStatementProvider.java | 45 ++++++++++++++++
 ....DialectUnsupportedShardingSQLStatementProvider | 18 +++++++
 10 files changed, 130 insertions(+), 246 deletions(-)

diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ShardingSupportedSQLCheckersBuilder.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ShardingSupportedSQLCheckersBuilder.java
index 1591411901c..9561c40bf24 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ShardingSupportedSQLCheckersBuilder.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ShardingSupportedSQLCheckersBuilder.java
@@ -30,11 +30,9 @@ import org.apache.shardingsphere.sharding.checker.sql.ddl.ShardingCreateViewSupp
 import org.apache.shardingsphere.sharding.checker.sql.ddl.ShardingDropIndexSupportedChecker;
 import org.apache.shardingsphere.sharding.checker.sql.ddl.ShardingDropTableSupportedChecker;
 import org.apache.shardingsphere.sharding.checker.sql.ddl.ShardingRenameTableSupportedChecker;
-import org.apache.shardingsphere.sharding.checker.sql.dml.ShardingCopySupportedChecker;
 import org.apache.shardingsphere.sharding.checker.sql.dml.ShardingInsertSupportedChecker;
-import org.apache.shardingsphere.sharding.checker.sql.dml.ShardingLoadDataSupportedChecker;
-import org.apache.shardingsphere.sharding.checker.sql.dml.ShardingLoadXmlSupportedChecker;
 import org.apache.shardingsphere.sharding.checker.sql.dml.ShardingMultipleTablesSupportedChecker;
+import org.apache.shardingsphere.sharding.checker.sql.dml.ShardingTableSupportedChecker;
 import org.apache.shardingsphere.sharding.constant.ShardingOrder;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 
@@ -60,10 +58,8 @@ public final class ShardingSupportedSQLCheckersBuilder implements SupportedSQLCh
                 new ShardingDropIndexSupportedChecker(),
                 new ShardingDropTableSupportedChecker(),
                 new ShardingRenameTableSupportedChecker(),
-                new ShardingCopySupportedChecker(),
                 new ShardingInsertSupportedChecker(),
-                new ShardingLoadDataSupportedChecker(),
-                new ShardingLoadXmlSupportedChecker(),
+                new ShardingTableSupportedChecker(),
                 new ShardingMultipleTablesSupportedChecker());
     }
     
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/DialectUnsupportedShardingSQLStatementProvider.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/DialectUnsupportedShardingSQLStatementProvider.java
new file mode 100644
index 00000000000..dbfc8abca66
--- /dev/null
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/DialectUnsupportedShardingSQLStatementProvider.java
@@ -0,0 +1,38 @@
+/*
+ * 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.checker.sql.dml;
+
+import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPI;
+import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
+
+import java.util.Collection;
+
+/**
+ * Dialect unsupported sharding SQL statement provider.
+ */
+@SingletonSPI
+public interface DialectUnsupportedShardingSQLStatementProvider extends DatabaseTypedSPI {
+    
+    /**
+     * Get unsupported SQL statement types.
+     *
+     * @return unsupported SQL statement types
+     */
+    Collection<Class<? extends SQLStatement>> getUnsupportedSQLStatementTypes();
+}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedChecker.java
deleted file mode 100644
index f0f133c83ce..00000000000
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedChecker.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.checker.sql.dml;
-
-import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
-import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-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.UnsupportedShardingOperationException;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.LoadDataStatement;
-
-/**
- * Load data supported checker for sharding.
- */
-@HighFrequencyInvocation
-public final class ShardingLoadDataSupportedChecker implements SupportedSQLChecker<SQLStatementContext, ShardingRule> {
-    
-    @Override
-    public boolean isCheck(final SQLStatementContext sqlStatementContext) {
-        return sqlStatementContext.getSqlStatement() instanceof LoadDataStatement;
-    }
-    
-    @Override
-    public void check(final ShardingRule rule, final ShardingSphereDatabase database, final ShardingSphereSchema currentSchema, final SQLStatementContext sqlStatementContext) {
-        String tableName = ((LoadDataStatement) sqlStatementContext.getSqlStatement()).getTable().getTableName().getIdentifier().getValue();
-        ShardingSpherePreconditions.checkState(!rule.isShardingTable(tableName), () -> new UnsupportedShardingOperationException("LOAD DATA", tableName));
-    }
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedChecker.java
deleted file mode 100644
index 8299488d094..00000000000
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedChecker.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.checker.sql.dml;
-
-import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
-import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
-import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
-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.UnsupportedShardingOperationException;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.LoadXMLStatement;
-
-/**
- * Load xml supported checker for sharding.
- */
-@HighFrequencyInvocation
-public final class ShardingLoadXmlSupportedChecker implements SupportedSQLChecker<SQLStatementContext, ShardingRule> {
-    
-    @Override
-    public boolean isCheck(final SQLStatementContext sqlStatementContext) {
-        return sqlStatementContext.getSqlStatement() instanceof LoadXMLStatement;
-    }
-    
-    @Override
-    public void check(final ShardingRule rule, final ShardingSphereDatabase database, final ShardingSphereSchema currentSchema, final SQLStatementContext sqlStatementContext) {
-        String tableName = ((LoadXMLStatement) sqlStatementContext.getSqlStatement()).getTable().getTableName().getIdentifier().getValue();
-        ShardingSpherePreconditions.checkState(!rule.isShardingTable(tableName), () -> new UnsupportedShardingOperationException("LOAD XML", tableName));
-    }
-}
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedChecker.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedChecker.java
similarity index 62%
rename from features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedChecker.java
rename to features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedChecker.java
index de99ae31826..d053f0f6ca6 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedChecker.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedChecker.java
@@ -20,27 +20,33 @@ package org.apache.shardingsphere.sharding.checker.sql.dml;
 import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
 import org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
+import org.apache.shardingsphere.infra.database.core.spi.DatabaseTypedSPILoader;
 import org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 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.UnsupportedShardingOperationException;
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.CopyStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
 
 /**
- * Copy supported checker for sharding.
+ * Table supported checker for sharding.
  */
 @HighFrequencyInvocation
-public final class ShardingCopySupportedChecker implements SupportedSQLChecker<SQLStatementContext, ShardingRule> {
+public final class ShardingTableSupportedChecker implements SupportedSQLChecker<SQLStatementContext, ShardingRule> {
     
     @Override
     public boolean isCheck(final SQLStatementContext sqlStatementContext) {
-        return sqlStatementContext.getSqlStatement() instanceof CopyStatement && ((CopyStatement) sqlStatementContext.getSqlStatement()).getTable().isPresent();
+        return DatabaseTypedSPILoader.findService(DialectUnsupportedShardingSQLStatementProvider.class, sqlStatementContext.getDatabaseType())
+                .map(optional -> optional.getUnsupportedSQLStatementTypes().contains(sqlStatementContext.getSqlStatement().getClass())).orElse(false);
     }
     
     @Override
     public void check(final ShardingRule rule, final ShardingSphereDatabase database, final ShardingSphereSchema currentSchema, final SQLStatementContext sqlStatementContext) {
-        String tableName = ((CopyStatement) sqlStatementContext.getSqlStatement()).getTable().map(optional -> optional.getTableName().getIdentifier().getValue()).orElse("");
-        ShardingSpherePreconditions.checkState(!rule.isShardingTable(tableName), () -> new UnsupportedShardingOperationException("COPY", tableName));
+        for (SimpleTableSegment each : sqlStatementContext.getSqlStatement().getAttributes().getAttribute(TableSQLStatementAttribute.class).getTables()) {
+            String tableName = each.getTableName().getIdentifier().getValue();
+            ShardingSpherePreconditions.checkState(
+                    !rule.isShardingTable(tableName), () -> new UnsupportedShardingOperationException(sqlStatementContext.getSqlStatement().getClass().getSimpleName(), tableName));
+        }
     }
 }
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedCheckerTest.java
deleted file mode 100644
index 81721af7f13..00000000000
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadDataSupportedCheckerTest.java
+++ /dev/null
@@ -1,63 +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.checker.sql.dml;
-
-import org.apache.shardingsphere.infra.binder.context.statement.type.CommonSQLStatementContext;
-import org.apache.shardingsphere.sharding.exception.syntax.UnsupportedShardingOperationException;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.LoadDataStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(MockitoExtension.class)
-class ShardingLoadDataSupportedCheckerTest {
-    
-    @Mock
-    private ShardingRule rule;
-    
-    @Test
-    void assertCheckWithSingleTable() {
-        LoadDataStatement sqlStatement = mock(LoadDataStatement.class);
-        SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
-        when(sqlStatement.getTable()).thenReturn(table);
-        when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(table)));
-        assertDoesNotThrow(() -> new ShardingLoadDataSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
-    }
-    
-    @Test
-    void assertCheckWithShardingTable() {
-        LoadDataStatement sqlStatement = mock(LoadDataStatement.class);
-        SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
-        when(sqlStatement.getTable()).thenReturn(table);
-        when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(table)));
-        when(rule.isShardingTable("foo_tbl")).thenReturn(true);
-        assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingLoadDataSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
-    }
-}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedCheckerTest.java
deleted file mode 100644
index 4dab84e0524..00000000000
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingLoadXmlSupportedCheckerTest.java
+++ /dev/null
@@ -1,63 +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.checker.sql.dml;
-
-import org.apache.shardingsphere.infra.binder.context.statement.type.CommonSQLStatementContext;
-import org.apache.shardingsphere.sharding.exception.syntax.UnsupportedShardingOperationException;
-import org.apache.shardingsphere.sharding.rule.ShardingRule;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.LoadXMLStatement;
-import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(MockitoExtension.class)
-class ShardingLoadXmlSupportedCheckerTest {
-    
-    @Mock
-    private ShardingRule rule;
-    
-    @Test
-    void assertCheckWithSingleTable() {
-        LoadXMLStatement sqlStatement = mock(LoadXMLStatement.class);
-        SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
-        when(sqlStatement.getTable()).thenReturn(table);
-        when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(table)));
-        assertDoesNotThrow(() -> new ShardingLoadXmlSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
-    }
-    
-    @Test
-    void assertCheckWithShardingTable() {
-        LoadXMLStatement sqlStatement = mock(LoadXMLStatement.class);
-        SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
-        when(sqlStatement.getTable()).thenReturn(table);
-        when(rule.isShardingTable("foo_tbl")).thenReturn(true);
-        when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(table)));
-        assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingLoadXmlSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
-    }
-}
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedCheckerTest.java
similarity index 73%
rename from features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
rename to features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedCheckerTest.java
index ab60c07f371..c2e74056172 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingCopySupportedCheckerTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/dml/ShardingTableSupportedCheckerTest.java
@@ -22,44 +22,43 @@ import org.apache.shardingsphere.sharding.exception.syntax.UnsupportedShardingOp
 import org.apache.shardingsphere.sharding.rule.ShardingRule;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
 import org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.SQLStatementAttributes;
 import org.apache.shardingsphere.sql.parser.statement.core.statement.attribute.type.TableSQLStatementAttribute;
-import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.CopyStatement;
 import org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
 
-import java.util.Optional;
-
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 @ExtendWith(MockitoExtension.class)
-class ShardingCopySupportedCheckerTest {
+class ShardingTableSupportedCheckerTest {
+    
+    @Mock
+    private SQLStatement sqlStatement;
     
     @Mock
     private ShardingRule rule;
     
-    @Test
-    void assertCheckWithNotShardingTable() {
-        assertDoesNotThrow(() -> new ShardingCopySupportedChecker().check(rule, mock(), mock(), createSQLStatementContext()));
+    @BeforeEach
+    void setUp() {
+        when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl"))))));
     }
     
     @Test
-    void assertCheckWitShardingTable() {
-        when(rule.isShardingTable("foo_tbl")).thenReturn(true);
-        assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingCopySupportedChecker().check(rule, mock(), mock(), createSQLStatementContext()));
+    void assertCheckWithoutShardingTable() {
+        assertDoesNotThrow(() -> new ShardingTableSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
     }
     
-    private CommonSQLStatementContext createSQLStatementContext() {
-        CopyStatement sqlStatement = mock(CopyStatement.class);
-        SimpleTableSegment table = new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("foo_tbl")));
-        when(sqlStatement.getTable()).thenReturn(Optional.of(table));
-        when(sqlStatement.getAttributes()).thenReturn(new SQLStatementAttributes(new TableSQLStatementAttribute(table)));
-        return new CommonSQLStatementContext(mock(), sqlStatement);
+    @Test
+    void assertCheckWithShardingTable() {
+        when(rule.isShardingTable("foo_tbl")).thenReturn(true);
+        assertThrows(UnsupportedShardingOperationException.class, () -> new ShardingTableSupportedChecker().check(rule, mock(), mock(), new CommonSQLStatementContext(mock(), sqlStatement)));
     }
 }
diff --git a/features/sharding/dialect/mysql/src/main/java/org/apache/shardingsphere/sharding/check/mysql/MySQLUnsupportedShardingSQLStatementProvider.java b/features/sharding/dialect/mysql/src/main/java/org/apache/shardingsphere/sharding/check/mysql/MySQLUnsupportedShardingSQLStatementProvider.java
new file mode 100644
index 00000000000..243e848d846
--- /dev/null
+++ b/features/sharding/dialect/mysql/src/main/java/org/apache/shardingsphere/sharding/check/mysql/MySQLUnsupportedShardingSQLStatementProvider.java
@@ -0,0 +1,45 @@
+/*
+ * 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.check.mysql;
+
+import org.apache.shardingsphere.sharding.checker.sql.dml.DialectUnsupportedShardingSQLStatementProvider;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.CopyStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.LoadDataStatement;
+import org.apache.shardingsphere.sql.parser.statement.core.statement.type.dml.LoadXMLStatement;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * Unsupported sharding SQL statement provider for MySQL.
+ */
+public final class MySQLUnsupportedShardingSQLStatementProvider implements DialectUnsupportedShardingSQLStatementProvider {
+    
+    private static final Collection<Class<? extends SQLStatement>> UNSUPPORTED_SQL_STATEMENT_TYPES = Arrays.asList(CopyStatement.class, LoadDataStatement.class, LoadXMLStatement.class);
+    
+    @Override
+    public Collection<Class<? extends SQLStatement>> getUnsupportedSQLStatementTypes() {
+        return UNSUPPORTED_SQL_STATEMENT_TYPES;
+    }
+    
+    @Override
+    public String getDatabaseType() {
+        return "MySQL";
+    }
+}
diff --git a/features/sharding/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.checker.sql.dml.DialectUnsupportedShardingSQLStatementProvider b/features/sharding/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.checker.sql.dml.DialectUnsupportedShardingSQLStatementProvider
new file mode 100644
index 00000000000..f90e0f0608f
--- /dev/null
+++ b/features/sharding/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.checker.sql.dml.DialectUnsupportedShardingSQLStatementProvider
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.sharding.check.mysql.MySQLUnsupportedShardingSQLStatementProvider