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 c31ff8bddaa Add oracle create view and delete parse test (#29051)
c31ff8bddaa is described below
commit c31ff8bddaaa7d9590364977093c15335fbd6802
Author: niu niu <[email protected]>
AuthorDate: Thu Nov 16 17:40:51 2023 +0800
Add oracle create view and delete parse test (#29051)
---
.../src/main/resources/case/ddl/create-view.xml | 114 +++++++++++++++++++++
.../parser/src/main/resources/case/dml/delete.xml | 17 +++
.../resources/sql/supported/ddl/create-view.xml | 3 +
.../main/resources/sql/supported/dml/delete.xml | 1 +
4 files changed, 135 insertions(+)
diff --git a/test/it/parser/src/main/resources/case/ddl/create-view.xml
b/test/it/parser/src/main/resources/case/ddl/create-view.xml
index 5b75c81512a..225a9a30e3c 100644
--- a/test/it/parser/src/main/resources/case/ddl/create-view.xml
+++ b/test/it/parser/src/main/resources/case/ddl/create-view.xml
@@ -296,4 +296,118 @@
</where>
</select>
</create-view>
+
+ <create-view sql-case-id="create_view_select_partition"
view-definition="SELECT * FROM sales PARTITION (SALES_Q1_2000)">
+ <view name="Q1_2000_sales" start-index="12" stop-index="24" />
+ <select>
+ <projections start-index="36" stop-index="36">
+ <shorthand-projection start-index="36" stop-index="36" />
+ </projections>
+ <from>
+ <simple-table name="sales" start-index="43" stop-index="47" />
+ </from>
+ </select>
+ </create-view>
+
+ <create-view sql-case-id="create_view_select_with_check_option"
view-definition="SELECT employee_id, last_name, department_id, job_id FROM
employees WHERE job_id = 'PU_CLERK' or job_id = 'SH_CLERK' or job_id =
'ST_CLERK'">
+ <view name="clerk" start-index="12" stop-index="16" />
+ <select>
+ <projections start-index="28" stop-index="72">
+ <column-projection name="employee_id" start-index="28"
stop-index="38" />
+ <column-projection name="last_name" start-index="41"
stop-index="49" />
+ <column-projection name="department_id" start-index="52"
stop-index="64" />
+ <column-projection name="job_id" start-index="67"
stop-index="72" />
+ </projections>
+ <from>
+ <simple-table name="employees" start-index="79"
stop-index="87" />
+ </from>
+ <where start-index="89" stop-index="159">
+ <expr>
+ <binary-operation-expression start-index="95"
stop-index="159">
+ <left>
+ <binary-operation-expression start-index="95"
stop-index="136">
+ <left>
+ <binary-operation-expression
start-index="95" stop-index="113">
+ <left>
+ <column name="job_id"
start-index="95" stop-index="100" />
+ </left>
+ <right>
+ <literal-expression
value="PU_CLERK" start-index="104" stop-index="113" />
+ </right>
+ <operator>=</operator>
+ </binary-operation-expression>
+ </left>
+ <right>
+ <binary-operation-expression
start-index="118" stop-index="136">
+ <left>
+ <column name="job_id"
start-index="118" stop-index="123" />
+ </left>
+ <right>
+ <literal-expression
value="SH_CLERK" start-index="127" stop-index="136" />
+ </right>
+ <operator>=</operator>
+ </binary-operation-expression>
+ </right>
+ <operator>or</operator>
+ </binary-operation-expression>
+ </left>
+ <right>
+ <binary-operation-expression start-index="141"
stop-index="159">
+ <left>
+ <column name="job_id" start-index="141"
stop-index="146" />
+ </left>
+ <right>
+ <literal-expression value="ST_CLERK"
start-index="150" stop-index="159" />
+ </right>
+ <operator>=</operator>
+ </binary-operation-expression>
+ </right>
+ <operator>or</operator>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+ </create-view>
+
+ <create-view sql-case-id="create_view_select_union"
view-definition="(SELECT employee_id, last_name, job_id, commission_pct,
department_id FROM employees) UNION (SELECT employee_id, last_name, job_id,
commission_pct, department_id FROM contract_workers)">
+ <view name="all_employees_vw" start-index="12" stop-index="27" />
+ <select>
+ <projections start-index="40" stop-index="100">
+ <column-projection name="employee_id" start-index="40"
stop-index="50" />
+ <column-projection name="last_name" start-index="53"
stop-index="61" />
+ <column-projection name="job_id" start-index="64"
stop-index="69" />
+ <column-projection name="commission_pct" start-index="72"
stop-index="85" />
+ <column-projection name="department_id" start-index="88"
stop-index="100" />
+ </projections>
+ <from>
+ <simple-table name="employees" start-index="107"
stop-index="115" />
+ </from>
+ <combine combine-type="UNION" start-index="32" stop-index="215">
+ <left>
+ <projections start-index="40" stop-index="100">
+ <column-projection name="employee_id" start-index="40"
stop-index="50" />
+ <column-projection name="last_name" start-index="53"
stop-index="61" />
+ <column-projection name="job_id" start-index="64"
stop-index="69" />
+ <column-projection name="commission_pct"
start-index="72" stop-index="85" />
+ <column-projection name="department_id"
start-index="88" stop-index="100" />
+ </projections>
+ <from>
+ <simple-table name="employees" start-index="107"
stop-index="115" />
+ </from>
+ </left>
+ <right>
+ <projections start-index="132" stop-index="192">
+ <column-projection name="employee_id"
start-index="132" stop-index="142" />
+ <column-projection name="last_name" start-index="145"
stop-index="153" />
+ <column-projection name="job_id" start-index="156"
stop-index="161" />
+ <column-projection name="commission_pct"
start-index="164" stop-index="177" />
+ <column-projection name="department_id"
start-index="180" stop-index="192" />
+ </projections>
+ <from>
+ <simple-table name="contract_workers"
start-index="199" stop-index="214" />
+ </from>
+ </right>
+ </combine>
+ </select>
+ </create-view>
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/delete.xml
b/test/it/parser/src/main/resources/case/dml/delete.xml
index b1d9da93158..cc76fb9a78c 100644
--- a/test/it/parser/src/main/resources/case/dml/delete.xml
+++ b/test/it/parser/src/main/resources/case/dml/delete.xml
@@ -700,4 +700,21 @@
<owner name="db1" start-index="12" stop-index="14" />
</table>
</delete>
+
+ <delete sql-case-id="delete_with_simple_condition">
+ <table name="Q1_2000_sales" start-index="12" stop-index="24" />
+ <where start-index="26" stop-index="46">
+ <expr>
+ <binary-operation-expression start-index="32" stop-index="46">
+ <left>
+ <column name="amount_sold" start-index="32"
stop-index="42" />
+ </left>
+ <operator><</operator>
+ <right>
+ <literal-expression value="0" start-index="46"
stop-index="46" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </delete>
</sql-parser-test-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml
b/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml
index e2f5eaea094..1c7de9f5fc7 100644
--- a/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/create-view.xml
@@ -27,4 +27,7 @@
<sql-case id="create_or_replace_view_with_select" value="create or replace
view named_moons as select p.name planet, p.class, m.name moon, m.radius from
planets p, moons m where p.name = m.planet_name(+) and m.name(+) not like
'S/%'" db-types="Oracle" />
<sql-case id="create_view_as_simple_select" value="CREATE VIEW
laurel.employee AS SELECT * FROM laurel.emp" db-types="Oracle" />
<sql-case id="create_view_as_where_where" value="CREATE VIEW
employees_departments AS SELECT employee_id, last_name, department_id FROM
employees, departments WHERE employees.department_id =
departments.department_id" db-types="Oracle" />
+ <sql-case id="create_view_select_partition" value="CREATE VIEW
Q1_2000_sales AS SELECT * FROM sales PARTITION (SALES_Q1_2000)"
db-types="Oracle" />
+ <sql-case id="create_view_select_with_check_option" value="CREATE VIEW
clerk AS SELECT employee_id, last_name, department_id, job_id FROM employees
WHERE job_id = 'PU_CLERK' or job_id = 'SH_CLERK' or job_id = 'ST_CLERK' WITH
CHECK OPTION" db-types="Oracle" />
+ <sql-case id="create_view_select_union" value="CREATE VIEW
all_employees_vw AS (SELECT employee_id, last_name, job_id, commission_pct,
department_id FROM employees) UNION (SELECT employee_id, last_name, job_id,
commission_pct, department_id FROM contract_workers)" db-types="Oracle" />
</sql-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/delete.xml
b/test/it/parser/src/main/resources/sql/supported/dml/delete.xml
index bdc02019b39..dea8fb1a5a9 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/delete.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/delete.xml
@@ -42,4 +42,5 @@
<sql-case id="delete_with_partition" value="DELETE FROM sales PARTITION
(sales_q1_1998) WHERE amount_sold > 1000" db-types="Oracle" />
<sql-case id="delete_with_table" value="DELETE product_price_history"
db-types="Oracle" />
<sql-case id="delete_with_schema" value="DELETE FROM db1.t_order" />
+ <sql-case id="delete_with_simple_condition" value="DELETE FROM
Q1_2000_sales WHERE amount_sold < 0" db-types="Oracle" />
</sql-cases>