This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 b6fd645b0b2 Add more test cases on Doris SQL parser (#37638)
b6fd645b0b2 is described below
commit b6fd645b0b279e34f3b661298ee94a7da49219ce
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jan 4 23:13:23 2026 +0800
Add more test cases on Doris SQL parser (#37638)
---
.../parser/src/main/resources/case/ddl/presto.xml | 1 +
.../parser/src/main/resources/case/dml/presto.xml | 298 +++++++++++++++++++++
.../main/resources/sql/supported/dml/presto.xml | 19 ++
3 files changed, 318 insertions(+)
diff --git a/test/it/parser/src/main/resources/case/ddl/presto.xml
b/test/it/parser/src/main/resources/case/ddl/presto.xml
index 8d54e4960bf..2421eb8e8bf 100644
--- a/test/it/parser/src/main/resources/case/ddl/presto.xml
+++ b/test/it/parser/src/main/resources/case/ddl/presto.xml
@@ -62,4 +62,5 @@
<column name="name" start-index="23" stop-index="26" />
</column-definition>
</create-table>
+
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/presto.xml
b/test/it/parser/src/main/resources/case/dml/presto.xml
index f8b33bc18c9..cf29ea9fbe3 100644
--- a/test/it/parser/src/main/resources/case/dml/presto.xml
+++ b/test/it/parser/src/main/resources/case/dml/presto.xml
@@ -1475,4 +1475,302 @@
</where>
</delete>
+ <select sql-case-id="presto_select_not_operator_bang">
+ <from>
+ <simple-table name="t_order" start-index="18" stop-index="24" />
+ </from>
+ <projections start-index="7" stop-index="11">
+ <expression-projection text="flag" start-index="7" stop-index="11">
+ <expr>
+ <not-expression start-index="7" stop-index="11">
+ <expr>
+ <column name="flag" start-index="8"
stop-index="11" />
+ </expr>
+ </not-expression>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_cast_as_char">
+ <from>
+ <simple-table name="t_order" start-index="35" stop-index="41" />
+ </from>
+ <projections start-index="7" stop-index="28">
+ <expression-projection text="CAST(order_id AS CHAR)"
start-index="7" stop-index="28">
+ <expr>
+ <function function-name="CAST" text="CAST(order_id AS
CHAR)" start-index="7" stop-index="28">
+ <parameter>
+ <column name="order_id" start-index="12"
stop-index="19" />
+ </parameter>
+ <parameter>
+ <data-type value="CHAR" start-index="24"
stop-index="27" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_subquery_projection">
+ <from>
+ <simple-table name="t_order" start-index="23" stop-index="29" />
+ </from>
+ <projections start-index="7" stop-index="16">
+ <subquery-projection start-index="7" stop-index="16" text="(SELECT
1)" literal-text="(SELECT 1)">
+ <subquery>
+ <select>
+ <projections start-index="15" stop-index="15">
+ <expression-projection text="1" start-index="15"
stop-index="15">
+ <expr>
+ <literal-expression value="1"
start-index="15" stop-index="15" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+ </subquery>
+ </subquery-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_exists_projection">
+ <from>
+ <simple-table name="t_order" start-index="30" stop-index="36" />
+ </from>
+ <projections start-index="7" stop-index="23">
+ <subquery-projection start-index="14" stop-index="23" text="EXISTS
(SELECT 1)" literal-text="EXISTS (SELECT 1)">
+ <subquery>
+ <select>
+ <projections start-index="22" stop-index="22">
+ <expression-projection text="1" start-index="22"
stop-index="22">
+ <expr>
+ <literal-expression value="1"
start-index="22" stop-index="22" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+ </subquery>
+ </subquery-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_in_projection">
+ <from>
+ <simple-table name="t_order" start-index="23" stop-index="29" />
+ </from>
+ <projections start-index="7" stop-index="16">
+ <expression-projection text="1 IN (1,2)" start-index="7"
stop-index="16">
+ <expr>
+ <in-expression start-index="7" stop-index="16">
+ <not>false</not>
+ <left>
+ <literal-expression value="1" start-index="7"
stop-index="7" />
+ </left>
+ <right>
+ <list-expression start-index="12" stop-index="16">
+ <items>
+ <literal-expression value="1"
start-index="13" stop-index="13" />
+ </items>
+ <items>
+ <literal-expression value="2"
start-index="15" stop-index="15" />
+ </items>
+ </list-expression>
+ </right>
+ </in-expression>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_between_projection">
+ <from>
+ <simple-table name="t_order" start-index="30" stop-index="36" />
+ </from>
+ <projections start-index="7" stop-index="23">
+ <expression-projection text="1 BETWEEN 1 AND 2" start-index="7"
stop-index="23">
+ <expr>
+ <between-expression start-index="7" stop-index="23">
+ <not>false</not>
+ <left>
+ <literal-expression value="1" start-index="7"
stop-index="7" />
+ </left>
+ <between-expr>
+ <literal-expression value="1" start-index="17"
stop-index="17" />
+ </between-expr>
+ <and-expr>
+ <literal-expression value="2" start-index="23"
stop-index="23" />
+ </and-expr>
+ </between-expression>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+
+ <select sql-case-id="presto_select_left_join">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <join-table join-type="LEFT" start-index="14" stop-index="87">
+ <left>
+ <simple-table name="t_order" start-index="14"
stop-index="20" />
+ </left>
+ <right>
+ <simple-table name="t_order_item" start-index="32"
stop-index="43" />
+ </right>
+ <on-condition start-index="48" stop-index="87">
+ <binary-operation-expression start-index="48"
stop-index="87">
+ <left>
+ <column name="order_id" start-index="48"
stop-index="63">
+ <owner name="t_order" start-index="48"
stop-index="54" />
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <column name="order_id" start-index="67"
stop-index="87">
+ <owner name="t_order_item" start-index="67"
stop-index="78" />
+ </column>
+ </right>
+ </binary-operation-expression>
+ </on-condition>
+ </join-table>
+ </from>
+ </select>
+
+ <select sql-case-id="presto_select_right_join">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <join-table join-type="RIGHT" start-index="14" stop-index="88">
+ <left>
+ <simple-table name="t_order" start-index="14"
stop-index="20" />
+ </left>
+ <right>
+ <simple-table name="t_order_item" start-index="33"
stop-index="44" />
+ </right>
+ <on-condition start-index="49" stop-index="88">
+ <binary-operation-expression start-index="49"
stop-index="88">
+ <left>
+ <column name="order_id" start-index="49"
stop-index="64">
+ <owner name="t_order" start-index="49"
stop-index="55" />
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <column name="order_id" start-index="68"
stop-index="88">
+ <owner name="t_order_item" start-index="68"
stop-index="79" />
+ </column>
+ </right>
+ </binary-operation-expression>
+ </on-condition>
+ </join-table>
+ </from>
+ </select>
+
+ <select sql-case-id="presto_select_natural_join">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <join-table join-type="INNER" natural="true" start-index="14"
stop-index="46">
+ <left>
+ <simple-table name="t_order" start-index="14"
stop-index="20" />
+ </left>
+ <right>
+ <simple-table name="t_order_item" start-index="35"
stop-index="46" />
+ </right>
+ </join-table>
+ </from>
+ </select>
+
+ <select sql-case-id="presto_select_natural_right_join">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <join-table join-type="RIGHT" natural="true" start-index="14"
stop-index="52">
+ <left>
+ <simple-table name="t_order" start-index="14"
stop-index="20" />
+ </left>
+ <right>
+ <simple-table name="t_order_item" start-index="41"
stop-index="52" />
+ </right>
+ </join-table>
+ </from>
+ </select>
+
+ <select sql-case-id="presto_select_join_using">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <join-table join-type="INNER" start-index="14" stop-index="54">
+ <left>
+ <simple-table name="t_order" start-index="14"
stop-index="20" />
+ </left>
+ <right>
+ <simple-table name="t_order_item" start-index="27"
stop-index="38" />
+ </right>
+ <using-columns name="order_id" start-index="46"
stop-index="53" />
+ </join-table>
+ </from>
+ </select>
+
+ <select sql-case-id="presto_select_json_separator">
+ <from>
+ <simple-table name="t_order" start-index="30" stop-index="36" />
+ </from>
+ <projections start-index="7" stop-index="23">
+ <expression-projection text="order_info->'$.a'" start-index="7"
stop-index="23" />
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_json_unquoted_separator">
+ <from>
+ <simple-table name="t_order" start-index="31" stop-index="37" />
+ </from>
+ <projections start-index="7" stop-index="24">
+ <expression-projection text="order_info->>'$.a'"
start-index="7" stop-index="24" />
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_udf_with_param">
+ <from>
+ <simple-table name="t_order" start-index="29" stop-index="35" />
+ </from>
+ <projections start-index="7" stop-index="22">
+ <expression-projection text="my_udf(order_id)" start-index="7"
stop-index="22">
+ <function function-name="my_udf(order_id)" start-index="7"
stop-index="22" text="my_udf(order_id)" />
+ </expression-projection>
+ </projections>
+ </select>
+
+ <insert sql-case-id="presto_insert_select_no_columns">
+ <table name="t_order" start-index="12" stop-index="18" />
+ <columns start-index="19" stop-index="19" />
+ <select>
+ <projections start-index="27" stop-index="27">
+ <expression-projection text="1" start-index="27"
stop-index="27">
+ <expr>
+ <literal-expression value="1" start-index="27"
stop-index="27" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+ </insert>
+
+ <insert sql-case-id="presto_insert_values_empty_columns">
+ <table name="t_order" start-index="12" stop-index="18" />
+ <columns start-index="20" stop-index="21" />
+ <values>
+ <value>
+ <assignment-value>
+ <literal-expression value="1" start-index="31"
stop-index="31" />
+ </assignment-value>
+ </value>
+ </values>
+ </insert>
+
</sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
b/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
index 0bde7e891e3..da819eed0ec 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
@@ -69,4 +69,23 @@
<sql-case id="presto_select_subquery_table" value="SELECT * FROM (SELECT *
FROM t_order) t" db-types="Presto" />
<sql-case id="presto_select_system_variable_plain" value="SELECT
@@time_zone" db-types="Presto" />
<sql-case id="presto_insert_set_assignment" value="INSERT INTO t_order SET
status = order_id" db-types="Presto" />
+ <sql-case id="presto_select_union" value="SELECT * FROM table1 UNION
SELECT * FROM table2" db-types="Presto" />
+ <sql-case id="presto_select_union_all" value="SELECT * FROM table1 UNION
ALL SELECT * FROM table2" db-types="Presto" />
+ <sql-case id="presto_select_with_except" value="(SELECT * FROM t1) EXCEPT
(SELECT * FROM t2)" db-types="Presto" />
+ <sql-case id="presto_select_not_operator_bang" value="SELECT !flag FROM
t_order" db-types="Presto" />
+ <sql-case id="presto_select_cast_as_char" value="SELECT CAST(order_id AS
CHAR) FROM t_order" db-types="Presto" />
+ <sql-case id="presto_select_subquery_projection" value="SELECT (SELECT 1)
FROM t_order" db-types="Presto" />
+ <sql-case id="presto_select_exists_projection" value="SELECT EXISTS
(SELECT 1) FROM t_order" db-types="Presto" />
+ <sql-case id="presto_select_in_projection" value="SELECT 1 IN (1,2) FROM
t_order" db-types="Presto" />
+ <sql-case id="presto_select_between_projection" value="SELECT 1 BETWEEN 1
AND 2 FROM t_order" db-types="Presto" />
+ <sql-case id="presto_select_left_join" value="SELECT * FROM t_order LEFT
JOIN t_order_item ON t_order.order_id = t_order_item.order_id"
db-types="Presto" />
+ <sql-case id="presto_select_right_join" value="SELECT * FROM t_order RIGHT
JOIN t_order_item ON t_order.order_id = t_order_item.order_id"
db-types="Presto" />
+ <sql-case id="presto_select_natural_join" value="SELECT * FROM t_order
NATURAL JOIN t_order_item" db-types="Presto" />
+ <sql-case id="presto_select_natural_right_join" value="SELECT * FROM
t_order NATURAL RIGHT JOIN t_order_item" db-types="Presto" />
+ <sql-case id="presto_select_join_using" value="SELECT * FROM t_order JOIN
t_order_item USING(order_id)" db-types="Presto" />
+ <sql-case id="presto_select_json_separator" value="SELECT
order_info->'$.a' FROM t_order" db-types="Presto" />
+ <sql-case id="presto_select_json_unquoted_separator" value="SELECT
order_info->>'$.a' FROM t_order" db-types="Presto" />
+ <sql-case id="presto_select_udf_with_param" value="SELECT my_udf(order_id)
FROM t_order" db-types="Presto" />
+ <sql-case id="presto_insert_select_no_columns" value="INSERT INTO t_order
SELECT 1" db-types="Presto" />
+ <sql-case id="presto_insert_values_empty_columns" value="INSERT INTO
t_order () VALUES (1)" db-types="Presto" />
</sql-cases>