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 f6cd5df9795 Add SQL parser test cases for ClickHouse (#37603)
f6cd5df9795 is described below
commit f6cd5df979596570d67a889a47759cd6bc058323
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Jan 1 15:51:39 2026 +0800
Add SQL parser test cases for ClickHouse (#37603)
---
.../src/main/resources/case/dml/clickhouse.xml | 227 ++++++++++++++++++++-
.../resources/sql/supported/dml/clickhouse.xml | 8 +
2 files changed, 234 insertions(+), 1 deletion(-)
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 65a54048613..85d40f2170c 100644
--- a/test/it/parser/src/main/resources/case/dml/clickhouse.xml
+++ b/test/it/parser/src/main/resources/case/dml/clickhouse.xml
@@ -522,4 +522,229 @@
</assignment>
</set>
</update>
-</sql-parser-test-cases>
\ No newline at end of file
+
+ <select sql-case-id="clickhouse_select_safe_eq_any">
+ <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="39">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="39">
+ <left>
+ <column name="status" start-index="28" stop-index="33"
/>
+ </left>
+ <operator><=></operator>
+ <right>
+ <literal-expression value="1" start-index="39"
stop-index="39" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="clickhouse_select_not_between_not_in">
+ <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="80">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="80">
+ <left>
+ <between-expression start-index="28" stop-index="54">
+ <not>true</not>
+ <left>
+ <column name="price" start-index="28"
stop-index="32" />
+ </left>
+ <between-expr>
+ <literal-expression value="10"
start-index="46" stop-index="47" />
+ </between-expr>
+ <and-expr>
+ <literal-expression value="20"
start-index="53" stop-index="54" />
+ </and-expr>
+ </between-expression>
+ </left>
+ <operator>AND</operator>
+ <right>
+ <in-expression start-index="60" stop-index="80">
+ <not>true</not>
+ <left>
+ <column name="user_id" start-index="60"
stop-index="66" />
+ </left>
+ <right>
+ <list-expression start-index="75"
stop-index="80">
+ <items>
+ <literal-expression value="4"
start-index="76" stop-index="76" />
+ </items>
+ <items>
+ <literal-expression value="5"
start-index="79" stop-index="79" />
+ </items>
+ </list-expression>
+ </right>
+ </in-expression>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </select>
+
+ <select sql-case-id="clickhouse_select_like_escape_true">
+ <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="43">
+ <expr>
+ <binary-operation-expression start-index="28" stop-index="43">
+ <left>
+ <column name="status" start-index="28" stop-index="33"
/>
+ </left>
+ <operator>LIKE</operator>
+ <right>
+ <list-expression start-index="40" stop-index="43">
+ <items>
+ <literal-expression value="A%"
start-index="40" stop-index="43" />
+ </items>
+ </list-expression>
+ </right>
+ </binary-operation-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">
+ <expr>
+ <binary-operation-expression start-index="7"
stop-index="33">
+ <left>
+ <column name="order_time" start-index="7"
stop-index="16" />
+ </left>
+ <operator>+</operator>
+ <right>
+ <common-expression text="INTERVAL2DAY"
literal-text="INTERVAL2DAY" start-index="20" stop-index="33" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </expression-projection>
+ <expression-projection alias="amount_decimal" text="CAST(amount AS
DATETIME64(10, 2))" start-index="54" stop-index="104">
+ <expr>
+ <function function-name="CAST" text="CAST(amount AS
DATETIME64(10, 2))" start-index="54" stop-index="86">
+ <parameter>
+ <column name="amount" start-index="59"
stop-index="64" />
+ </parameter>
+ <parameter>
+ <data-type value="DATETIME64" start-index="69"
stop-index="85">
+ <data-type-length precision="10" scale="2"
start-index="80" stop-index="85" />
+ </data-type>
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ <expression-projection alias="wrapped_status" text="(status) AS
'wrapped_status'" start-index="107" stop-index="134">
+ <expr>
+ <column name="status" start-index="108" stop-index="113" />
+ </expr>
+ </expression-projection>
+ </projections>
+ <from>
+ <simple-table name="t_order" start-index="141" stop-index="147" />
+ </from>
+ </select>
+
+ <select sql-case-id="clickhouse_select_right_join_subquery">
+ <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="96">
+ <left>
+ <subquery-table alias="sub" start-index="14"
stop-index="47">
+ <subquery start-index="14" stop-index="43">
+ <select>
+ <projections start-index="22" stop-index="29">
+ <column-projection name="order_id"
start-index="22" stop-index="29" />
+ </projections>
+ <from start-index="31" stop-index="42">
+ <simple-table name="t_order"
start-index="36" stop-index="42" />
+ </from>
+ </select>
+ </subquery>
+ </subquery-table>
+ </left>
+ <right>
+ <simple-table name="t_order_item" alias="i"
start-index="54" stop-index="67" />
+ </right>
+ <on-condition>
+ <binary-operation-expression start-index="72"
stop-index="96">
+ <left>
+ <column name="order_id" start-index="72"
stop-index="83">
+ <owner name="sub" start-index="72"
stop-index="74" />
+ </column>
+ </left>
+ <operator>=</operator>
+ <right>
+ <column name="order_id" start-index="87"
stop-index="96">
+ <owner name="i" start-index="87"
stop-index="87" />
+ </column>
+ </right>
+ </binary-operation-expression>
+ </on-condition>
+ </join-table>
+ </from>
+ </select>
+
+ <select sql-case-id="clickhouse_select_comma_join">
+ <projections start-index="7" stop-index="7">
+ <shorthand-projection start-index="7" stop-index="7" />
+ </projections>
+ <from>
+ <join-table join-type="COMMA" start-index="14" stop-index="38">
+ <left>
+ <simple-table name="t_order" alias="o" start-index="14"
stop-index="22" />
+ </left>
+ <right>
+ <simple-table name="t_order_item" alias="i"
start-index="25" stop-index="38" />
+ </right>
+ </join-table>
+ </from>
+ </select>
+
+ <update sql-case-id="clickhouse_update_set_default">
+ <table start-index="7" stop-index="13">
+ <simple-table name="t_order" start-index="7" stop-index="13" />
+ </table>
+ <set start-index="15" stop-index="34">
+ <assignment start-index="19" stop-index="34">
+ <column name="status" start-index="19" stop-index="24" />
+ <assignment-value>
+ <column name="DEFAULT" start-index="28" stop-index="34" />
+ </assignment-value>
+ </assignment>
+ </set>
+ <where start-index="36" stop-index="53">
+ <expr>
+ <binary-operation-expression start-index="42" stop-index="53">
+ <left>
+ <column name="order_id" start-index="42"
stop-index="49" />
+ </left>
+ <operator>=</operator>
+ <right>
+ <literal-expression value="1" start-index="53"
stop-index="53" />
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </where>
+ </update>
+
+ <delete sql-case-id="clickhouse_delete_without_where">
+ <table name="t_order" start-index="12" stop-index="18" />
+ </delete>
+</sql-parser-test-cases>
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 b7d90cd53bd..09d3e8822d3 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
@@ -30,4 +30,12 @@
<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_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_update_set_default" value="UPDATE t_order SET
status = DEFAULT WHERE order_id = 1" db-types="ClickHouse" />
+ <sql-case id="clickhouse_delete_without_where" value="ALTER TABLE t_order
DELETE" db-types="ClickHouse" />
</sql-cases>