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 17e89ffd047 Add presto SQL parse test cases (#37616)
17e89ffd047 is described below
commit 17e89ffd047dda6b29a8fe077c43ca6668badb51
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jan 2 11:46:28 2026 +0800
Add presto SQL parse test cases (#37616)
---
.../{sql/supported/dml => case/ddl}/presto.xml | 15 +-
.../parser/src/main/resources/case/dml/presto.xml | 333 +++++++++++++++++++++
.../sql/supported/{dml => ddl}/presto.xml | 2 +-
.../main/resources/sql/supported/dml/presto.xml | 9 +
4 files changed, 355 insertions(+), 4 deletions(-)
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
b/test/it/parser/src/main/resources/case/ddl/presto.xml
similarity index 62%
copy from test/it/parser/src/main/resources/sql/supported/dml/presto.xml
copy to test/it/parser/src/main/resources/case/ddl/presto.xml
index 28a1e1d0267..d9c9f989902 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
+++ b/test/it/parser/src/main/resources/case/ddl/presto.xml
@@ -16,6 +16,15 @@
~ limitations under the License.
-->
-<sql-cases>
- <sql-case id="presto_select_assignment_operator" value="SELECT * FROM
t_order WHERE order_id := 1" db-types="Presto" />
-</sql-cases>
+<sql-parser-test-cases>
+ <create-table sql-case-id="presto_create_table_decimal">
+ <table name="t_price" start-index="13" stop-index="34">
+ <owner name="schem1" start-index="21" stop-index="26">
+ <owner name="catalog" start-index="13" stop-index="19" />
+ </owner>
+ </table>
+ <column-definition type="DECIMAL" start-index="37" stop-index="56">
+ <column name="amount" />
+ </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 9b027f20ada..ebcb60c08eb 100644
--- a/test/it/parser/src/main/resources/case/dml/presto.xml
+++ b/test/it/parser/src/main/resources/case/dml/presto.xml
@@ -38,4 +38,337 @@
</expr>
</where>
</select>
+
+ <select sql-case-id="presto_select_literals">
+ <from>
+ <simple-table name="t_order" start-index="58" stop-index="79">
+ <owner name="schem1" start-index="66" stop-index="71">
+ <owner name="catalog" start-index="58" stop-index="64" />
+ </owner>
+ </simple-table>
+ </from>
+ <projections start-index="7" stop-index="51">
+ <expression-projection text="2020-01-01" start-index="7"
stop-index="23">
+ <expr>
+ <literal-expression value="2020-01-01" start-index="7"
stop-index="23" />
+ </expr>
+ </expression-projection>
+ <expression-projection text="X'1F'" start-index="26"
stop-index="30">
+ <expr>
+ <common-expression text="X'1F'" start-index="26"
stop-index="30" />
+ </expr>
+ </expression-projection>
+ <expression-projection text="B'1010'" start-index="33"
stop-index="39">
+ <expr>
+ <common-expression text="B'1010'" start-index="33"
stop-index="39" />
+ </expr>
+ </expression-projection>
+ <expression-projection text="true" start-index="42"
stop-index="45">
+ <expr>
+ <literal-expression value="true" start-index="42"
stop-index="45" />
+ </expr>
+ </expression-projection>
+ <expression-projection text="null" start-index="48"
stop-index="51">
+ <expr>
+ <literal-expression value="null" start-index="48"
stop-index="51" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_compare_all_subquery">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="77">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="77">
+ <left>
+ <column name="order_id" start-index="28"
stop-index="35" />
+ </left>
+ <operator>= ALL</operator>
+ <right>
+ <subquery start-index="43" stop-index="77">
+ <select>
+ <from start-index="65" stop-index="76">
+ <simple-table name="t_order_item"
start-index="65" stop-index="76" />
+ </from>
+ <projections start-index="51" stop-index="58">
+ <column-projection name="order_id"
start-index="51" stop-index="58" />
+ </projections>
+ </select>
+ </subquery>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="presto_select_or_boolean_true">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="55">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="55">
+ <left>
+ <binary-operation-expression start-index="28"
stop-index="39">
+ <left>
+ <column name="flag" start-index="28"
stop-index="31" />
+ </left>
+ <operator>IS</operator>
+ <right>
+ <literal-expression value="TRUE"
start-index="36" stop-index="39" />
+ </right>
+ </binary-operation-expression>
+ </left>
+ <operator>OR</operator>
+ <right>
+ <binary-operation-expression start-index="44"
stop-index="55">
+ <left>
+ <column name="order_id" start-index="44"
stop-index="51" />
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="1" start-index="55"
stop-index="55" />
+ </right>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="presto_select_not_flag">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="35">
+ <expr>
+ <not-expression start-index="28" stop-index="35">
+ <expr>
+ <column name="flag" start-index="32" stop-index="35" />
+ </expr>
+ </not-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="presto_select_not_exists_subquery">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="48">
+ <expr>
+ <exists-subquery start-index="32" stop-index="48">
+ <not>true</not>
+ <subquery start-index="39" stop-index="48">
+ <select>
+ <projections start-index="47" stop-index="47">
+ <expression-projection text="1"
start-index="47" stop-index="47">
+ <expr>
+ <literal-expression value="1"
start-index="47" stop-index="47" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+ </subquery>
+ </exists-subquery>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="presto_select_predicate_variants">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="125">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="125">
+ <left>
+ <binary-operation-expression start-index="28"
stop-index="104">
+ <left>
+ <binary-operation-expression start-index="28"
stop-index="80">
+ <left>
+ <between-expression start-index="28"
stop-index="55">
+ <not>true</not>
+ <left>
+ <column name="order_id"
start-index="28" stop-index="35" />
+ </left>
+ <between-expr>
+ <literal-expression value="1"
start-index="49" stop-index="49" />
+ </between-expr>
+ <and-expr>
+ <literal-expression value="5"
start-index="55" stop-index="55" />
+ </and-expr>
+ </between-expression>
+ </left>
+ <operator>AND</operator>
+ <right>
+ <binary-operation-expression
start-index="61" stop-index="80">
+ <left>
+ <column name="status"
start-index="61" stop-index="66" />
+ </left>
+ <operator>REGEXP</operator>
+ <right>
+ <literal-expression
value="[12]" start-index="75" stop-index="80" />
+ </right>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </left>
+ <operator>AND</operator>
+ <right>
+ <binary-operation-expression start-index="86"
stop-index="104">
+ <left>
+ <column name="status" start-index="86"
stop-index="91" />
+ </left>
+ <operator>RLIKE</operator>
+ <right>
+ <literal-expression value="[34]"
start-index="99" stop-index="104" />
+ </right>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </left>
+ <operator>AND</operator>
+ <right>
+ <binary-operation-expression start-index="110"
stop-index="125">
+ <left>
+ <column name="status" start-index="110"
stop-index="115" />
+ </left>
+ <operator>LIKE</operator>
+ <right>
+ <list-expression start-index="122"
stop-index="125">
+ <items>
+ <literal-expression value="ok"
start-index="122" stop-index="125" />
+ </items>
+ </list-expression>
+ </right>
+ </binary-operation-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="presto_select_case_binary_variable">
+ <from>
+ <simple-table name="t_order" start-index="104" stop-index="110" />
+ </from>
+ <projections start-index="7" stop-index="97">
+ <expression-projection text="CASE catalog.schem1.order_id WHEN 1
THEN 'one' ELSE 'other' END" start-index="7" stop-index="69">
+ <expr>
+ <case-when-expression>
+ <case-expr start-index="12" stop-index="34">
+ <column name="order_id" start-index="12"
stop-index="34">
+ <owner name="schem1" start-index="20"
stop-index="25">
+ <owner name="catalog" start-index="12"
stop-index="18" />
+ </owner>
+ </column>
+ </case-expr>
+ <when-exprs>
+ <literal-expression value="1" start-index="41"
stop-index="41" />
+ </when-exprs>
+ <then-exprs>
+ <literal-expression value="one" start-index="48"
stop-index="52" />
+ </then-exprs>
+ <else-expr>
+ <literal-expression value="other" start-index="59"
stop-index="65" />
+ </else-expr>
+ </case-when-expression>
+ </expr>
+ </expression-projection>
+ <column-projection name="status" start-index="79" stop-index="84"
/>
+ <expression-projection text="@user_value" start-index="87"
stop-index="97">
+ <expr>
+ <variable-segment text="@user_value" start-index="87"
stop-index="97" variable="user_value" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_concat_match_interval">
+ <from>
+ <simple-table name="t_order" start-index="96" stop-index="102" />
+ </from>
+ <projections start-index="7" stop-index="89">
+ <expression-projection text="status || 'X'" start-index="7"
stop-index="19">
+ <expr>
+ <binary-operation-expression start-index="7"
stop-index="19">
+ <left>
+ <column name="status" start-index="7"
stop-index="12" />
+ </left>
+ <operator>||</operator>
+ <right>
+ <literal-expression value="X" start-index="17"
stop-index="19" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </expression-projection>
+ <expression-projection text="MATCH(status) AGAINST ('kw')"
start-index="22" stop-index="49">
+ <expr>
+ <common-expression text="MATCH(status) AGAINST ('kw')"
start-index="22" stop-index="49" />
+ </expr>
+ </expression-projection>
+ <expression-projection text="INTERVAL" start-index="52"
stop-index="59">
+ <expr>
+ <function function-name="INTERVAL" text="INTERVAL"
start-index="52" stop-index="59">
+ <parameter>
+ <literal-expression value="1" start-index="61"
stop-index="63" />
+ </parameter>
+ <parameter>
+ <literal-expression value="DAY" start-index="65"
stop-index="67" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ <expression-projection text="catalog.fn(order_id)"
start-index="70" stop-index="89">
+ <expr>
+ <function function-name="catalog.fn(order_id)"
text="catalog.fn(order_id)" start-index="70" stop-index="89">
+ <parameter>
+ <column name="order_id" start-index="81"
stop-index="88" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="presto_select_is_true">
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <where start-index="22" stop-index="39">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="39">
+ <left>
+ <column name="flag" start-index="28" stop-index="31" />
+ </left>
+ <operator>IS</operator>
+ <right>
+ <literal-expression value="TRUE" start-index="36"
stop-index="39" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
</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/ddl/presto.xml
similarity index 86%
copy from test/it/parser/src/main/resources/sql/supported/dml/presto.xml
copy to test/it/parser/src/main/resources/sql/supported/ddl/presto.xml
index 28a1e1d0267..607ab07d1de 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
+++ b/test/it/parser/src/main/resources/sql/supported/ddl/presto.xml
@@ -17,5 +17,5 @@
-->
<sql-cases>
- <sql-case id="presto_select_assignment_operator" value="SELECT * FROM
t_order WHERE order_id := 1" db-types="Presto" />
+ <sql-case id="presto_create_table_decimal" value="CREATE TABLE
catalog.schem1.t_price (amount DECIMAL(10,2))" db-types="Presto" />
</sql-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 28a1e1d0267..b878305a582 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
@@ -17,5 +17,14 @@
-->
<sql-cases>
+ <sql-case id="presto_select_literals" value="SELECT DATE '2020-01-01',
X'1F', B'1010', TRUE, NULL FROM catalog.schem1.t_order" db-types="Presto" />
+ <sql-case id="presto_select_compare_all_subquery" value="SELECT * FROM
t_order WHERE order_id = ALL (SELECT order_id FROM t_order_item)"
db-types="Presto" />
+ <sql-case id="presto_select_or_boolean_true" value="SELECT * FROM t_order
WHERE flag IS TRUE OR order_id = 1" db-types="Presto" />
+ <sql-case id="presto_select_not_flag" value="SELECT * FROM t_order WHERE
NOT flag" db-types="Presto" />
+ <sql-case id="presto_select_not_exists_subquery" value="SELECT * FROM
t_order WHERE NOT EXISTS (SELECT 1)" db-types="Presto" />
<sql-case id="presto_select_assignment_operator" value="SELECT * FROM
t_order WHERE order_id := 1" db-types="Presto" />
+ <sql-case id="presto_select_predicate_variants" value="SELECT * FROM
t_order WHERE order_id NOT BETWEEN 1 AND 5 AND status REGEXP '[12]' AND status
RLIKE '[34]' AND status LIKE 'ok'" db-types="Presto" />
+ <sql-case id="presto_select_case_binary_variable" value="SELECT CASE
catalog.schem1.order_id WHEN 1 THEN 'one' ELSE 'other' END, BINARY status,
@user_value FROM t_order" db-types="Presto" />
+ <sql-case id="presto_select_concat_match_interval" value="SELECT status ||
'X', MATCH(status) AGAINST ('kw'), INTERVAL '1' DAY, catalog.fn(order_id) FROM
t_order" db-types="Presto" />
+ <sql-case id="presto_select_is_true" value="SELECT * FROM t_order WHERE
flag IS TRUE" db-types="Presto" />
</sql-cases>