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

panjuan 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 b09b437  Main structure code of processing SCTL dist SQL. (#11742)
b09b437 is described below

commit b09b437527f2c87801e8f5edefc21fba955aeec3
Author: Raigor <[email protected]>
AuthorDate: Thu Aug 12 14:25:57 2021 +0800

    Main structure code of processing SCTL dist SQL. (#11742)
    
    * Add SCTL syntax definition for ANTLR
    
    * fix mistake
    
    * Parse SCTL according to the DistSQL process and implement `set 
readwrite_splitting hint source` syntax.
    
    * Rollback yaml file.
    
    * Delete blank line.
    
    * Improve comments.
    
    * fix set syntax
    
    * add TODO comment.
    
    * Fix indent of new line, move sharding and readwrite hint syntax to 
feature distsql package.
    
    * add final to param.
    
    * Rename ResourceStatement.g4 to CommonDistSQLStatement.g4
    
    * Rename SCTL to commonDistSQL
---
 .../src/main/antlr4/imports/Keyword.g4             | 16 ++++++
 .../RALStatement.g4}                               | 27 ++++++---
 ...ourceStatement.g4 => CommonDistSQLStatement.g4} |  8 ++-
 .../parser/api/DistSQLStatementParserEngine.java   |  4 +-
 .../CommonDistSQLLexer.java}                       | 10 ++--
 .../CommonDistSQLParser.java}                      | 10 ++--
 .../CommonDistSQLStatementParserEngine.java}       | 10 ++--
 .../CommonDistSQLStatementVisitor.java}            | 29 ++++++----
 .../statement/ral/CommonDistSQLStatement.java}     | 15 ++---
 .../ral/common/HintDistSQLStatement.java}          | 15 +++--
 .../ral/common/PreviewDistSQLStatement.java        | 16 +++---
 .../statement/ral/common/SetDistSQLStatement.java} | 15 +++--
 .../ral/common/ShowDistSQLStatement.java}          | 15 +++--
 .../ral/common/hint/ClearHintStatement.java}       | 19 +++---
 .../ral/common/preview/PreviewStatement.java}      | 21 ++++---
 .../antlr4/imports/readwrite-splitting/Keyword.g4  | 20 +++++++
 .../imports/readwrite-splitting/RALStatement.g4    | 23 +++++---
 .../autogen/ReadwriteSplittingRuleStatement.g4     |  5 +-
 .../ReadwriteSplittingRuleSQLStatementVisitor.java |  7 +++
 .../SetReadwriteSplittingHintSourceStatement.java  | 18 +++---
 .../src/main/antlr4/imports/sharding/Keyword.g4    | 30 +++++++++-
 .../main/antlr4/imports/sharding/RALStatement.g4   | 64 ++++++---------------
 .../parser/autogen/ShardingRuleStatement.g4        |  7 ++-
 .../shardingsphere/infra/hint/HintManager.java     |  7 +++
 .../shardingsphere/infra/hint/HintManagerTest.java |  8 +++
 .../text/distsql/ral/RALBackendHandlerFactory.java | 10 +++-
 .../common/CommonDistSQLBackendHandlerFactory.java | 62 ++++++++++++++++++++
 .../ral/common/HintDistSQLBackendHandler.java      | 66 +++++++++++++++++++++
 .../ral/common/PrviewDistSQLBackendHandler.java    | 44 ++++++++++++++
 .../ral/common/SetDistSQLBackendHandler.java       | 44 ++++++++++++++
 .../ral/common/ShowDistSQLBackendHandler.java      | 44 ++++++++++++++
 .../distsql/ral/common/hint/HintSourceType.java    | 39 ++++++++-----
 .../ral/common/hint/HintStatementExecutor.java     | 53 +++++++++++++++++
 .../common/hint/HintStatementExecutorFactory.java  | 55 ++++++++++++++++++
 .../hint/executor/AbstractHintQueryExecutor.java   | 67 ++++++++++++++++++++++
 .../hint/executor/AbstractHintUpdateExecutor.java  | 23 ++++----
 .../common/hint/executor/ClearHintExecutor.java    | 40 +++++++++++++
 .../SetReadwriteSplittingHintSourceExecutor.java   | 50 ++++++++++++++++
 38 files changed, 827 insertions(+), 189 deletions(-)

diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
index fabe60b..d9ba2a1 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
@@ -27,10 +27,18 @@ ADD
     : A D D
     ;
 
+CLEAR
+    : C L E A R
+    ;
+
 DROP
     : D R O P
     ;
 
+SET
+    : S E T
+    ;
+
 SHOW
     : S H O W
     ;
@@ -78,3 +86,11 @@ NAME
 PROPERTIES
     : P R O P E R T I E S
     ;
+
+VARIABLE
+    : V A R I A B L E
+    ;
+
+HINT
+    : H I N T
+    ;
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4
similarity index 74%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4
index 3a9e4c6..e942427 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4
@@ -15,13 +15,26 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+grammar RALStatement;
 
-import Symbol, RDLStatement, RQLStatement;
+import Keyword, Literals, Symbol;
 
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
+setVariable
+    : SET VARIABLE variableName EQ variableValue
+    ;
+
+showVariable
+    : SHOW VARIABLE variableName
+    ;
+
+clearHint
+    : CLEAR HINT
+    ;
+
+variableName
+    : IDENTIFIER
+    ;
+
+variableValue
+    : IDENTIFIER
     ;
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
similarity index 84%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
index 3a9e4c6..01bf552 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/CommonDistSQLStatement.g4
@@ -15,13 +15,17 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+grammar CommonDistSQLStatement;
 
-import Symbol, RDLStatement, RQLStatement;
+import Symbol, RALStatement, RDLStatement, RQLStatement;
 
 execute
     : (addResource
     | dropResource
     | showResources
+    | setVariable
+    | showVariable
+//    | previewSQL
+    | clearHint
     ) SEMI?
     ;
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngine.java
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngine.java
index 22e41bb..989b893 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngine.java
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngine.java
@@ -18,7 +18,7 @@
 package org.apache.shardingsphere.distsql.parser.api;
 
 import org.antlr.v4.runtime.misc.ParseCancellationException;
-import 
org.apache.shardingsphere.distsql.parser.core.resource.ResourceSQLStatementParserEngine;
+import 
org.apache.shardingsphere.distsql.parser.core.common.CommonDistSQLStatementParserEngine;
 import 
org.apache.shardingsphere.distsql.parser.core.rule.RuleSQLStatementParserEngine;
 import org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
@@ -36,7 +36,7 @@ public final class DistSQLStatementParserEngine {
      */
     public SQLStatement parse(final String sql) {
         try {
-            return new ResourceSQLStatementParserEngine().parse(sql);
+            return new CommonDistSQLStatementParserEngine().parse(sql);
         } catch (final ParseCancellationException | SQLParsingException 
ignored) {
             return new RuleSQLStatementParserEngine().parse(sql);
         }
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLLexer.java
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLLexer.java
similarity index 74%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLLexer.java
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLLexer.java
index 7515f4b..58b32d8 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLLexer.java
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLLexer.java
@@ -15,18 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.parser.core.resource;
+package org.apache.shardingsphere.distsql.parser.core.common;
 
 import org.antlr.v4.runtime.CharStream;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementLexer;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementLexer;
 import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
 
 /**
- * SQL lexer for resource dist SQL.
+ * SQL lexer for common dist SQL.
  */
-public final class ResourceDistSQLLexer extends ResourceStatementLexer 
implements SQLLexer {
+public final class CommonDistSQLLexer extends CommonDistSQLStatementLexer 
implements SQLLexer {
     
-    public ResourceDistSQLLexer(final CharStream input) {
+    public CommonDistSQLLexer(final CharStream input) {
         super(input);
     }
 }
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLParser.java
similarity index 77%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLParser.java
index b465555..d06292c 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLParser.java
@@ -15,20 +15,20 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.parser.core.resource;
+package org.apache.shardingsphere.distsql.parser.core.common;
 
 import org.antlr.v4.runtime.TokenStream;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser;
 import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
 import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
 import org.apache.shardingsphere.sql.parser.core.ParseASTNode;
 
 /**
- * SQL parser for resource dist SQL.
+ * SQL parser for common dist SQL.
  */
-public final class ResourceDistSQLParser extends ResourceStatementParser 
implements SQLParser {
+public final class CommonDistSQLParser extends CommonDistSQLStatementParser 
implements SQLParser {
     
-    public ResourceDistSQLParser(final TokenStream input) {
+    public CommonDistSQLParser(final TokenStream input) {
         super(input);
     }
     
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceSQLStatementParserEngine.java
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementParserEngine.java
similarity index 80%
rename from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceSQLStatementParserEngine.java
rename to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementParserEngine.java
index 3e72d56..fd93ed2 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceSQLStatementParserEngine.java
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementParserEngine.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.parser.core.resource;
+package org.apache.shardingsphere.distsql.parser.core.common;
 
 import org.antlr.v4.runtime.tree.ErrorNode;
 import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
@@ -25,9 +25,9 @@ import 
org.apache.shardingsphere.sql.parser.exception.SQLParsingException;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 
 /**
- * SQL statement parser engine for resource dist SQL.
+ * SQL statement parser engine for common dist SQL.
  */
-public final class ResourceSQLStatementParserEngine {
+public final class CommonDistSQLStatementParserEngine {
     
     /**
      * Parse SQL.
@@ -36,7 +36,7 @@ public final class ResourceSQLStatementParserEngine {
      * @return SQL statement
      */
     public SQLStatement parse(final String sql) {
-        ASTNode astNode = SQLParserFactory.newInstance(sql, 
ResourceDistSQLLexer.class, ResourceDistSQLParser.class).parse();
+        ASTNode astNode = SQLParserFactory.newInstance(sql, 
CommonDistSQLLexer.class, CommonDistSQLParser.class).parse();
         return getSQLStatement(sql, (ParseASTNode) astNode);
     }
     
@@ -44,6 +44,6 @@ public final class ResourceSQLStatementParserEngine {
         if (parseASTNode.getRootNode() instanceof ErrorNode) {
             throw new SQLParsingException("Unsupported SQL of `%s`", sql);
         }
-        return (SQLStatement) (new 
ResourceDistSQLStatementVisitor()).visit(parseASTNode.getRootNode());
+        return (SQLStatement) (new 
CommonDistSQLStatementVisitor()).visit(parseASTNode.getRootNode());
     }
 }
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLStatementVisitor.java
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
similarity index 72%
rename from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLStatementVisitor.java
rename to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
index a1db4a5..14b1dc5 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLStatementVisitor.java
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/common/CommonDistSQLStatementVisitor.java
@@ -15,18 +15,20 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.parser.core.resource;
+package org.apache.shardingsphere.distsql.parser.core.common;
 
 import org.antlr.v4.runtime.tree.ParseTree;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementBaseVisitor;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.AddResourceContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.DataSourceContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.DropResourceContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.SchemaNameContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.ShowResourcesContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.PoolPropertiesContext;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser.PoolPropertyContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementBaseVisitor;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.AddResourceContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ClearHintContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.DataSourceContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.DropResourceContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PoolPropertiesContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.PoolPropertyContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.SchemaNameContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.CommonDistSQLStatementParser.ShowResourcesContext;
 import org.apache.shardingsphere.distsql.parser.segment.DataSourceSegment;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.create.AddResourceStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rdl.drop.DropResourceStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.rql.show.ShowResourcesStatement;
@@ -39,9 +41,9 @@ import java.util.Properties;
 import java.util.stream.Collectors;
 
 /**
- * SQL statement visitor for resource dist SQL.
+ * SQL statement visitor for common dist SQL.
  */
-public final class ResourceDistSQLStatementVisitor extends 
ResourceStatementBaseVisitor<ASTNode> implements SQLVisitor {
+public final class CommonDistSQLStatementVisitor extends 
CommonDistSQLStatementBaseVisitor<ASTNode> implements SQLVisitor {
     
     @Override
     public ASTNode visitAddResource(final AddResourceContext ctx) {
@@ -89,4 +91,9 @@ public final class ResourceDistSQLStatementVisitor extends 
ResourceStatementBase
     public ASTNode visitSchemaName(final SchemaNameContext ctx) {
         return new SchemaSegment(ctx.getStart().getStartIndex(), 
ctx.getStop().getStopIndex(), new IdentifierValue(ctx.getText()));
     }
+    
+    @Override
+    public ASTNode visitClearHint(final ClearHintContext ctx) {
+        return new ClearHintStatement();
+    }
 }
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/CommonDistSQLStatement.java
similarity index 82%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/CommonDistSQLStatement.java
index 3a9e4c6..70ec0d2 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/CommonDistSQLStatement.java
@@ -15,13 +15,10 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral;
 
-import Symbol, RDLStatement, RQLStatement;
-
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
-    ;
+/**
+ * Common dist sql statement.
+ */
+public abstract class CommonDistSQLStatement extends RALStatement {
+}
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/HintDistSQLStatement.java
similarity index 74%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/HintDistSQLStatement.java
index 3a9e4c6..5f82496 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/HintDistSQLStatement.java
@@ -15,13 +15,12 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common;
 
-import Symbol, RDLStatement, RQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLStatement;
 
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
-    ;
+/**
+ * Hint dist sql statement.
+ */
+public abstract class HintDistSQLStatement extends CommonDistSQLStatement {
+}
diff --git 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingRuleStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/PreviewDistSQLStatement.java
similarity index 75%
copy from 
shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingRuleStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/PreviewDistSQLStatement.java
index d6ce029..8572c79 100644
--- 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingRuleStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/PreviewDistSQLStatement.java
@@ -15,14 +15,12 @@
  * limitations under the License.
  */
 
-grammar ReadwriteSplittingRuleStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common;
 
-import Symbol, RDLStatement, RQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLStatement;
 
-execute
-    : (createReadwriteSplittingRule
-    | alterReadwriteSplittingRule
-    | dropReadwriteSplittingRule
-    | showReadwriteSplittingRules
-    ) SEMI?
-    ;
+/**
+ * Preview dist sql statement.
+ */
+public abstract class PreviewDistSQLStatement extends CommonDistSQLStatement {
+}
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/SetDistSQLStatement.java
similarity index 74%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/SetDistSQLStatement.java
index 3a9e4c6..d2ee968 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/SetDistSQLStatement.java
@@ -15,13 +15,12 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common;
 
-import Symbol, RDLStatement, RQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLStatement;
 
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
-    ;
+/**
+ * Set dist sql statement.
+ */
+public abstract class SetDistSQLStatement extends CommonDistSQLStatement {
+}
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/ShowDistSQLStatement.java
similarity index 74%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/ShowDistSQLStatement.java
index 3a9e4c6..c763044 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/ShowDistSQLStatement.java
@@ -15,13 +15,12 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common;
 
-import Symbol, RDLStatement, RQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLStatement;
 
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
-    ;
+/**
+ * Show dist sql statement.
+ */
+public abstract class ShowDistSQLStatement extends CommonDistSQLStatement {
+}
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/hint/ClearHintStatement.java
similarity index 68%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/hint/ClearHintStatement.java
index 3a9e4c6..99ae6b8 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/hint/ClearHintStatement.java
@@ -15,13 +15,16 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common.hint;
 
-import Symbol, RDLStatement, RQLStatement;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
 
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
-    ;
+/**
+ * Clear hint statement.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class ClearHintStatement extends HintDistSQLStatement {
+}
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/preview/PreviewStatement.java
similarity index 66%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
copy to 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/preview/PreviewStatement.java
index 3a9e4c6..271e545 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-distsql-parser/shardingsphere-distsql-parser-statement/src/main/java/org/apache/shardingsphere/distsql/parser/statement/ral/common/preview/PreviewStatement.java
@@ -15,13 +15,18 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+package org.apache.shardingsphere.distsql.parser.statement.ral.common.preview;
 
-import Symbol, RDLStatement, RQLStatement;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.PreviewDistSQLStatement;
 
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
-    ;
+/**
+ * Preview statement.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class PreviewStatement extends PreviewDistSQLStatement {
+    
+    private final String sql;
+}
diff --git 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/Keyword.g4
 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/Keyword.g4
index 3c3ab60..c540bb8 100644
--- 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/Keyword.g4
+++ 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/Keyword.g4
@@ -35,6 +35,10 @@ DROP
     : D R O P
     ;
 
+SET
+    : S E T
+    ;
+
 SHOW
     : S H O W
     ;
@@ -78,3 +82,19 @@ PROPERTIES
 RULES
     : R U L E S
     ;
+
+SOURCE
+    : S O U R C E
+    ;
+
+STATUS
+    : S T A T U S
+    ;
+
+HINT
+    : H I N T
+    ;
+
+CLEAR
+    : C L E A R
+    ;
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/RALStatement.g4
similarity index 70%
rename from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
rename to 
shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/RALStatement.g4
index 3a9e4c6..a866e63 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ResourceStatement.g4
+++ 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/imports/readwrite-splitting/RALStatement.g4
@@ -15,13 +15,22 @@
  * limitations under the License.
  */
 
-grammar ResourceStatement;
+grammar RALStatement;
 
-import Symbol, RDLStatement, RQLStatement;
+import Keyword, Literals, Symbol;
 
-execute
-    : (addResource
-    | dropResource
-    | showResources
-    ) SEMI?
+setReadwriteSplittingHintSource
+    : SET READWRITE_SPLITTING HINT SOURCE EQ sourceValue
+    ;
+
+showReadwriteSplittingHintStatus
+    : SHOW READWRITE_SPLITTING HINT STATUS
+    ;
+
+clearReadwriteSplittingHint
+    : CLEAR READWRITE_SPLITTING HINT
+    ;
+
+sourceValue
+    : IDENTIFIER
     ;
diff --git 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingRuleStatement.g4
 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/Readwrite
 [...]
index d6ce029..f8f874a 100644
--- 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingRuleStatement.g4
+++ 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ReadwriteSplittingRuleStatement.g4
@@ -17,12 +17,15 @@
 
 grammar ReadwriteSplittingRuleStatement;
 
-import Symbol, RDLStatement, RQLStatement;
+import Symbol, RALStatement, RDLStatement, RQLStatement;
 
 execute
     : (createReadwriteSplittingRule
     | alterReadwriteSplittingRule
     | dropReadwriteSplittingRule
     | showReadwriteSplittingRules
+    | setReadwriteSplittingHintSource
+    | showReadwriteSplittingHintStatus
+    | clearReadwriteSplittingHint
     ) SEMI?
     ;
diff --git 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwrit
 [...]
index 1129c1d..c54a5d1 100644
--- 
a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
+++ 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingRuleSQLStatementVisitor.java
@@ -27,6 +27,7 @@ import 
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleSt
 import 
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.ReadwriteSplittingRuleDefinitionContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.RuleNameContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.SchemaNameContext;
+import 
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.SetReadwriteSplittingHintSourceContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.ShowReadwriteSplittingRulesContext;
 import 
org.apache.shardingsphere.distsql.parser.autogen.ReadwriteSplittingRuleStatementParser.StaticReadwriteSplittingRuleDefinitionContext;
 import org.apache.shardingsphere.distsql.parser.segment.AlgorithmSegment;
@@ -35,6 +36,7 @@ import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.Alt
 import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.CreateReadwriteSplittingRuleStatement;
 import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.DropReadwriteSplittingRuleStatement;
 import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.ShowReadwriteSplittingRulesStatement;
+import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.SetReadwriteSplittingHintSourceStatement;
 import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
 import org.apache.shardingsphere.sql.parser.api.visitor.SQLVisitor;
 import 
org.apache.shardingsphere.sql.parser.sql.common.segment.generic.SchemaSegment;
@@ -95,6 +97,11 @@ public final class ReadwriteSplittingRuleSQLStatementVisitor 
extends ReadwriteSp
         return new AlgorithmSegment(ctx.algorithmName().getText(), 
getAlgorithmProperties(ctx));
     }
     
+    @Override
+    public ASTNode visitSetReadwriteSplittingHintSource(final 
SetReadwriteSplittingHintSourceContext ctx) {
+        return new 
SetReadwriteSplittingHintSourceStatement(ctx.sourceValue().getText());
+    }
+    
     private Properties getAlgorithmProperties(final AlgorithmDefinitionContext 
ctx) {
         Properties result = new Properties();
         if (null == ctx.algorithmProperties()) {
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLLexer.java
 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/hint/SetReadwriteSplittingHintSourceStatement.java
similarity index 63%
rename from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLLexer.java
rename to 
shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/hint/SetReadwriteSplittingHintSourceStatement.java
index 7515f4b..76b7a4f 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLLexer.java
+++ 
b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-statement/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/statement/hint/SetReadwriteSplittingHintSourceStatement.java
@@ -15,18 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.parser.core.resource;
+package 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint;
 
-import org.antlr.v4.runtime.CharStream;
-import org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementLexer;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLLexer;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
 
 /**
- * SQL lexer for resource dist SQL.
+ * Set readwrite-splitting hint source statement.
  */
-public final class ResourceDistSQLLexer extends ResourceStatementLexer 
implements SQLLexer {
+@RequiredArgsConstructor
+@Getter
+public final class SetReadwriteSplittingHintSourceStatement extends 
HintDistSQLStatement {
     
-    public ResourceDistSQLLexer(final CharStream input) {
-        super(input);
-    }
+    private final String source;
 }
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
index b602ae4..a507739 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/Keyword.g4
@@ -102,7 +102,7 @@ RULES
 COLUMNS
     : C O L U M N S
     ;
-    
+
 ALGORITHM
     : A L G O R I T H M
     ;
@@ -110,3 +110,31 @@ ALGORITHM
 ALGORITHMS
     : A L G O R I T H M S
     ;
+
+HINT
+    : H I N T
+    ;
+
+SET
+    : S E T
+    ;
+
+ADD
+    : A D D
+    ;
+
+DATABASE_VALUE
+    : D A T A B A S E UL_ V A L U E
+    ;
+
+TABLE_VALUE
+    : T A B L E UL_ V A L U E
+    ;
+
+STATUS
+    : S T A T U S
+    ;
+
+CLEAR
+    : C L E A R
+    ;
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RALStatement.g4
similarity index 63%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
copy to 
shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RALStatement.g4
index fabe60b..27a3590 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/imports/sharding/RALStatement.g4
@@ -15,66 +15,34 @@
  * limitations under the License.
  */
 
-lexer grammar Keyword;
+grammar RALStatement;
 
-import Alphabet;
+import Keyword, Literals, Symbol;
 
-WS
-    : [ \t\r\n] + ->skip
+setShardingHintDatabaseValue
+    : SET SHARDING HINT DATABASE_VALUE EQ shardingValue
     ;
 
-ADD
-    : A D D
+addShardingHintDatabaseValue
+    : ADD SHARDING HINT DATABASE_VALUE tableName EQ shardingValue
     ;
 
-DROP
-    : D R O P
+addShardingHintTableValue
+    : ADD SHARDING HINT TABLE_VALUE tableName EQ shardingValue
     ;
 
-SHOW
-    : S H O W
+showShardingHintStatus
+    : SHOW SHARDING HINT STATUS
     ;
 
-RESOURCE
-    : R E S O U R C E
+clearShardingHint
+    : CLEAR SHARDING HINT
     ;
 
-RESOURCES
-    : R E S O U R C E S
+tableName
+    : IDENTIFIER
     ;
 
-FROM
-    : F R O M
-    ;
-
-URL
-    : U R L
-    ;
-
-HOST
-    : H O S T
-    ;
-
-PORT
-    : P O R T
-    ;
-
-DB
-    : D B
-    ;
-
-USER
-    : U S E R
-    ;
-
-PASSWORD
-    : P A S S W O R D
-    ;
-
-NAME
-    : N A M E
-    ;
-
-PROPERTIES
-    : P R O P E R T I E S
+shardingValue
+    : IDENTIFIER
     ;
diff --git 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ShardingRuleStatement.g4
 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ShardingRuleStatement.g4
index c8b7f73..7ed7c4c 100644
--- 
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ShardingRuleStatement.g4
+++ 
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/ShardingRuleStatement.g4
@@ -17,7 +17,7 @@
 
 grammar ShardingRuleStatement;
 
-import Symbol, RDLStatement, RQLStatement;
+import Symbol, RALStatement, RDLStatement, RQLStatement;
 
 execute
     : (createShardingTableRule
@@ -34,5 +34,10 @@ execute
     | showShardingBindingTableRules
     | showShardingBroadcastTableRules
     | showShardingAlgorithms
+    | setShardingHintDatabaseValue
+    | addShardingHintDatabaseValue
+    | addShardingHintTableValue
+    | showShardingHintStatus
+    | clearShardingHint
     ) SEMI?
     ;
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
index 9febb38..6dc37bd 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/hint/HintManager.java
@@ -146,6 +146,13 @@ public final class HintManager implements AutoCloseable {
     }
     
     /**
+     * Set database routing to be automatic.
+     */
+    public void setReadwriteSplittingAuto() {
+        writeRouteOnly = false;
+    }
+    
+    /**
      * Judge whether route to write database only or not.
      *
      * @return route to write database only or not
diff --git 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/HintManagerTest.java
 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/HintManagerTest.java
index 81ffac3..76126e2 100644
--- 
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/HintManagerTest.java
+++ 
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/hint/HintManagerTest.java
@@ -170,6 +170,14 @@ public final class HintManagerTest {
     }
     
     @Test
+    public void assertSetReadwriteSplittingAuto() {
+        try (HintManager hintManager = HintManager.getInstance()) {
+            hintManager.setReadwriteSplittingAuto();
+            assertFalse(HintManager.isWriteRouteOnly());
+        }
+    }
+    
+    @Test
     public void assertClose() {
         HintManager hintManager = HintManager.getInstance();
         hintManager.addDatabaseShardingValue("logic_table", 1);
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
index d4d247b..3e33646 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/RALBackendHandlerFactory.java
@@ -21,12 +21,16 @@ import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.QueryableRALStatement;
 import org.apache.shardingsphere.distsql.parser.statement.ral.RALStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLStatement;
 import 
org.apache.shardingsphere.distsql.parser.statement.ral.UpdatableRALStatement;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
 import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
 import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.query.QueryableRALBackendHandlerFactory;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.CommonDistSQLBackendHandlerFactory;
 import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.update.UpdatableRALBackendHandlerFactory;
 
+import java.sql.SQLException;
+
 /**
  * RAL backend handler factory.
  */
@@ -39,14 +43,18 @@ public final class RALBackendHandlerFactory {
      * @param sqlStatement RAL statement
      * @param backendConnection backend connection
      * @return RAL backend handler
+     * @throws SQLException SQL exception
      */
-    public static TextProtocolBackendHandler newInstance(final RALStatement 
sqlStatement, final BackendConnection backendConnection) {
+    public static TextProtocolBackendHandler newInstance(final RALStatement 
sqlStatement, final BackendConnection backendConnection) throws SQLException {
         if (sqlStatement instanceof QueryableRALStatement) {
             return 
QueryableRALBackendHandlerFactory.newInstance((QueryableRALStatement) 
sqlStatement, backendConnection);
         }
         if (sqlStatement instanceof UpdatableRALStatement) {
             return 
UpdatableRALBackendHandlerFactory.newInstance((UpdatableRALStatement) 
sqlStatement);
         }
+        if (sqlStatement instanceof CommonDistSQLStatement) {
+            return 
CommonDistSQLBackendHandlerFactory.newInstance((CommonDistSQLStatement) 
sqlStatement, backendConnection);
+        }
         throw new 
UnsupportedOperationException(sqlStatement.getClass().getCanonicalName());
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
new file mode 100644
index 0000000..fd65a91
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/CommonDistSQLBackendHandlerFactory.java
@@ -0,0 +1,62 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common;
+
+import com.mchange.v1.db.sql.UnsupportedTypeException;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.CommonDistSQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.PreviewDistSQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.SetDistSQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.ShowDistSQLStatement;
+import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+
+import java.sql.SQLException;
+
+/**
+ * Common dist sql backend handler factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class CommonDistSQLBackendHandlerFactory {
+    
+    /**
+     * Create new instance of common dist sql backend handler.
+     * 
+     * @param sqlStatement common dist sql statement
+     * @param backendConnection backend connection
+     * @return common dist sql backend handler
+     * @throws SQLException SQL exception
+     */
+    public static TextProtocolBackendHandler newInstance(final 
CommonDistSQLStatement sqlStatement, final BackendConnection backendConnection) 
throws SQLException {
+        if (sqlStatement instanceof SetDistSQLStatement) {
+            return new SetDistSQLBackendHandler((SetDistSQLStatement) 
sqlStatement, backendConnection);
+        }
+        if (sqlStatement instanceof ShowDistSQLStatement) {
+            return new ShowDistSQLBackendHandler((ShowDistSQLStatement) 
sqlStatement, backendConnection);
+        }
+        if (sqlStatement instanceof PreviewDistSQLStatement) {
+            return new PrviewDistSQLBackendHandler((PreviewDistSQLStatement) 
sqlStatement, backendConnection);
+        }
+        if (sqlStatement instanceof HintDistSQLStatement) {
+            return new HintDistSQLBackendHandler((HintDistSQLStatement) 
sqlStatement, backendConnection);
+        }
+        throw new 
UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/HintDistSQLBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/HintDistSQLBackendHandler.java
new file mode 100644
index 0000000..d077334
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/HintDistSQLBackendHandler.java
@@ -0,0 +1,66 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
+import 
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey;
+import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintStatementExecutor;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintStatementExecutorFactory;
+
+import java.sql.SQLException;
+import java.util.Collection;
+
+/**
+ * Hint dist sql backend handler.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class HintDistSQLBackendHandler implements 
TextProtocolBackendHandler {
+    
+    private final HintDistSQLStatement sqlStatement;
+    
+    private final BackendConnection backendConnection;
+    
+    private HintStatementExecutor hintStatementExecutor;
+    
+    @SuppressWarnings("unchecked")
+    @Override
+    public ResponseHeader execute() throws SQLException {
+        if 
(!ProxyContext.getInstance().getMetaDataContexts().getProps().<Boolean>getValue(ConfigurationPropertyKey.PROXY_HINT_ENABLED))
 {
+            throw new UnsupportedOperationException(String.format("%s should 
be true, please check your config", 
ConfigurationPropertyKey.PROXY_HINT_ENABLED.getKey()));
+        }
+        hintStatementExecutor = 
HintStatementExecutorFactory.newInstance(sqlStatement, backendConnection);
+        return hintStatementExecutor.execute();
+    }
+    
+    @Override
+    public boolean next() throws SQLException {
+        return hintStatementExecutor.next();
+    }
+    
+    @Override
+    public Collection<Object> getRowData() throws SQLException {
+        return hintStatementExecutor.getQueryResponseRow().getData();
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/PrviewDistSQLBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/PrviewDistSQLBackendHandler.java
new file mode 100644
index 0000000..589516b
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/PrviewDistSQLBackendHandler.java
@@ -0,0 +1,44 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.PreviewDistSQLStatement;
+import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+
+/**
+ * Preview dist sql backend handler.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class PrviewDistSQLBackendHandler implements 
TextProtocolBackendHandler {
+    
+    private final PreviewDistSQLStatement sqlStatement;
+    
+    private final BackendConnection backendConnection;
+    
+    @Override
+    public ResponseHeader execute() {
+        // TODO add execute logic
+        return new UpdateResponseHeader(null);
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/SetDistSQLBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/SetDistSQLBackendHandler.java
new file mode 100644
index 0000000..8622439
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/SetDistSQLBackendHandler.java
@@ -0,0 +1,44 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.SetDistSQLStatement;
+import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+
+/**
+ * Set dist sql backend handler.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class SetDistSQLBackendHandler implements 
TextProtocolBackendHandler {
+    
+    private final SetDistSQLStatement sqlStatement;
+    
+    private final BackendConnection backendConnection;
+    
+    @Override
+    public ResponseHeader execute() {
+        // TODO add execute logic
+        return new UpdateResponseHeader(null);
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/ShowDistSQLBackendHandler.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/ShowDistSQLBackendHandler.java
new file mode 100644
index 0000000..0ff77b8
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/ShowDistSQLBackendHandler.java
@@ -0,0 +1,44 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.ShowDistSQLStatement;
+import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import org.apache.shardingsphere.proxy.backend.text.TextProtocolBackendHandler;
+
+/**
+ * Show dist sql backend handler.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class ShowDistSQLBackendHandler implements 
TextProtocolBackendHandler {
+    
+    private final ShowDistSQLStatement sqlStatement;
+    
+    private final BackendConnection backendConnection;
+    
+    @Override
+    public ResponseHeader execute() {
+        // TODO add execute logic
+        return new UpdateResponseHeader(null);
+    }
+}
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintSourceType.java
similarity index 53%
copy from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
copy to 
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintSourceType.java
index b465555..6cacbe0 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintSourceType.java
@@ -15,25 +15,36 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.parser.core.resource;
+package org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint;
 
-import org.antlr.v4.runtime.TokenStream;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
-import org.apache.shardingsphere.sql.parser.core.ParseASTNode;
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
 
 /**
- * SQL parser for resource dist SQL.
+ * Hint source type.
  */
-public final class ResourceDistSQLParser extends ResourceStatementParser 
implements SQLParser {
+@RequiredArgsConstructor
+@Getter
+public enum HintSourceType {
     
-    public ResourceDistSQLParser(final TokenStream input) {
-        super(input);
-    }
+    AUTO("auto"),
+    
+    WRITE("write");
+    
+    private final String value;
     
-    @Override
-    public ASTNode parse() {
-        return new ParseASTNode(execute());
+    /**
+     * Convert string to HintSourceType.
+     *
+     * @param value value
+     * @return hint source type
+     */
+    public static HintSourceType typeOf(final String value) {
+        for (HintSourceType each : values()) {
+            if (each.value.equalsIgnoreCase(value)) {
+                return each;
+            }
+        }
+        throw new UnsupportedOperationException("unsupported hint source type: 
" + value);
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutor.java
new file mode 100644
index 0000000..d2009ad
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutor.java
@@ -0,0 +1,53 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.hint;
+
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+
+import java.sql.SQLException;
+
+/**
+ * Hint statement executor.
+ */
+public interface HintStatementExecutor<T extends HintDistSQLStatement> {
+    
+    /**
+     * Execute hint statement.
+     *
+     * @return backend response
+     */
+    ResponseHeader execute();
+    
+    /**
+     * Goto next result value.
+     *
+     * @return has more result value or not
+     * @throws SQLException SQL exception
+     */
+    boolean next() throws SQLException;
+    
+    /**
+     * Get query response row.
+     *
+     * @return query response row
+     * @throws SQLException SQL exception
+     */
+    QueryResponseRow getQueryResponseRow() throws SQLException;
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactory.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactory.java
new file mode 100644
index 0000000..9d920d4
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/HintStatementExecutorFactory.java
@@ -0,0 +1,55 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.hint;
+
+import com.mchange.v1.db.sql.UnsupportedTypeException;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
+import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.connection.BackendConnection;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.ClearHintExecutor;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor.SetReadwriteSplittingHintSourceExecutor;
+import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.SetReadwriteSplittingHintSourceStatement;
+
+import java.sql.SQLException;
+
+/**
+ * Hint statement executor factory.
+ */
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class HintStatementExecutorFactory {
+    
+    /**
+     * Create hint statement executor instance.
+     *
+     * @param sqlStatement hint statement
+     * @param backendConnection backend connection
+     * @return hint command executor
+     * @throws SQLException SQL exception
+     */
+    public static HintStatementExecutor newInstance(final HintDistSQLStatement 
sqlStatement, final BackendConnection backendConnection) throws SQLException {
+        if (sqlStatement instanceof SetReadwriteSplittingHintSourceStatement) {
+            return new 
SetReadwriteSplittingHintSourceExecutor((SetReadwriteSplittingHintSourceStatement)
 sqlStatement);
+        }
+        if (sqlStatement instanceof ClearHintStatement) {
+            return new ClearHintExecutor((ClearHintStatement) sqlStatement);
+        }
+        throw new 
UnsupportedTypeException(sqlStatement.getClass().getCanonicalName());
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AbstractHintQueryExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AbstractHintQueryExecutor.java
new file mode 100644
index 0000000..0677c80
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AbstractHintQueryExecutor.java
@@ -0,0 +1,67 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.hint.executor;
+
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
+import org.apache.shardingsphere.infra.merge.result.MergedResult;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseCell;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
+import 
org.apache.shardingsphere.proxy.backend.response.data.impl.TextQueryResponseCell;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.query.QueryResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.query.impl.QueryHeader;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintStatementExecutor;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Abstract hint query executor.
+ */
+public abstract class AbstractHintQueryExecutor<T extends 
HintDistSQLStatement> implements HintStatementExecutor<T> {
+    
+    private List<QueryHeader> queryHeaders;
+    
+    private MergedResult mergedResult;
+    
+    @Override
+    public final ResponseHeader execute() {
+        queryHeaders = createQueryHeaders();
+        mergedResult = createMergedResult();
+        return new QueryResponseHeader(queryHeaders);
+    }
+    
+    protected abstract List<QueryHeader> createQueryHeaders();
+    
+    protected abstract MergedResult createMergedResult();
+    
+    @Override
+    public final boolean next() throws SQLException {
+        return null != mergedResult && mergedResult.next();
+    }
+    
+    @Override
+    public final QueryResponseRow getQueryResponseRow() throws SQLException {
+        List<QueryResponseCell> cells = new ArrayList<>(queryHeaders.size());
+        for (int i = 0; i < queryHeaders.size(); i++) {
+            cells.add(new TextQueryResponseCell(mergedResult.getValue(i + 1, 
Object.class)));
+        }
+        return new QueryResponseRow(cells);
+    }
+}
diff --git 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AbstractHintUpdateExecutor.java
similarity index 56%
rename from 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
rename to 
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AbstractHintUpdateExecutor.java
index b465555..d1fc84a 100644
--- 
a/shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/core/resource/ResourceDistSQLParser.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/AbstractHintUpdateExecutor.java
@@ -15,25 +15,24 @@
  * limitations under the License.
  */
 
-package org.apache.shardingsphere.distsql.parser.core.resource;
+package 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.executor;
 
-import org.antlr.v4.runtime.TokenStream;
-import 
org.apache.shardingsphere.distsql.parser.autogen.ResourceStatementParser;
-import org.apache.shardingsphere.sql.parser.api.parser.SQLParser;
-import org.apache.shardingsphere.sql.parser.api.visitor.ASTNode;
-import org.apache.shardingsphere.sql.parser.core.ParseASTNode;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.HintDistSQLStatement;
+import org.apache.shardingsphere.proxy.backend.response.data.QueryResponseRow;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintStatementExecutor;
 
 /**
- * SQL parser for resource dist SQL.
+ * Abstract hint update executor.
  */
-public final class ResourceDistSQLParser extends ResourceStatementParser 
implements SQLParser {
+public abstract class AbstractHintUpdateExecutor<T extends 
HintDistSQLStatement> implements HintStatementExecutor<T> {
     
-    public ResourceDistSQLParser(final TokenStream input) {
-        super(input);
+    @Override
+    public final boolean next() {
+        return false;
     }
     
     @Override
-    public ASTNode parse() {
-        return new ParseASTNode(execute());
+    public final QueryResponseRow getQueryResponseRow() {
+        return null;
     }
 }
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearHintExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearHintExecutor.java
new file mode 100644
index 0000000..7d16843
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/ClearHintExecutor.java
@@ -0,0 +1,40 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.hint.executor;
+
+import lombok.RequiredArgsConstructor;
+import 
org.apache.shardingsphere.distsql.parser.statement.ral.common.hint.ClearHintStatement;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+
+/**
+ * Clear hint statement executor.
+ */
+@RequiredArgsConstructor
+public final class ClearHintExecutor extends 
AbstractHintUpdateExecutor<ClearHintStatement> {
+    
+    private final ClearHintStatement sqlStatement;
+    
+    @Override
+    public ResponseHeader execute() {
+        HintManagerHolder.get().close();
+        HintManagerHolder.remove();
+        return new UpdateResponseHeader(null);
+    }
+}
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetReadwriteSplittingHintSourceExecutor.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetReadwriteSplittingHintSourceExecutor.java
new file mode 100644
index 0000000..4572fec
--- /dev/null
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/hint/executor/SetReadwriteSplittingHintSourceExecutor.java
@@ -0,0 +1,50 @@
+/*
+ * 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.proxy.backend.text.distsql.ral.common.hint.executor;
+
+import lombok.RequiredArgsConstructor;
+import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.response.header.update.UpdateResponseHeader;
+import 
org.apache.shardingsphere.proxy.backend.text.distsql.ral.common.hint.HintSourceType;
+import 
org.apache.shardingsphere.proxy.backend.text.sctl.hint.internal.HintManagerHolder;
+import 
org.apache.shardingsphere.readwritesplitting.distsql.parser.statement.hint.SetReadwriteSplittingHintSourceStatement;
+
+/**
+ * Set readwrite-splitting hint source statement executor.
+ */
+@RequiredArgsConstructor
+public final class SetReadwriteSplittingHintSourceExecutor extends 
AbstractHintUpdateExecutor<SetReadwriteSplittingHintSourceStatement> {
+    
+    private final SetReadwriteSplittingHintSourceStatement sqlStatement;
+    
+    @Override
+    public ResponseHeader execute() {
+        HintSourceType sourceType = 
HintSourceType.typeOf(sqlStatement.getSource());
+        switch (sourceType) {
+            case AUTO:
+                HintManagerHolder.get().setReadwriteSplittingAuto();
+                break;
+            case WRITE:
+                HintManagerHolder.get().setWriteRouteOnly();
+                break;
+            default:
+                break;
+        }
+        return new UpdateResponseHeader(null);
+    }
+}

Reply via email to