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 5a379b4d86e Add more SQL parser test cases on ClickHouse (#37608)
5a379b4d86e is described below
commit 5a379b4d86ed5db4c01fa829dd17641217b3b9fb
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Jan 1 20:02:19 2026 +0800
Add more SQL parser test cases on ClickHouse (#37608)
---
.../src/main/resources/case/dml/clickhouse.xml | 91 ++++++++++++++++++++++
.../resources/sql/supported/dml/clickhouse.xml | 5 ++
2 files changed, 96 insertions(+)
diff --git a/test/it/parser/src/main/resources/case/dml/clickhouse.xml
b/test/it/parser/src/main/resources/case/dml/clickhouse.xml
index b7db34f579e..4850562a228 100644
--- a/test/it/parser/src/main/resources/case/dml/clickhouse.xml
+++ b/test/it/parser/src/main/resources/case/dml/clickhouse.xml
@@ -482,6 +482,38 @@
</where>
</select>
+ <select sql-case-id="clickhouse_select_subquery_compare">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <where start-index="22" stop-index="46">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="46">
+ <left>
+ <column name="amount" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>=</operator>
+ <right>
+ <subquery start-index="37" stop-index="46">
+ <select>
+ <projections start-index="45" stop-index="45">
+ <expression-projection text="1"
start-index="45" stop-index="45">
+ <expr>
+ <literal-expression value="1"
start-index="45" stop-index="45" />
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+ </subquery>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
<select sql-case-id="clickhouse_select_param_projection" parameters="1">
<projections start-index="7" stop-index="22">
<expression-projection alias="param_alias" text="?"
start-index="7" stop-index="22">
@@ -619,6 +651,31 @@
</where>
</select>
+ <select sql-case-id="clickhouse_select_between_plain">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="14" stop-index="20" />
+ </from>
+ <where start-index="22" stop-index="49">
+ <expr>
+ <between-expression start-index="28" stop-index="49">
+ <not>false</not>
+ <left>
+ <column name="amount" start-index="28" stop-index="33"
/>
+ </left>
+ <between-expr>
+ <literal-expression value="1" start-index="43"
stop-index="43" />
+ </between-expr>
+ <and-expr>
+ <literal-expression value="5" start-index="49"
stop-index="49" />
+ </and-expr>
+ </between-expression>
+ </expr>
+ </where>
+ </select>
+
<select sql-case-id="clickhouse_select_interval_and_cast_decimal">
<projections start-index="7" stop-index="134">
<expression-projection alias="interval_added" text="order_time +
INTERVAL 2 DAY" start-index="7" stop-index="51">
@@ -717,6 +774,40 @@
</from>
</select>
+ <select sql-case-id="clickhouse_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" 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="clickhouse_select_count_star">
+ <projections start-index="7" stop-index="14">
+ <aggregation-projection type="COUNT" expression="COUNT(*)"
start-index="7" stop-index="14" />
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="21" stop-index="27" />
+ </from>
+ </select>
+
+ <select sql-case-id="clickhouse_select_all_projection">
+ <projections start-index="11" stop-index="16">
+ <column-projection name="amount" start-index="11" stop-index="16"
/>
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="23" stop-index="29" />
+ </from>
+ </select>
+
<select sql-case-id="clickhouse_select_or_boolean">
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/clickhouse.xml
b/test/it/parser/src/main/resources/sql/supported/dml/clickhouse.xml
index 5bceb451be4..e54e539d389 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/clickhouse.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/clickhouse.xml
@@ -27,15 +27,20 @@
<sql-case id="clickhouse_select_not_predicate" value="SELECT * FROM
t_order WHERE NOT (status > 0)" db-types="ClickHouse" />
<sql-case id="clickhouse_select_not_like" value="SELECT * FROM t_order
WHERE status NOT LIKE 'A%'" db-types="ClickHouse" />
<sql-case id="clickhouse_select_in_list_and_subquery" value="SELECT * FROM
t_order WHERE user_id IN (1, 2, 3) AND order_id IN (SELECT order_id FROM
t_order_item) AND status IS NOT NULL" db-types="ClickHouse" />
+ <sql-case id="clickhouse_select_subquery_compare" value="SELECT * FROM
t_order WHERE amount = (SELECT 1)" db-types="ClickHouse" />
<sql-case id="clickhouse_select_param_projection" value="SELECT ? AS
param_alias" db-types="ClickHouse" case-types="PLACEHOLDER" />
<sql-case id="clickhouse_select_subquery_projection" value="SELECT (SELECT
1) AS sub_val FROM t_order" db-types="ClickHouse" />
<sql-case id="clickhouse_update_without_where" value="UPDATE t_order SET
status = 0" db-types="ClickHouse" />
<sql-case id="clickhouse_select_safe_eq_any" value="SELECT * FROM t_order
WHERE status <=> 1" db-types="ClickHouse" />
<sql-case id="clickhouse_select_not_between_not_in" value="SELECT * FROM
t_order WHERE price NOT BETWEEN 10 AND 20 AND user_id NOT IN (4, 5)"
db-types="ClickHouse" />
+ <sql-case id="clickhouse_select_between_plain" value="SELECT * FROM
t_order WHERE amount BETWEEN 1 AND 5" db-types="ClickHouse" />
<sql-case id="clickhouse_select_like_escape_true" value="SELECT * FROM
t_order WHERE status LIKE 'A%'" db-types="ClickHouse" />
<sql-case id="clickhouse_select_interval_and_cast_decimal" value="SELECT
order_time + INTERVAL 2 DAY AS interval_added, CAST(amount AS DATETIME64(10,
2)) AS amount_decimal, (status) AS 'wrapped_status' FROM t_order"
db-types="ClickHouse" />
<sql-case id="clickhouse_select_right_join_subquery" value="SELECT * FROM
(SELECT order_id FROM t_order) sub JOIN t_order_item i ON sub.order_id =
i.order_id" db-types="ClickHouse" />
<sql-case id="clickhouse_select_comma_join" value="SELECT * FROM t_order
o, t_order_item i" db-types="ClickHouse" />
+ <sql-case id="clickhouse_select_natural_join" value="SELECT * FROM t_order
NATURAL JOIN t_order_item" db-types="ClickHouse" />
+ <sql-case id="clickhouse_select_count_star" value="SELECT COUNT(*) FROM
t_order" db-types="ClickHouse" />
+ <sql-case id="clickhouse_select_all_projection" value="SELECT ALL amount
FROM t_order" db-types="ClickHouse" />
<sql-case id="clickhouse_select_or_boolean" value="SELECT * FROM t_order
WHERE status IS TRUE OR amount > 100" db-types="ClickHouse" />
<sql-case id="clickhouse_select_is_false" value="SELECT * FROM t_order
WHERE is_deleted IS FALSE" db-types="ClickHouse" />
<sql-case id="clickhouse_select_parenthesized_right_cross_join"
value="SELECT * FROM (t_order o RIGHT JOIN t_order_item i ON o.order_id =
i.order_id) CROSS JOIN t_user u" db-types="ClickHouse" />