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

chengzhang 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 3d96e9ffb60 Compatible with early MySQL explain SQL keywords (#29413)
3d96e9ffb60 is described below

commit 3d96e9ffb601856a1633e22dcd174a81d1c3aed8
Author: niu niu <[email protected]>
AuthorDate: Tue Dec 19 10:25:57 2023 +0800

    Compatible with early MySQL explain SQL keywords (#29413)
    
    * Compatible with early MySQL explain SQL keywords
    
    * Chang test case
    
    * Change test case
---
 .../src/main/antlr4/imports/mysql/DALStatement.g4  |  2 +-
 .../parser/src/main/resources/case/dal/explain.xml | 56 ++++++++++++++++++++++
 .../main/resources/sql/supported/dal/explain.xml   |  2 +
 3 files changed, 59 insertions(+), 1 deletion(-)

diff --git 
a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DALStatement.g4 
b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DALStatement.g4
index b1152e4d516..80eb2954d63 100644
--- a/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DALStatement.g4
+++ b/parser/sql/dialect/mysql/src/main/antlr4/imports/mysql/DALStatement.g4
@@ -416,7 +416,7 @@ shutdown
     ;
 
 explainType
-    : FORMAT EQ_ formatName
+    : (FORMAT EQ_ formatName | EXTENDED | PARTITIONS)
     ;
     
 explainableStatement
diff --git a/test/it/parser/src/main/resources/case/dal/explain.xml 
b/test/it/parser/src/main/resources/case/dal/explain.xml
index 9bf5476a77f..83fc7fb0060 100644
--- a/test/it/parser/src/main/resources/case/dal/explain.xml
+++ b/test/it/parser/src/main/resources/case/dal/explain.xml
@@ -17,6 +17,62 @@
   -->
 
 <sql-parser-test-cases>
+    <describe sql-case-id="explain_extended_select">
+        <select>
+            <projections start-index="24" stop-index="49">
+                <expression-projection text="10 % 7" start-index="24" 
stop-index="29">
+                    <expr>
+                        <binary-operation-expression start-index="24" 
stop-index="29">
+                            <left>
+                                <literal-expression value="10" 
start-index="24" stop-index="25" />
+                            </left>
+                            <right>
+                                <literal-expression value="7" start-index="29" 
stop-index="29" />
+                            </right>
+                            <operator>%</operator>
+                        </binary-operation-expression>
+                    </expr>    
+                </expression-projection>
+                <expression-projection text="10 mod 7" start-index="32" 
stop-index="39">
+                    <expr>
+                        <binary-operation-expression start-index="32" 
stop-index="39">
+                            <left>
+                                <literal-expression value="10" 
start-index="32" stop-index="33" />
+                            </left>
+                            <right>
+                                <literal-expression value="7" start-index="39" 
stop-index="39" />
+                            </right>
+                            <operator>mod</operator>
+                        </binary-operation-expression>
+                    </expr>
+                </expression-projection>
+                <expression-projection text="10 div 3" start-index="42" 
stop-index="49">
+                    <expr>
+                        <binary-operation-expression start-index="42" 
stop-index="49">
+                            <left>
+                                <literal-expression value="10" 
start-index="42" stop-index="43" />
+                            </left>
+                            <right>
+                                <literal-expression value="3" start-index="49" 
stop-index="49" />
+                            </right>
+                            <operator>div</operator>
+                        </binary-operation-expression>
+                    </expr>
+                </expression-projection>
+            </projections>
+        </select>
+    </describe>
+    
+    <describe sql-case-id="explain_partitions_select">
+        <select>
+            <projections start-index="26" stop-index="26">
+                <expression-projection text="1" start-index="26" 
stop-index="26">
+                    <literal-expression value="1" start-index="26" 
stop-index="26" />
+                </expression-projection>
+            </projections>
+        </select>
+    </describe>
+    
     <describe sql-case-id="explain_select_constant_without_table">
         <select>
             <projections start-index="15" stop-index="20">
diff --git a/test/it/parser/src/main/resources/sql/supported/dal/explain.xml 
b/test/it/parser/src/main/resources/sql/supported/dal/explain.xml
index b8e488e013a..7afaf18e4ff 100644
--- a/test/it/parser/src/main/resources/sql/supported/dal/explain.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dal/explain.xml
@@ -17,6 +17,8 @@
   -->
 
 <sql-cases>
+    <sql-case id="explain_extended_select" value="explain extended select 10 % 
7, 10 mod 7, 10 div 3" db-types="MySQL" />
+    <sql-case id="explain_partitions_select" value="explain partitions select 
1" db-types="MySQL" />
     <sql-case id="explain_select_constant_without_table" value="EXPLAIN SELECT 
1 as a" db-types="PostgreSQL, openGauss, MySQL, SQLServer" />
     <sql-case id="explain_update_without_condition" value="EXPLAIN UPDATE 
t_order SET status = 'finished'" db-types="PostgreSQL, openGauss, MySQL, 
SQLServer" />
     <sql-case id="explain_insert_without_parameters" value="EXPLAIN INSERT 
INTO t_order (order_id, user_id, status) VALUES (1, 1, 'insert')" 
db-types="PostgreSQL, openGauss, MySQL, SQLServer" />

Reply via email to