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 071eabe6db7 Add more SQL parser test cases on presto (#37614)
071eabe6db7 is described below
commit 071eabe6db7574a1b526d15a277ba477e5852989
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Jan 2 10:36:47 2026 +0800
Add more SQL parser test cases on presto (#37614)
---
.../parser/src/main/resources/case/dml/presto.xml | 41 ++++++++++++++++++++++
.../main/resources/sql/supported/dml/presto.xml | 21 +++++++++++
.../sql/supported/dml/select-expression.xml | 32 ++++++++---------
.../sql/supported/dml/select-order-by.xml | 2 +-
.../sql/supported/dml/select-special-function.xml | 2 +-
5 files changed, 80 insertions(+), 18 deletions(-)
diff --git a/test/it/parser/src/main/resources/case/dml/presto.xml
b/test/it/parser/src/main/resources/case/dml/presto.xml
new file mode 100644
index 00000000000..9b027f20ada
--- /dev/null
+++ b/test/it/parser/src/main/resources/case/dml/presto.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<sql-parser-test-cases>
+ <select sql-case-id="presto_select_assignment_operator">
+ <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="40">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="40">
+ <left>
+ <column name="order_id" start-index="28"
stop-index="35" />
+ </left>
+ <operator>:=</operator>
+ <right>
+ <literal-expression value="1" start-index="40"
stop-index="40" />
+ </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/dml/presto.xml
new file mode 100644
index 00000000000..28a1e1d0267
--- /dev/null
+++ b/test/it/parser/src/main/resources/sql/supported/dml/presto.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ 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>
diff --git
a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
index 6ecfeceb5f7..1c6aef14c2f 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-expression.xml
@@ -32,7 +32,7 @@
<sql-case id="select_with_case_expression" value="select t.*,o.item_id as
item_id,(case when t.status = 'init' then '已启用' when t.status = 'failed' then
'已停用' end) as stateName from t_order t left join t_order_item as o on
o.order_id =t.order_id where t.order_id=1000 limit 1" db-types="MySQL,H2" />
<sql-case id="select_where_with_expr_with_or" value="SELECT * FROM t_order
WHERE t_order.order_id = ? OR ? = t_order.order_id" db-types="MySQL" />
<sql-case id="select_where_with_expr_with_or_sign" value="SELECT * FROM
t_order WHERE t_order.order_id = ? || ? = t_order.order_id" db-types="MySQL" />
- <sql-case id="select_where_with_expr_with_xor" value="SELECT * FROM
t_order WHERE t_order.order_id = ? XOR ? = t_order.order_id" db-types="MySQL" />
+ <sql-case id="select_where_with_expr_with_xor" value="SELECT * FROM
t_order WHERE t_order.order_id = ? XOR ? = t_order.order_id"
db-types="MySQL,Presto" />
<sql-case id="select_where_with_expr_with_and" value="SELECT * FROM
t_order WHERE t_order.order_id = ? AND ? = t_order.order_id" db-types="MySQL" />
<sql-case id="select_where_with_expr_with_and_or" value="SELECT * FROM
t_order WHERE t_order.order_id = ? AND ? = t_order.order_id OR t_order.status =
'failed' AND ? = t_order.order_id" />
<sql-case id="select_where_with_expr_with_and_sign" value="SELECT * FROM
t_order WHERE t_order.order_id = ? && ? = t_order.order_id"
db-types="MySQL" />
@@ -40,24 +40,24 @@
<sql-case id="select_where_with_expr_with_not_sign" value="SELECT * FROM
t_order WHERE ! ( ? = t_order.order_id)" db-types="MySQL" />
<sql-case id="select_where_with_expr_with_is" value="SELECT * FROM t_order
WHERE ? = t_order.order_id IS FALSE" db-types="MySQL" />
<sql-case id="select_where_with_expr_with_is_not" value="SELECT * FROM
t_order WHERE ? = t_order.order_id IS NOT FALSE" db-types="MySQL" />
- <sql-case id="select_where_with_boolean_primary_with_is" value="SELECT *
FROM t_order WHERE t_order.status IS NULL" db-types="MySQL" />
- <sql-case id="select_where_with_boolean_primary_with_is_not" value="SELECT
* FROM t_order WHERE t_order.status IS NOT NULL" db-types="MySQL" />
- <sql-case id="select_where_with_boolean_primary_with_null_safe"
value="SELECT * FROM t_order WHERE t_order.status <=> t_order.order_id"
db-types="MySQL" />
+ <sql-case id="select_where_with_boolean_primary_with_is" value="SELECT *
FROM t_order WHERE t_order.status IS NULL" db-types="MySQL,Presto" />
+ <sql-case id="select_where_with_boolean_primary_with_is_not" value="SELECT
* FROM t_order WHERE t_order.status IS NOT NULL" db-types="MySQL,Presto" />
+ <sql-case id="select_where_with_boolean_primary_with_null_safe"
value="SELECT * FROM t_order WHERE t_order.status <=> t_order.order_id"
db-types="MySQL,Presto" />
<sql-case id="select_where_with_boolean_primary_with_comparison_predicate"
value="SELECT * FROM t_order WHERE t_order.status >= t_order.order_id"
db-types="MySQL" />
<sql-case id="select_where_with_boolean_primary_with_comparison_subquery"
value="SELECT * FROM t_order WHERE t_order.status > ALL (SELECt status FROM
t_order_item WHERE status > ?)" db-types="MySQL" />
- <sql-case id="select_where_with_predicate_with_in_subquery" value="SELECT
* FROM t_order WHERE t_order.order_id NOT IN (SELECT order_id FROM t_order_item
WHERE status > ?)" db-types="MySQL,PostgreSQL,openGauss" />
- <sql-case id="select_where_with_predicate_with_in_expr" value="SELECT *
FROM t_order WHERE t_order.order_id IN (?, ?, ?)"
db-types="MySQL,PostgreSQL,openGauss" />
- <sql-case id="select_where_with_predicate_with_between" value="SELECT *
FROM t_order WHERE t_order.order_id BETWEEN ? AND ?" db-types="MySQL" />
- <sql-case id="select_where_with_predicate_with_sounds_like" value="SELECT
* FROM t_order WHERE t_order.order_id SOUNDS LIKE '1%'" db-types="MySQL" />
- <sql-case id="select_where_with_predicate_with_like" value="SELECT * FROM
t_order WHERE t_order.order_id NOT LIKE '1%' ESCAPE '$'" db-types="MySQL" />
+ <sql-case id="select_where_with_predicate_with_in_subquery" value="SELECT
* FROM t_order WHERE t_order.order_id NOT IN (SELECT order_id FROM t_order_item
WHERE status > ?)" db-types="MySQL,PostgreSQL,openGauss,Presto" />
+ <sql-case id="select_where_with_predicate_with_in_expr" value="SELECT *
FROM t_order WHERE t_order.order_id IN (?, ?, ?)"
db-types="MySQL,PostgreSQL,openGauss,Presto" />
+ <sql-case id="select_where_with_predicate_with_between" value="SELECT *
FROM t_order WHERE t_order.order_id BETWEEN ? AND ?" db-types="MySQL,Presto" />
+ <sql-case id="select_where_with_predicate_with_sounds_like" value="SELECT
* FROM t_order WHERE t_order.order_id SOUNDS LIKE '1%'" db-types="MySQL,Presto"
/>
+ <sql-case id="select_where_with_predicate_with_like" value="SELECT * FROM
t_order WHERE t_order.order_id NOT LIKE '1%' ESCAPE '$'"
db-types="MySQL,Presto" />
<sql-case id="select_where_with_predicate_with_not_like" value="SELECT *
FROM t_order WHERE t_order.status NOT LIKE '1%'"
db-types="MySQL,PostgreSQL,openGauss" />
- <sql-case id="select_where_with_predicate_with_regexp" value="SELECT *
FROM t_order WHERE t_order.order_id NOT REGEXP '[123]'" db-types="MySQL" />
- <sql-case id="select_where_with_predicate_with_rlike" value="SELECT * FROM
t_order WHERE t_order.order_id NOT RLIKE '[123]'" db-types="MySQL" />
+ <sql-case id="select_where_with_predicate_with_regexp" value="SELECT *
FROM t_order WHERE t_order.order_id NOT REGEXP '[123]'" db-types="MySQL,Presto"
/>
+ <sql-case id="select_where_with_predicate_with_rlike" value="SELECT * FROM
t_order WHERE t_order.order_id NOT RLIKE '[123]'" db-types="MySQL,Presto" />
<sql-case id="select_where_with_bit_expr_with_vertical_bar" value="SELECT
* FROM t_order WHERE t_order.order_id | ?" db-types="MySQL" />
<sql-case id="select_where_with_bit_expr_with_ampersand" value="SELECT *
FROM t_order WHERE t_order.order_id & ?" db-types="MySQL" />
<sql-case id="select_where_with_bit_expr_with_signed_left_shift"
value="SELECT * FROM t_order WHERE t_order.order_id << ?"
db-types="MySQL" />
<sql-case id="select_where_with_bit_expr_with_signed_right_shift"
value="SELECT * FROM t_order WHERE t_order.order_id >> ?"
db-types="MySQL" />
- <sql-case id="select_where_with_bit_expr_with_plus" value="SELECT * FROM
t_order WHERE t_order.order_id + ?" db-types="MySQL" />
+ <sql-case id="select_where_with_bit_expr_with_plus" value="SELECT * FROM
t_order WHERE t_order.order_id + ?" db-types="MySQL,Presto" />
<sql-case id="select_where_with_bit_expr_with_minus" value="SELECT * FROM
t_order WHERE t_order.order_id - ?" db-types="MySQL" />
<sql-case id="select_where_with_bit_expr_with_asterisk" value="SELECT *
FROM t_order WHERE t_order.order_id * ?" db-types="MySQL" />
<sql-case id="select_where_with_bit_expr_with_slash" value="SELECT * FROM
t_order WHERE t_order.order_id / ?" db-types="MySQL" />
@@ -70,7 +70,7 @@
<sql-case id="select_where_with_simple_expr_with_literals" value="SELECT *
FROM t_order WHERE ? < order_id" db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_column" value="SELECT *
FROM t_order WHERE t_order.order_id" db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_function_call"
value="SELECT * FROM t_order WHERE now() < order_id" db-types="MySQL" />
- <sql-case id="select_where_with_simple_expr_with_collate" value="SELECT *
FROM t_order WHERE order_id collate utf8mb4_0900_ai_ci" db-types="MySQL" />
+ <sql-case id="select_where_with_simple_expr_with_collate" value="SELECT *
FROM t_order WHERE order_id collate utf8mb4_0900_ai_ci" db-types="MySQL,Presto"
/>
<sql-case id="select_where_with_simple_expr_with_variable" value="SELECT *
FROM t_order WHERE @@max_connections < order_id" db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_plus" value="SELECT *
FROM t_order WHERE ? + t_order.order_id" db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_minus" value="SELECT *
FROM t_order WHERE ? - t_order.order_id" db-types="MySQL" />
@@ -79,11 +79,11 @@
<sql-case id="select_where_with_simple_expr_with_binary" value="SELECT *
FROM t_order WHERE BINARY t_order.order_id" db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_binary_value"
value="SELECT * FROM t_order WHERE t_order.order_id = BINARY ?"
db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_row" value="SELECT * FROM
t_order WHERE ROW(?, now()) = (order_id, status)" db-types="MySQL" />
- <sql-case id="select_where_with_simple_expr_with_subquery" value="SELECT *
FROM t_order WHERE (SELECT order_id FROM t_order_item WHERE status > ?)"
db-types="MySQL" />
- <sql-case id="select_where_with_simple_expr_with_exists_subquery"
value="SELECT * FROM t_order WHERE EXISTS (SELECT order_id FROM t_order_item
WHERE status > ? )" db-types="MySQL" />
+ <sql-case id="select_where_with_simple_expr_with_subquery" value="SELECT *
FROM t_order WHERE (SELECT order_id FROM t_order_item WHERE status > ?)"
db-types="MySQL,Presto" />
+ <sql-case id="select_where_with_simple_expr_with_exists_subquery"
value="SELECT * FROM t_order WHERE EXISTS (SELECT order_id FROM t_order_item
WHERE status > ? )" db-types="MySQL,Presto" />
<sql-case id="select_where_with_simple_expr_with_odbc_escape_syntax"
value="SELECT * FROM t_order WHERE {ts ?}" db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_json_extract_sign"
value="SELECT * FROM t_order WHERE order_id ->"$[1]""
db-types="MySQL" />
- <sql-case id="select_where_with_simple_expr_with_json_member_of"
value="SELECT * FROM t_order WHERE order_id member of("[1,2,3]")"
db-types="MySQL" />
+ <sql-case id="select_where_with_simple_expr_with_json_member_of"
value="SELECT * FROM t_order WHERE order_id member of("[1,2,3]")"
db-types="MySQL,Presto" />
<sql-case
id="select_where_with_simple_expr_with_json_unquote_extract_sign" value="SELECT
* FROM t_order WHERE order_id ->> "$[1]"" db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_json_contains"
value="SELECT * FROM t_order WHERE JSON_CONTAINS(order_msg -> '$[*].code', 'x',
'$') " db-types="MySQL" />
<sql-case id="select_where_with_simple_expr_with_json_contains_and_limit"
value="SELECT id, order_info->'$.id' FROM t_order where
json_contains(order_info, ?, '$.id') limit ?, ?" db-types="MySQL" />
diff --git
a/test/it/parser/src/main/resources/sql/supported/dml/select-order-by.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select-order-by.xml
index 4b7848768fc..ab377693811 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-order-by.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-order-by.xml
@@ -34,5 +34,5 @@
<sql-case id="select_order_by_with_table_star_table_name" value="SELECT
t_order.* FROM t_order ORDER BY t_order.order_id" db-types="H2,MySQL" />
<sql-case id="select_order_by_with_star_no_table_alias" value="SELECT *
FROM t_order ORDER BY order_id" db-types="H2,MySQL" />
<sql-case id="select_order_by_with_table_star_without_table_name"
value="SELECT i.*, o.* FROM t_order o JOIN t_order_item i ON o.user_id =
i.user_id AND o.order_id = i.order_id ORDER BY item_id" db-types="H2,MySQL" />
- <sql-case id="select_order_by_expression_binary_operation" value="select *
from t_order order by 1+1" db-types="MySQL" />
+ <sql-case id="select_order_by_expression_binary_operation" value="select *
from t_order order by 1+1" db-types="MySQL,Presto" />
</sql-cases>
diff --git
a/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
b/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
index fa71c12b293..280b4353354 100644
---
a/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
+++
b/test/it/parser/src/main/resources/sql/supported/dml/select-special-function.xml
@@ -19,7 +19,7 @@
<sql-cases>
<sql-case id="select_group_concat_with_order_by" value="SELECT
GROUP_CONCAT(status ORDER BY status) FROM t_order" db-types="MySQL,Doris" />
<sql-case id="select_group_concat_with_order_by_for_opengauss"
value="SELECT GROUP_CONCAT(status ORDER BY status) FROM t_order"
db-types="openGauss" />
- <sql-case id="select_window_function" value="SELECT order_id, ROW_NUMBER()
OVER() FROM t_order" db-types="MySQL" />
+ <sql-case id="select_window_function" value="SELECT order_id, ROW_NUMBER()
OVER() FROM t_order" db-types="MySQL,Presto" />
<sql-case id="select_cast_function" value="SELECT CAST('1' AS UNSIGNED)"
db-types="MySQL" />
<sql-case id="select_cast_as_year" value="SELECT CAST(-1.1 AS YEAR)"
db-types="MySQL" />
<sql-case id="select_cast" value="SELECT CAST(c AT TIME ZONE 'UTC' AS
DATETIME)" db-types="MySQL" />