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

duanzhengqiang 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 0ca5aeb5502 support reserved word parse in parser engine. (#32422)
0ca5aeb5502 is described below

commit 0ca5aeb55025102b6d36ddd0cc27f77aa5a57f23
Author: Skitii <[email protected]>
AuthorDate: Fri Aug 9 08:03:22 2024 +0800

    support reserved word parse in parser engine. (#32422)
---
 .../mysql/src/main/antlr4/imports/mysql/BaseRule.g4  |  4 +++-
 .../it/parser/src/main/resources/case/dml/select.xml | 20 ++++++++++++++++++++
 .../src/main/resources/sql/supported/dml/select.xml  |  2 ++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4 
b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
index b03e2d8b9c8..cc7682cb197 100644
--- a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
+++ b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4
@@ -126,7 +126,7 @@ identifier
     | UNDERSCORE_CHARSET
     | BQUOTA_STRING
     ;
-    
+
 identifierKeywordsUnambiguous
     : ACTION
     | ACCOUNT
@@ -522,6 +522,8 @@ identifierKeywordsUnambiguous
     | XML
     | YEAR
     | YEAR_MONTH
+    | CONDITION
+    | DESCRIBE
     ;
     
 identifierKeywordsAmbiguous1RolesAndLabels
diff --git a/test/it/parser/src/main/resources/case/dml/select.xml 
b/test/it/parser/src/main/resources/case/dml/select.xml
index ea7418f5938..8460f748e2a 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -9478,4 +9478,24 @@
             </simple-table>
         </from>
     </select>
+
+    <select sql-case-id="select_with_reserved_word_with_table_ref">
+        <projections start-index="7" stop-index="19">
+            <column-projection name="condition" start-index="7" 
stop-index="19" >
+                <owner name="xxx" start-index="7" stop-index="9" />
+            </column-projection>
+        </projections>
+        <from start-index="26" stop-index="28">
+            <simple-table name="xxx" start-index="26" stop-index="28"/>
+        </from>
+    </select>
+
+    <select sql-case-id="select_with_reserved_word">
+        <projections start-index="7" stop-index="14">
+            <column-projection name="describe" start-index="7" stop-index="14" 
/>
+        </projections>
+        <from start-index="21" stop-index="23">
+            <simple-table name="xxx" start-index="21" stop-index="23"/>
+        </from>
+    </select>
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index 0dd5214dcc6..cf24d786d9c 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -280,4 +280,6 @@
     <sql-case id="select_with_index_hints1" value="SELECT * FROM t1 USE INDEX 
(i1) IGNORE INDEX (i2) USE INDEX (i2);" db-types="MySQL,Doris"/>
     <sql-case id="select_with_index_hints2" value="SELECT * FROM t1 USE INDEX 
() IGNORE INDEX (i2) USE INDEX (i1) USE INDEX (i2);" db-types="MySQL,Doris"/>
     <sql-case id="select_with_index_hints3" value="SELECT * FROM t1 USE INDEX 
(i1,i2) IGNORE INDEX (i2);" db-types="MySQL,Doris"/>
+    <sql-case id="select_with_reserved_word_with_table_ref" value="select 
xxx.condition from xxx" db-types="MySQL"/>
+    <sql-case id="select_with_reserved_word" value="select describe from xxx" 
db-types="MySQL"/>
 </sql-cases>

Reply via email to