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

[shardingsphere] branch master updated: Add SQLStatementHandler (#7689)

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

menghaoran 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 f40a2b4  Add SQLStatementHandler (#7689)
f40a2b4 is described below

commit f40a2b4b68b595641e514a926ad0d50119d363d8
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Oct 3 20:07:43 2020 +0800

    Add SQLStatementHandler (#7689)
    
    * For code format
    
    * Add SQLStatementHandler
    
    * Refactor CreateTableStatementHandler
    
    * Update java doc
    
    * Update ShardingInsertStatementValidator
    
    * Update ShardingUpdateStatementValidator
    
    * For code format
---
 .../ShardingCreateTableStatementValidator.java     |  2 +-
 .../impl/ShardingInsertStatementValidator.java     |  8 ++---
 .../impl/ShardingUpdateStatementValidator.java     | 16 ++++-----
 .../ShardingCreateTableStatementValidatorTest.java |  4 +--
 .../impl/ShardingDeleteStatementValidatorTest.java | 12 +++----
 .../impl/ShardingInsertStatementValidatorTest.java |  4 +--
 .../sql/dialect/handler/SQLStatementHandler.java   | 24 +++++++++++++
 .../handler/ddl/AlterIndexStatementHandler.java    |  3 +-
 .../handler/ddl/CreateTableStatementHandler.java   |  9 ++---
 .../handler/ddl/DropIndexStatementHandler.java     |  3 +-
 .../handler/dml/DeleteStatementHandler.java        |  3 +-
 .../handler/dml/InsertStatementHandler.java        |  5 +--
 .../handler/dml/SelectStatementHandler.java        |  7 ++--
 .../handler/dml/UpdateStatementHandler.java        |  7 ++--
 .../ddl/CreateTableStatementHandlerTest.java       | 40 +++++++++++-----------
 15 files changed, 89 insertions(+), 58 deletions(-)

diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidator.java
index 80cc6c8..7804d50 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidator.java
@@ -37,7 +37,7 @@ public final class ShardingCreateTableStatementValidator implements ShardingStat
     public void preValidate(final ShardingRule shardingRule, 
                             final SQLStatementContext<CreateTableStatement> sqlStatementContext, final List<Object> parameters, final ShardingSphereMetaData metaData) {
         String tableName = sqlStatementContext.getSqlStatement().getTable().getTableName().getIdentifier().getValue();
-        if (!CreateTableStatementHandler.containsNotExistClause(sqlStatementContext.getSqlStatement()) && metaData.getRuleSchemaMetaData().getAllTableNames().contains(tableName)) {
+        if (!CreateTableStatementHandler.containsIfNotExistClause(sqlStatementContext.getSqlStatement()) && metaData.getRuleSchemaMetaData().getAllTableNames().contains(tableName)) {
             throw new TableExistsException(tableName);
         }
     }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidator.java
index 0578811..e956102 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidator.java
@@ -64,10 +64,6 @@ public final class ShardingInsertStatementValidator implements ShardingStatement
         }
     }
     
-    @Override
-    public void postValidate(final InsertStatement sqlStatement, final RouteContext routeContext) {
-    }
-    
     private boolean isUpdateShardingKey(final ShardingRule shardingRule, final OnDuplicateKeyColumnsSegment onDuplicateKeyColumnsSegment, final String tableName) {
         for (AssignmentSegment each : onDuplicateKeyColumnsSegment.getColumns()) {
             if (shardingRule.isShardingColumn(each.getColumn().getIdentifier().getValue(), tableName)) {
@@ -88,4 +84,8 @@ public final class ShardingInsertStatementValidator implements ShardingStatement
     private boolean isAllSameTables(final Collection<String> tableNames) {
         return 1 == tableNames.stream().distinct().count();
     }
+    
+    @Override
+    public void postValidate(final InsertStatement sqlStatement, final RouteContext routeContext) {
+    }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidator.java
index 02c874e..ad4d402 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingUpdateStatementValidator.java
@@ -67,14 +67,7 @@ public final class ShardingUpdateStatementValidator implements ShardingStatement
             }
         }
     }
-
-    @Override
-    public void postValidate(final UpdateStatement sqlStatement, final RouteContext routeContext) {
-        if (UpdateStatementHandler.getLimitSegment(sqlStatement).isPresent() && routeContext.getRouteUnits().size() > 1) {
-            throw new ShardingSphereException("UPDATE ... LIMIT can not support sharding route to multiple data nodes.");
-        }
-    }
-
+    
     private Optional<Object> getShardingColumnSetAssignmentValue(final AssignmentSegment assignmentSegment, final List<Object> parameters) {
         ExpressionSegment segment = assignmentSegment.getValue();
         int shardingSetAssignIndex = -1;
@@ -158,4 +151,11 @@ public final class ShardingUpdateStatementValidator implements ShardingStatement
         }
         return Optional.empty();
     }
+    
+    @Override
+    public void postValidate(final UpdateStatement sqlStatement, final RouteContext routeContext) {
+        if (UpdateStatementHandler.getLimitSegment(sqlStatement).isPresent() && routeContext.getRouteUnits().size() > 1) {
+            throw new ShardingSphereException("UPDATE ... LIMIT can not support sharding route to multiple data nodes.");
+        }
+    }
 }
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java
index 9d49c91..8374aa0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingCreateTableStatementValidatorTest.java
@@ -40,10 +40,10 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 public final class ShardingCreateTableStatementValidatorTest {
-
+    
     @Mock
     private ShardingRule shardingRule;
-
+    
     @Test(expected = TableExistsException.class)
     public void assertValidateMySQLCreateTable() {
         MySQLCreateTableStatement sqlStatement = new MySQLCreateTableStatement();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java
index 4c6a0c5..3bea5fc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingDeleteStatementValidatorTest.java
@@ -38,30 +38,30 @@ import java.util.Collections;
 import static org.mockito.Mockito.mock;
 
 public final class ShardingDeleteStatementValidatorTest {
-
+    
     @Mock
     private ShardingRule shardingRule;
-
+    
     @Test(expected = ShardingSphereException.class)
     public void assertValidateMySQLDeleteModifyMultiTables() {
         assertValidateDeleteModifyMultiTables(new MySQLDeleteStatement());
     }
-
+    
     @Test(expected = ShardingSphereException.class)
     public void assertValidateOracleDeleteModifyMultiTables() {
         assertValidateDeleteModifyMultiTables(new OracleDeleteStatement());
     }
-
+    
     @Test(expected = ShardingSphereException.class)
     public void assertValidatePostgreSQLDeleteModifyMultiTables() {
         assertValidateDeleteModifyMultiTables(new PostgreSQLDeleteStatement());
     }
-
+    
     @Test(expected = ShardingSphereException.class)
     public void assertValidateSQL92DeleteModifyMultiTables() {
         assertValidateDeleteModifyMultiTables(new SQL92DeleteStatement());
     }
-
+    
     @Test(expected = ShardingSphereException.class)
     public void assertValidateSQLServerDeleteModifyMultiTables() {
         assertValidateDeleteModifyMultiTables(new SQLServerDeleteStatement());
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java
index 8960f51..8d602ea 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/validator/impl/ShardingInsertStatementValidatorTest.java
@@ -56,14 +56,14 @@ public final class ShardingInsertStatementValidatorTest {
     
     @Mock
     private ShardingRule shardingRule;
-
+    
     @Test(expected = ShardingSphereException.class)
     public void assertValidateInsertModifyMultiTables() {
         SQLStatementContext<InsertStatement> sqlStatementContext = new InsertStatementContext(new SchemaMetaData(Collections.emptyMap()), Collections.singletonList(1), createInsertStatement());
         sqlStatementContext.getTablesContext().getTables().addAll(createMultiTablesContext().getTables());
         new ShardingInsertStatementValidator().preValidate(shardingRule, sqlStatementContext, Collections.emptyList(), mock(ShardingSphereMetaData.class));
     }
-
+    
     @Test
     public void assertValidateOnDuplicateKeyWithoutShardingKey() {
         when(shardingRule.isShardingColumn("id", "user")).thenReturn(false);
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/SQLStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/SQLStatementHandler.java
new file mode 100644
index 0000000..586b177
--- /dev/null
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/SQLStatementHandler.java
@@ -0,0 +1,24 @@
+/*
+ * 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.sql.parser.sql.dialect.handler;
+
+/**
+ * SQL statement handler.
+ */
+public interface SQLStatementHandler {
+}
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/AlterIndexStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/AlterIndexStatementHandler.java
index 26c06dc..1fe7fc2 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/AlterIndexStatementHandler.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/AlterIndexStatementHandler.java
@@ -21,6 +21,7 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.AlterIndexStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.ddl.SQLServerAlterIndexStatement;
 
@@ -30,7 +31,7 @@ import java.util.Optional;
  * Alter index statement handler for different dialect SQL statements.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class AlterIndexStatementHandler {
+public final class AlterIndexStatementHandler implements SQLStatementHandler {
     
     /**
      * Get simple table segment.
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
index 9622d14..d4332a9 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandler.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.sql.parser.sql.dialect.handler.ddl;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.CreateTableStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.ddl.MySQLCreateTableStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
@@ -29,15 +30,15 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.ddl
  * Create table statement handler for different dialect SQL statements.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class CreateTableStatementHandler {
+public final class CreateTableStatementHandler implements SQLStatementHandler {
     
     /**
-     * Judge whether contains not exist clause.
+     * Judge whether contains if not exist clause.
      *
      * @param createTableStatement create table statement
-     * @return contains not exist clause or not
+     * @return contains if not exist clause or not
      */
-    public static boolean containsNotExistClause(final CreateTableStatement createTableStatement) {
+    public static boolean containsIfNotExistClause(final CreateTableStatement createTableStatement) {
         if (createTableStatement instanceof MySQLStatement) {
             return ((MySQLCreateTableStatement) createTableStatement).isNotExisted();
         }
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java
index a692b02..3fc25c4 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/DropIndexStatementHandler.java
@@ -21,6 +21,7 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.ddl.DropIndexStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.ddl.MySQLDropIndexStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.sqlserver.SQLServerStatement;
@@ -32,7 +33,7 @@ import java.util.Optional;
  * Drop index statement handler for different dialect SQL statements.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DropIndexStatementHandler {
+public final class DropIndexStatementHandler implements SQLStatementHandler {
     
     /**
      * Get simple table segment.
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/DeleteStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/DeleteStatementHandler.java
index 67b8edc..e03b320 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/DeleteStatementHandler.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/DeleteStatementHandler.java
@@ -22,6 +22,7 @@ import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.OrderBySegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.LimitSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLDeleteStatement;
 
@@ -31,7 +32,7 @@ import java.util.Optional;
  * Delete statement handler for different dialect SQL statements.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DeleteStatementHandler {
+public final class DeleteStatementHandler implements SQLStatementHandler {
     
     /**
      * Get order by segment.
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
index 6a02051..dc9173d 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/InsertStatementHandler.java
@@ -21,9 +21,10 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.SetAssignmentSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.OnDuplicateKeyColumnsSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.OutputSegment;
+import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.WithSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLInsertStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.postgresql.PostgreSQLStatement;
@@ -37,7 +38,7 @@ import java.util.Optional;
  * Insert statement handler for different dialect SQL statements.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class InsertStatementHandler {
+public final class InsertStatementHandler implements SQLStatementHandler {
     
     /**
      * Get On duplicate key columns segment.
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/SelectStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/SelectStatementHandler.java
index b16c9e6..3afb3e6 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/SelectStatementHandler.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/SelectStatementHandler.java
@@ -22,6 +22,7 @@ import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.LimitSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.LockSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLSelectStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.oracle.OracleStatement;
@@ -39,8 +40,8 @@ import java.util.Optional;
  * Select statement helper class for different dialect SQL statements.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class SelectStatementHandler {
-
+public final class SelectStatementHandler implements SQLStatementHandler {
+    
     /**
      * Get limit segment.
      *
@@ -62,7 +63,7 @@ public final class SelectStatementHandler {
         }
         return Optional.empty();
     }
-
+    
     /**
      * Get lock segment.
      *
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/UpdateStatementHandler.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/UpdateStatementHandler.java
index 4ad318c..9918b67 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/UpdateStatementHandler.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/dml/UpdateStatementHandler.java
@@ -22,6 +22,7 @@ import lombok.NoArgsConstructor;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.OrderBySegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.pagination.limit.LimitSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
+import org.apache.shardingsphere.sql.parser.sql.dialect.handler.SQLStatementHandler;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.MySQLStatement;
 import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dml.MySQLUpdateStatement;
 
@@ -31,8 +32,8 @@ import java.util.Optional;
  * Update statement helper class for different dialect SQL statements.
  */
 @NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class UpdateStatementHandler {
-
+public final class UpdateStatementHandler implements SQLStatementHandler {
+    
     /**
      * Get order by segment.
      *
@@ -45,7 +46,7 @@ public final class UpdateStatementHandler {
         }
         return Optional.empty();
     }
-
+    
     /**
      * Get limit segment.
      *
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java
index 4a085d1..1b14bc8 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/test/java/org/apache/shardingsphere/sql/parser/sql/dialect/handler/ddl/CreateTableStatementHandlerTest.java
@@ -27,58 +27,58 @@ import org.junit.Test;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
-public class CreateTableStatementHandlerTest {
+public final class CreateTableStatementHandlerTest {
     
     @Test
-    public void assertContainsNotExistClauseForMySQL() {
+    public void assertContainsIfNotExistClauseForMySQL() {
         MySQLCreateTableStatement createTableStatement = new MySQLCreateTableStatement();
         createTableStatement.setNotExisted(true);
-        boolean containsNotExistClause = CreateTableStatementHandler.containsNotExistClause(createTableStatement);
+        boolean containsNotExistClause = CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
         assertTrue(containsNotExistClause);
     }
-
+    
     @Test
-    public void assertContainsNotExistClauseForPostgreSQL() {
+    public void assertContainsIfNotExistClauseForPostgreSQL() {
         PostgreSQLCreateTableStatement createTableStatement = new PostgreSQLCreateTableStatement();
         createTableStatement.setNotExisted(true);
-        boolean containsNotExistClause = CreateTableStatementHandler.containsNotExistClause(createTableStatement);
+        boolean containsNotExistClause = CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
         assertTrue(containsNotExistClause);
     }
-
+    
     @Test
-    public void assertNotContainsNotExistClauseForMySQL() {
+    public void assertNotContainsIfNotExistClauseForMySQL() {
         MySQLCreateTableStatement createTableStatement = new MySQLCreateTableStatement();
         createTableStatement.setNotExisted(false);
-        boolean containsNotExistClause = CreateTableStatementHandler.containsNotExistClause(createTableStatement);
+        boolean containsNotExistClause = CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
         assertFalse(containsNotExistClause);
     }
-
+    
     @Test
-    public void assertNotContainsNotExistClauseForOracle() {
+    public void assertNotContainsIfNotExistClauseForOracle() {
         OracleCreateTableStatement createTableStatement = new OracleCreateTableStatement();
-        boolean containsNotExistClause = CreateTableStatementHandler.containsNotExistClause(createTableStatement);
+        boolean containsNotExistClause = CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
         assertFalse(containsNotExistClause);
     }
-
+    
     @Test
-    public void assertNotContainsNotExistClauseForPostgreSQL() {
+    public void assertNotContainsIfNotExistClauseForPostgreSQL() {
         PostgreSQLCreateTableStatement createTableStatement = new PostgreSQLCreateTableStatement();
         createTableStatement.setNotExisted(false);
-        boolean containsNotExistClause = CreateTableStatementHandler.containsNotExistClause(createTableStatement);
+        boolean containsNotExistClause = CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
         assertFalse(containsNotExistClause);
     }
-
+    
     @Test
     public void assertNotContainsNotExistClauseForSQL92() {
         SQL92CreateTableStatement createTableStatement = new SQL92CreateTableStatement();
-        boolean containsNotExistClause = CreateTableStatementHandler.containsNotExistClause(createTableStatement);
+        boolean containsNotExistClause = CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
         assertFalse(containsNotExistClause);
     }
-
+    
     @Test
-    public void assertNotContainsNotExistClauseForSQLServer() {
+    public void assertNotContainsIfNotExistClauseForSQLServer() {
         SQLServerCreateTableStatement createTableStatement = new SQLServerCreateTableStatement();
-        boolean containsNotExistClause = CreateTableStatementHandler.containsNotExistClause(createTableStatement);
+        boolean containsNotExistClause = CreateTableStatementHandler.containsIfNotExistClause(createTableStatement);
         assertFalse(containsNotExistClause);
     }
 }