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 bd748db38a7 Add test for explain plan (#27551)
bd748db38a7 is described below
commit bd748db38a7dd17f06dd5495ca8b8ff558e5a1d3
Author: boyjoy1127 <[email protected]>
AuthorDate: Sat Jul 29 21:07:13 2023 +0800
Add test for explain plan (#27551)
---
.../parser/src/main/resources/case/dal/explain.xml | 75 +++++++++++++++++++++-
.../main/resources/sql/supported/dal/explain.xml | 4 ++
2 files changed, 77 insertions(+), 2 deletions(-)
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 555dce10175..2d94975f1a7 100644
--- a/test/it/parser/src/main/resources/case/dal/explain.xml
+++ b/test/it/parser/src/main/resources/case/dal/explain.xml
@@ -449,7 +449,29 @@
</where>
</select>
</describe>
-
+ <describe sql-case-id="explain_for_select_with_statement">
+ <select>
+ <projections start-index="53" stop-index="53">
+ <shorthand-projection start-index="53" stop-index="53" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="60" stop-index="66"
/>
+ </from>
+ <where start-index="68" stop-index="85">
+ <expr>
+ <binary-operation-expression start-index="74"
stop-index="85">
+ <left>
+ <column name="order_id" start-index="74"
stop-index="81" />
+ </left>
+ <operator>></operator>
+ <right>
+ <literal-expression value="8" start-index="85"
stop-index="85" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+ </describe>
<describe sql-case-id="explain_for_update_without_condition">
<update>
<table start-index="24" stop-index="30">
@@ -481,6 +503,21 @@
</set>
</update>
</describe>
+ <describe sql-case-id="explain_for_update_with_statement">
+ <update>
+ <table start-index="37" stop-index="43">
+ <simple-table name="t_order" start-index="53" stop-index="59"
/>
+ </table>
+ <set start-index="61" stop-index="70" literal-stop-index="70">
+ <assignment start-index="65" stop-index="70"
literal-stop-index="70">
+ <column name="id" start-index="65" stop-index="66" />
+ <assignment-value>
+ <literal-expression value="1" start-index="70"
stop-index="70" />
+ </assignment-value>
+ </assignment>
+ </set>
+ </update>
+ </describe>
<describe sql-case-id="explain_for_insert_without_parameters">
<insert>
<table name="t_order" start-index="29" stop-index="35" />
@@ -522,7 +559,21 @@
</values>
</insert>
</describe>
-
+ <describe sql-case-id="explain_for_insert_statement">
+ <insert>
+ <table name="t_order" start-index="58" stop-index="64" />
+ <columns start-index="66" stop-index="75">
+ <column name="order_id" start-index="67" stop-index="74" />
+ </columns>
+ <values>
+ <value>
+ <assignment-value>
+ <literal-expression value="1" start-index="84"
stop-index="84" />
+ </assignment-value>
+ </value>
+ </values>
+ </insert>
+ </describe>
<describe sql-case-id="explain_for_delete_without_sharding_value">
<delete>
<table name="t_order" start-index="29" stop-index="35" />
@@ -569,4 +620,24 @@
</where>
</delete>
</describe>
+ <describe sql-case-id="explain_for_delete_statement">
+ <delete>
+ <table name="t_order" start-index="58" stop-index="64" />
+ <where start-index="66" stop-index="84">
+ <expr>
+ <binary-operation-expression start-index="72"
stop-index="84">
+ <left>
+ <column name="x" start-index="72" stop-index="80">
+ <owner name="t_order" start-index="72"
stop-index="78" />
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="1" start-index="84"
stop-index="84" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </delete>
+ </describe>
</sql-parser-test-cases>
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 dccefae391c..b6e728e8ac0 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
@@ -46,11 +46,15 @@
<sql-case id="explain_for_select_alias_as_keyword" value="EXPLAIN PLAN FOR
SELECT length.item_id password FROM t_order_item length where length.item_id =
1;" db-types="Oracle" />
<sql-case id="explain_for_select_with_binding_tables" value="EXPLAIN PLAN
FOR SELECT i.* FROM t_order o JOIN t_order_item i USING(order_id) WHERE
o.order_id = 10" db-types="Oracle" />
<sql-case id="explain_for_select_with_analyze" value="EXPLAIN PLAN FOR
SELECT * FROM t_order WHERE order_id > 8" db-types="Oracle" />
+ <sql-case id="explain_for_select_with_statement" value="EXPLAIN PLAN SET
STATEMENT_ID = 'select1' FOR SELECT * FROM t_order WHERE order_id > 8"
db-types="Oracle" />
<sql-case id="explain_for_update_without_condition" value="EXPLAIN PLAN
FOR UPDATE t_order SET status = 'finished'" db-types="Oracle" />
<sql-case id="explain_for_update" value="EXPLAIN PLAN FOR UPDATE t_order
SET id = 1" db-types="Oracle" />
+ <sql-case id="explain_for_update_with_statement" value="EXPLAIN PLAN SET
STATEMENT_ID = 'update1' FOR UPDATE t_order SET id = 1" db-types="Oracle" />
<sql-case id="explain_for_insert_without_parameters" value="EXPLAIN PLAN
FOR INSERT INTO t_order (order_id, user_id, status) VALUES (1, 1, 'insert')"
db-types="Oracle" />
<sql-case id="explain_for_with_analyze_insert" value="EXPLAIN PLAN FOR
INSERT INTO t_order (order_id) VALUES(1)" db-types="Oracle" />
+ <sql-case id="explain_for_insert_statement" value="EXPLAIN PLAN SET
STATEMENT_ID = 'insert1' FOR INSERT INTO t_order (order_id) VALUES(1)"
db-types="Oracle" />
<sql-case id="explain_for_delete_without_sharding_value" value="EXPLAIN
PLAN FOR DELETE FROM t_order WHERE status='init'" db-types="Oracle" />
<sql-case id="explain_for_with_analyze_delete" value="EXPLAIN PLAN FOR
DELETE FROM t_order" db-types="Oracle" />
<sql-case id="explain_for_delete_condition" value="EXPLAIN PLAN FOR DELETE
FROM t_order WHERE t_order.x = 1" db-types="Oracle" />
+ <sql-case id="explain_for_delete_statement" value="EXPLAIN PLAN SET
STATEMENT_ID = 'insert1' FOR DELETE FROM t_order WHERE t_order.x = 1"
db-types="Oracle" />
</sql-cases>