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 cdbf155aa2e Add explain insert convert (#28667)
cdbf155aa2e is described below

commit cdbf155aa2efdab0208f6b4610bb7fa09200d3dc
Author: niu niu <[email protected]>
AuthorDate: Sun Oct 8 11:36:25 2023 +0800

    Add explain insert convert (#28667)
---
 .../converter/statement/explain/ExplainStatementConverter.java       | 5 ++++-
 test/it/optimizer/src/test/resources/converter/explain.xml           | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/converter/statement/explain/ExplainStatementConverter.java
 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/converter/statement/explain/ExplainStatementConverter.java
index 6bdd4e2d1b7..d97953c46ae 100644
--- 
a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/converter/statement/explain/ExplainStatementConverter.java
+++ 
b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/converter/statement/explain/ExplainStatementConverter.java
@@ -25,10 +25,12 @@ import org.apache.calcite.sql.parser.SqlParserPos;
 import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dal.ExplainStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.DeleteStatement;
+import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.InsertStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.SelectStatement;
 import 
org.apache.shardingsphere.sql.parser.sql.common.statement.dml.UpdateStatement;
 import 
org.apache.shardingsphere.sqlfederation.compiler.converter.statement.SQLStatementConverter;
 import 
org.apache.shardingsphere.sqlfederation.compiler.converter.statement.delete.DeleteStatementConverter;
+import 
org.apache.shardingsphere.sqlfederation.compiler.converter.statement.insert.InsertStatementConverter;
 import 
org.apache.shardingsphere.sqlfederation.compiler.converter.statement.select.SelectStatementConverter;
 import 
org.apache.shardingsphere.sqlfederation.compiler.converter.statement.update.UpdateStatementConverter;
 
@@ -54,8 +56,9 @@ public final class ExplainStatementConverter implements 
SQLStatementConverter<Ex
             return new DeleteStatementConverter().convert((DeleteStatement) 
sqlStatement);
         } else if (sqlStatement instanceof UpdateStatement) {
             return new UpdateStatementConverter().convert((UpdateStatement) 
sqlStatement);
+        } else if (sqlStatement instanceof InsertStatement) {
+            return new InsertStatementConverter().convert((InsertStatement) 
sqlStatement);
         }
-        // TODO other statement converter.
         return null;
     }
 }
diff --git a/test/it/optimizer/src/test/resources/converter/explain.xml 
b/test/it/optimizer/src/test/resources/converter/explain.xml
index 043298d0311..f41588cac65 100644
--- a/test/it/optimizer/src/test/resources/converter/explain.xml
+++ b/test/it/optimizer/src/test/resources/converter/explain.xml
@@ -59,4 +59,7 @@
     <test-cases sql-case-id="explain_for_update" expected-sql="EXPLAIN PLAN 
INCLUDING ALL ATTRIBUTES WITH TYPE FOR UPDATE &quot;t_order&quot; SET 
&quot;id&quot; = 1" db-types="Oracle" />
     <test-cases sql-case-id="explain_for_update_with_statement" 
expected-sql="EXPLAIN PLAN INCLUDING ALL ATTRIBUTES WITH TYPE FOR UPDATE 
&quot;t_order&quot; SET &quot;id&quot; = 1" db-types="Oracle" />
     <test-cases sql-case-id="explain_for_update_with_into" 
expected-sql="EXPLAIN PLAN INCLUDING ALL ATTRIBUTES WITH TYPE FOR UPDATE 
&quot;t_order&quot; SET &quot;id&quot; = 1" db-types="Oracle" />
+    <test-cases sql-case-id="explain_insert_without_parameters" 
expected-sql="EXPLAIN PLAN INCLUDING ALL ATTRIBUTES WITH TYPE FOR INSERT INTO 
`t_order` (`order_id`, `user_id`, `status`) VALUES (1, 1, 'insert')" 
db-types="MySQL" />
+    <test-cases sql-case-id="explain_insert_without_parameters" 
expected-sql="EXPLAIN PLAN INCLUDING ALL ATTRIBUTES WITH TYPE FOR INSERT INTO 
&quot;t_order&quot; (&quot;order_id&quot;, &quot;user_id&quot;, 
&quot;status&quot;) VALUES (1, 1, 'insert')" 
db-types="PostgreSQL,openGauss,Oracle" />
+    <test-cases sql-case-id="explain_for_with_analyze_insert" 
expected-sql="EXPLAIN PLAN INCLUDING ALL ATTRIBUTES WITH TYPE FOR INSERT INTO 
&quot;t_order&quot; (&quot;order_id&quot;) VALUES (1)" db-types="Oracle" />
 </sql-node-converter-test-cases>

Reply via email to