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 d3a8b37884e Merge DropTableStatementContext and 
TableAvailableSQLStatementContext (#35699)
d3a8b37884e is described below

commit d3a8b37884ee5d541d265dfc6915191ed53e5185
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Fri Jun 13 19:34:48 2025 +0800

    Merge DropTableStatementContext and TableAvailableSQLStatementContext 
(#35699)
---
 .../sql/ddl/ShardingDropTableSupportedChecker.java | 10 ++---
 .../ddl/ShardingDropTableRouteContextChecker.java  |  9 ++---
 .../ddl/ShardingDropTableSupportedCheckerTest.java |  8 ++--
 .../ShardingDropTableRouteContextCheckerTest.java  | 22 ++++++-----
 .../statement/SQLStatementContextFactory.java      |  3 +-
 .../type/ddl/DropTableStatementContext.java        | 44 ----------------------
 .../type/ddl/DropTableStatementContextTest.java    | 40 --------------------
 .../sql/table/SingleDropTableSupportedChecker.java |  8 ++--
 .../sql/SingleDropTableSupportedCheckerTest.java   |  6 +--
 9 files changed, 35 insertions(+), 115 deletions(-)

diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedChecker.java
index 218e03f83cd..1a0800b4c32 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedChecker.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.sharding.checker.sql.ddl;
 
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropTableStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -31,16 +31,16 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropTab
 /**
  * Drop table supported checker for sharding.
  */
-public final class ShardingDropTableSupportedChecker implements 
SupportedSQLChecker<DropTableStatementContext, ShardingRule> {
+public final class ShardingDropTableSupportedChecker implements 
SupportedSQLChecker<TableAvailableSQLStatementContext, ShardingRule> {
     
     @Override
     public boolean isCheck(final SQLStatementContext sqlStatementContext) {
-        return sqlStatementContext instanceof DropTableStatementContext;
+        return sqlStatementContext.getSqlStatement() instanceof 
DropTableStatement;
     }
     
     @Override
-    public void check(final ShardingRule rule, final ShardingSphereDatabase 
database, final ShardingSphereSchema currentSchema, final 
DropTableStatementContext sqlStatementContext) {
-        DropTableStatement dropTableStatement = 
sqlStatementContext.getSqlStatement();
+    public void check(final ShardingRule rule, final ShardingSphereDatabase 
database, final ShardingSphereSchema currentSchema, final 
TableAvailableSQLStatementContext sqlStatementContext) {
+        DropTableStatement dropTableStatement = (DropTableStatement) 
sqlStatementContext.getSqlStatement();
         if (!dropTableStatement.isIfExists()) {
             ShardingSphereSchema schema = 
sqlStatementContext.getTablesContext().getSchemaName().map(database::getSchema).orElse(currentSchema);
             ShardingSupportedCommonChecker.checkTableExist(schema, 
sqlStatementContext.getTablesContext().getSimpleTables());
diff --git 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextChecker.java
 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextChecker.java
index 41fe0672611..e841938a474 100644
--- 
a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextChecker.java
+++ 
b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextChecker.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.sharding.route.engine.checker.ddl;
 
 import com.cedarsoftware.util.CaseInsensitiveSet;
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropTableStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
@@ -45,17 +45,16 @@ public final class ShardingDropTableRouteContextChecker 
implements ShardingRoute
     
     @Override
     public void check(final ShardingRule shardingRule, final QueryContext 
queryContext, final ShardingSphereDatabase database, final 
ConfigurationProperties props, final RouteContext routeContext) {
-        DropTableStatementContext dropTableStatementContext = 
(DropTableStatementContext) queryContext.getSqlStatementContext();
-        DropTableStatement dropTableStatement = 
dropTableStatementContext.getSqlStatement();
+        TableAvailableSQLStatementContext dropTableStatementContext = 
(TableAvailableSQLStatementContext) queryContext.getSqlStatementContext();
         checkTableInUsed(shardingRule, dropTableStatementContext, 
routeContext);
-        for (SimpleTableSegment each : dropTableStatement.getTables()) {
+        for (SimpleTableSegment each : ((DropTableStatement) 
dropTableStatementContext.getSqlStatement()).getTables()) {
             if 
(ShardingSupportedCheckUtils.isRouteUnitDataNodeDifferentSize(shardingRule, 
routeContext, each.getTableName().getIdentifier().getValue())) {
                 throw new ShardingDDLRouteException("DROP", "TABLE", 
dropTableStatementContext.getTablesContext().getTableNames());
             }
         }
     }
     
-    private void checkTableInUsed(final ShardingRule shardingRule, final 
DropTableStatementContext sqlStatementContext, final RouteContext routeContext) 
{
+    private void checkTableInUsed(final ShardingRule shardingRule, final 
TableAvailableSQLStatementContext sqlStatementContext, final RouteContext 
routeContext) {
         Collection<String> dropTables = 
sqlStatementContext.getTablesContext().getTableNames();
         Collection<String> otherRuleActualTables = 
shardingRule.getShardingTables().values().stream().filter(each -> 
!dropTables.contains(each.getLogicTable()))
                 .flatMap(each -> 
each.getActualDataNodes().stream().map(DataNode::getTableName)).collect(Collectors.toCollection(CaseInsensitiveSet::new));
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
index cdc648b09de..976b6e7c530 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/checker/sql/ddl/ShardingDropTableSupportedCheckerTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.sharding.checker.sql.ddl;
 
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropTableStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
@@ -35,6 +35,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import org.mockito.junit.jupiter.MockitoSettings;
 import org.mockito.quality.Strictness;
 
+import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -63,8 +64,9 @@ class ShardingDropTableSupportedCheckerTest {
     @Test
     void assertCheck() {
         DropTableStatement sqlStatement = new DropTableStatement();
-        sqlStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order_item"))));
-        DropTableStatementContext sqlStatementContext = new 
DropTableStatementContext(mock(), sqlStatement);
+        SimpleTableSegment table = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order_item")));
+        sqlStatement.getTables().add(table);
+        TableAvailableSQLStatementContext sqlStatementContext = new 
TableAvailableSQLStatementContext(mock(), sqlStatement, 
Collections.singleton(table));
         ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS);
         ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
         when(schema.containsTable("t_order_item")).thenReturn(true);
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
index af3e54119ea..df0ff77fc8b 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/route/engine/checker/ddl/ShardingDropTableRouteContextCheckerTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.sharding.route.engine.checker.ddl;
 
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropTableStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
 import org.apache.shardingsphere.infra.datanode.DataNode;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -80,7 +80,8 @@ class ShardingDropTableRouteContextCheckerTest {
     @Test
     void assertCheckWhenDropTableInUsed() {
         DropTableStatement sqlStatement = new DropTableStatement();
-        sqlStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order_item"))));
+        SimpleTableSegment table = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order_item")));
+        sqlStatement.getTables().add(table);
         ShardingSphereDatabase database = mock(ShardingSphereDatabase.class, 
RETURNS_DEEP_STUBS);
         when(database.getName()).thenReturn("db_schema");
         
when(database.getSchema("db_schema").containsTable("t_order_item")).thenReturn(true);
@@ -93,7 +94,7 @@ class ShardingDropTableRouteContextCheckerTest {
         routeUnits.add(routeUnit);
         RouteContext routeContext = mock(RouteContext.class);
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        when(queryContext.getSqlStatementContext()).thenReturn(new 
DropTableStatementContext(mock(), sqlStatement));
+        when(queryContext.getSqlStatementContext()).thenReturn(new 
TableAvailableSQLStatementContext(mock(), sqlStatement, table));
         assertThrows(InUsedTablesException.class, () -> new 
ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, 
database, mock(ConfigurationProperties.class), routeContext));
     }
     
@@ -119,14 +120,15 @@ class ShardingDropTableRouteContextCheckerTest {
     @Test
     void assertCheckWithSameRouteResultShardingTableForPostgreSQL() {
         DropTableStatement sqlStatement = new DropTableStatement();
-        sqlStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order"))));
+        SimpleTableSegment table = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order")));
+        sqlStatement.getTables().add(table);
         when(shardingRule.isShardingTable("t_order")).thenReturn(true);
         when(shardingRule.getShardingTable("t_order")).thenReturn(new 
ShardingTable(Arrays.asList("ds_0", "ds_1"), "t_order"));
         Collection<RouteUnit> routeUnits = new LinkedList<>();
         routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), 
Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
         routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), 
Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        when(queryContext.getSqlStatementContext()).thenReturn(new 
DropTableStatementContext(mock(), sqlStatement));
+        when(queryContext.getSqlStatementContext()).thenReturn(new 
TableAvailableSQLStatementContext(mock(), sqlStatement, table));
         assertDoesNotThrow(() -> new 
ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, 
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
                 mock(ConfigurationProperties.class), routeContext));
     }
@@ -134,13 +136,14 @@ class ShardingDropTableRouteContextCheckerTest {
     @Test
     void assertCheckWithDifferentRouteResultShardingTableForPostgreSQL() {
         DropTableStatement sqlStatement = new DropTableStatement();
-        sqlStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order"))));
+        SimpleTableSegment table = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_order")));
+        sqlStatement.getTables().add(table);
         when(shardingRule.isShardingTable("t_order")).thenReturn(true);
         when(shardingRule.getShardingTable("t_order")).thenReturn(new 
ShardingTable(Arrays.asList("ds_0", "ds_1"), "t_order"));
         Collection<RouteUnit> routeUnits = new LinkedList<>();
         routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), 
Collections.singleton(new RouteMapper("t_order", "t_order_0"))));
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        when(queryContext.getSqlStatementContext()).thenReturn(new 
DropTableStatementContext(mock(), sqlStatement));
+        when(queryContext.getSqlStatementContext()).thenReturn(new 
TableAvailableSQLStatementContext(mock(), sqlStatement, table));
         assertThrows(ShardingDDLRouteException.class, () -> new 
ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, 
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
                 mock(ConfigurationProperties.class), routeContext));
     }
@@ -148,13 +151,14 @@ class ShardingDropTableRouteContextCheckerTest {
     @Test
     void assertCheckWithSameRouteResultBroadcastTableForPostgreSQL() {
         DropTableStatement sqlStatement = new DropTableStatement();
-        sqlStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_config"))));
+        SimpleTableSegment table = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_config")));
+        sqlStatement.getTables().add(table);
         when(shardingRule.getShardingTable("t_config")).thenReturn(new 
ShardingTable(Arrays.asList("ds_0", "ds_1"), "t_config"));
         Collection<RouteUnit> routeUnits = new LinkedList<>();
         routeUnits.add(new RouteUnit(new RouteMapper("ds_0", "ds_0"), 
Collections.singleton(new RouteMapper("t_config", "t_config"))));
         routeUnits.add(new RouteUnit(new RouteMapper("ds_1", "ds_1"), 
Collections.singleton(new RouteMapper("t_config", "t_config"))));
         when(routeContext.getRouteUnits()).thenReturn(routeUnits);
-        when(queryContext.getSqlStatementContext()).thenReturn(new 
DropTableStatementContext(mock(), sqlStatement));
+        when(queryContext.getSqlStatementContext()).thenReturn(new 
TableAvailableSQLStatementContext(mock(), sqlStatement, table));
         assertDoesNotThrow(() -> new 
ShardingDropTableRouteContextChecker().check(shardingRule, queryContext, 
mock(ShardingSphereDatabase.class, RETURNS_DEEP_STUBS),
                 mock(ConfigurationProperties.class), routeContext));
     }
diff --git 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
 
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
index 1da5bbf7c8f..33400a01b54 100644
--- 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
+++ 
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/SQLStatementContextFactory.java
@@ -38,7 +38,6 @@ import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateT
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CreateViewStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.CursorStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropIndexStatementContext;
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropTableStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.FetchStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.MoveStatementContext;
 import 
org.apache.shardingsphere.infra.binder.context.statement.type.dml.CopyStatementContext;
@@ -186,7 +185,7 @@ public final class SQLStatementContextFactory {
             return new TableAvailableSQLStatementContext(databaseType, 
sqlStatement, ((RenameTableStatement) sqlStatement).getTables());
         }
         if (sqlStatement instanceof DropTableStatement) {
-            return new DropTableStatementContext(databaseType, 
(DropTableStatement) sqlStatement);
+            return new TableAvailableSQLStatementContext(databaseType, 
sqlStatement, ((DropTableStatement) sqlStatement).getTables());
         }
         if (sqlStatement instanceof CreateIndexStatement) {
             return new CreateIndexStatementContext(databaseType, 
(CreateIndexStatement) sqlStatement);
diff --git 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropTableStatementContext.java
 
b/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropTableStatementContext.java
deleted file mode 100644
index 3c631fb2e64..00000000000
--- 
a/infra/binder/core/src/main/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropTableStatementContext.java
+++ /dev/null
@@ -1,44 +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.binder.context.statement.type.ddl;
-
-import lombok.Getter;
-import 
org.apache.shardingsphere.infra.binder.context.segment.table.TablesContext;
-import 
org.apache.shardingsphere.infra.binder.context.statement.CommonSQLStatementContext;
-import org.apache.shardingsphere.infra.binder.context.type.TableAvailable;
-import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
-import 
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropTableStatement;
-
-/**
- * Drop table statement context.
- */
-@Getter
-public final class DropTableStatementContext extends CommonSQLStatementContext 
implements TableAvailable {
-    
-    private final TablesContext tablesContext;
-    
-    public DropTableStatementContext(final DatabaseType databaseType, final 
DropTableStatement sqlStatement) {
-        super(databaseType, sqlStatement);
-        tablesContext = new TablesContext(sqlStatement.getTables());
-    }
-    
-    @Override
-    public DropTableStatement getSqlStatement() {
-        return (DropTableStatement) super.getSqlStatement();
-    }
-}
diff --git 
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropTableStatementContextTest.java
 
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropTableStatementContextTest.java
deleted file mode 100644
index 62729a87f8c..00000000000
--- 
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/ddl/DropTableStatementContextTest.java
+++ /dev/null
@@ -1,40 +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.binder.context.statement.type.ddl;
-
-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.ddl.DropTableStatement;
-import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-
-class DropTableStatementContextTest {
-    
-    @Test
-    void assertNewInstance() {
-        DropTableStatement dropTableStatement = new DropTableStatement();
-        DropTableStatementContext actual = new 
DropTableStatementContext(mock(), dropTableStatement);
-        dropTableStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("foo_tbl"))));
-        dropTableStatement.getTables().add(new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("bar_tbl"))));
-        assertThat(actual.getSqlStatement(), is(dropTableStatement));
-    }
-}
diff --git 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/checker/sql/table/SingleDropTableSupportedChecker.java
 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/checker/sql/table/SingleDropTableSupportedChecker.java
index dd4ce4616a7..d25cb9a8070 100644
--- 
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/checker/sql/table/SingleDropTableSupportedChecker.java
+++ 
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/checker/sql/table/SingleDropTableSupportedChecker.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.single.checker.sql.table;
 
 import 
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropTableStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import org.apache.shardingsphere.infra.checker.SupportedSQLChecker;
 import 
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
 import 
org.apache.shardingsphere.infra.exception.kernel.syntax.UnsupportedDropCascadeTableException;
@@ -30,7 +30,7 @@ import 
org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.DropTab
 /**
  * Drop table supported checker for single.
  */
-public final class SingleDropTableSupportedChecker implements 
SupportedSQLChecker<DropTableStatementContext, SingleRule> {
+public final class SingleDropTableSupportedChecker implements 
SupportedSQLChecker<TableAvailableSQLStatementContext, SingleRule> {
     
     @Override
     public boolean isCheck(final SQLStatementContext sqlStatementContext) {
@@ -38,7 +38,7 @@ public final class SingleDropTableSupportedChecker implements 
SupportedSQLChecke
     }
     
     @Override
-    public void check(final SingleRule rule, final ShardingSphereDatabase 
database, final ShardingSphereSchema currentSchema, final 
DropTableStatementContext sqlStatementContext) {
-        
ShardingSpherePreconditions.checkState(!sqlStatementContext.getSqlStatement().isContainsCascade(),
 UnsupportedDropCascadeTableException::new);
+    public void check(final SingleRule rule, final ShardingSphereDatabase 
database, final ShardingSphereSchema currentSchema, final 
TableAvailableSQLStatementContext sqlStatementContext) {
+        ShardingSpherePreconditions.checkState(!((DropTableStatement) 
sqlStatementContext.getSqlStatement()).isContainsCascade(), 
UnsupportedDropCascadeTableException::new);
     }
 }
diff --git 
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
 
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
index f35634c1da6..d8ae952848d 100644
--- 
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
+++ 
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/checker/sql/SingleDropTableSupportedCheckerTest.java
@@ -17,7 +17,7 @@
 
 package org.apache.shardingsphere.single.checker.sql;
 
-import 
org.apache.shardingsphere.infra.binder.context.statement.type.ddl.DropTableStatementContext;
+import 
org.apache.shardingsphere.infra.binder.context.statement.TableAvailableSQLStatementContext;
 import 
org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType;
 import 
org.apache.shardingsphere.infra.exception.kernel.syntax.UnsupportedDropCascadeTableException;
 import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -63,10 +63,10 @@ class SingleDropTableSupportedCheckerTest {
         return result;
     }
     
-    private DropTableStatementContext createSQLStatementContext(final boolean 
containsCascade) {
+    private TableAvailableSQLStatementContext createSQLStatementContext(final 
boolean containsCascade) {
         DropTableStatement dropSchemaStatement = 
mock(DropTableStatement.class, RETURNS_DEEP_STUBS);
         
when(dropSchemaStatement.isContainsCascade()).thenReturn(containsCascade);
         
when(dropSchemaStatement.getTables()).thenReturn(Collections.emptyList());
-        return new DropTableStatementContext(mock(), dropSchemaStatement);
+        return new TableAvailableSQLStatementContext(mock(), 
dropSchemaStatement, Collections.emptyList());
     }
 }

Reply via email to