tristaZero commented on a change in pull request #11742:
URL: https://github.com/apache/shardingsphere/pull/11742#discussion_r686398432



##########
File path: 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
##########
@@ -78,3 +90,36 @@ 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
+    ;
+
+SOURCE
+    : S O U R C E
+    ;
+    
+STATUS
+    : S T A T U S
+    ;
+
+SHARDING
+    : S H A R D I N G
+    ;
+
+READWRITE_SPLITTING
+    : R E A D W R I T E UL_ S P L I T T I N G
+    ;
+    
+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
+    ;
+    

Review comment:
       The last line is expected to be a new line instead of a line with indent.

##########
File path: 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngine.java
##########
@@ -38,7 +39,11 @@ public SQLStatement parse(final String sql) {
         try {
             return new ResourceSQLStatementParserEngine().parse(sql);
         } catch (final ParseCancellationException | SQLParsingException 
ignored) {
-            return new RuleSQLStatementParserEngine().parse(sql);
+            try {
+                return new RuleSQLStatementParserEngine().parse(sql);
+            } catch (final SQLParsingException ignoredToo) {
+                return new SCTLStatementParserEngine().parse(sql);

Review comment:
       Same with the above question.

##########
File path: 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/org/apache/shardingsphere/distsql/parser/autogen/SCTLStatement.g4
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+grammar SCTLStatement;

Review comment:
       I suggest we merge `SCTLStatement ` and `ResourceStatement`, and then 
rename this new class.

##########
File path: 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/RALStatement.g4
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+grammar RALStatement;
+
+import Keyword, Literals, Symbol;
+
+setVariable
+    : SET VARIABLE name EQ value
+    ;
+
+showVariable
+    : SHOW VARIABLE name
+    ;
+
+previewSQL
+    : PREVIEW sql
+    ;
+
+setReadwriteSplittingHintSource
+    : SET READWRITE_SPLITTING HINT SOURCE EQ value
+    ;
+    
+setShardingHintDatabaseValue
+    : SET SHARDING HINT DATABASE_VALUE EQ value
+    ;
+
+addShardingHintDatabaseValue
+    : ADD SHARDING HINT DATABASE_VALUE name EQ value
+    ;
+
+addShardingHintTableValue
+    : ADD SHARDING HINT TABLE_VALUE name EQ value
+    ;
+
+showHintStatus
+    : SHOW feature HINT STATUS
+    ;
+
+clearHint
+    : CLEAR feature? HINT
+    ;
+
+name
+    : IDENTIFIER
+    ;
+    
+value
+    : IDENTIFIER
+    ;
+
+sql
+    : STRING
+    ;
+    
+feature
+    : SHARDING | READWRITE_SPLITTING
+    ;
+    

Review comment:
       A new-line issue

##########
File path: 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/antlr4/imports/Keyword.g4
##########
@@ -78,3 +90,36 @@ 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
+    ;
+
+SOURCE
+    : S O U R C E
+    ;
+    
+STATUS
+    : S T A T U S
+    ;
+
+SHARDING

Review comment:
       Do you think `sharding` and `read-write-splitting` are supposed to move 
to their own feature distsql packages?

##########
File path: 
shardingsphere-distsql-parser/shardingsphere-distsql-parser-engine/src/main/java/org/apache/shardingsphere/distsql/parser/api/DistSQLStatementParserEngine.java
##########
@@ -38,7 +39,11 @@ public SQLStatement parse(final String sql) {
         try {
             return new ResourceSQLStatementParserEngine().parse(sql);
         } catch (final ParseCancellationException | SQLParsingException 
ignored) {
-            return new RuleSQLStatementParserEngine().parse(sql);
+            try {

Review comment:
       Why do we need `catch` to parse `RuleSQLStatementParserEngine`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to