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 30a4b9f2f96 Add more SQL parser test cases on ClickHouse (#37613)
30a4b9f2f96 is described below

commit 30a4b9f2f9615f90c5d07a8b5fbae4e89345b713
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Jan 1 23:48:11 2026 +0800

    Add more SQL parser test cases on ClickHouse (#37613)
    
    * Add more SQL parser test cases on ClickHouse
    
    * Add more SQL parser test cases on ClickHouse
---
 .../src/main/resources/case/dml/clickhouse.xml     | 138 +++++++++++++++++++++
 .../resources/sql/supported/dml/clickhouse.xml     |   6 +
 .../main/resources/sql/unsupported/unsupported.xml |   9 ++
 3 files changed, 153 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 3648ba8a606..1b28d833354 100644
--- a/test/it/parser/src/main/resources/case/dml/clickhouse.xml
+++ b/test/it/parser/src/main/resources/case/dml/clickhouse.xml
@@ -1029,4 +1029,142 @@
     <delete sql-case-id="clickhouse_delete_without_where">
         <table name="t_order" start-index="12" stop-index="18" />
     </delete>
+    
+    <select sql-case-id="clickhouse_select_is_not_null">
+        <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="45">
+            <expr>
+                <binary-operation-expression start-index="28" stop-index="45">
+                    <left>
+                        <column name="status" start-index="28" stop-index="33" 
/>
+                    </left>
+                    <operator>IS</operator>
+                    <right>
+                        <literal-expression value="NOT NULL" start-index="38" 
stop-index="45" />
+                    </right>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
+    
+    <select sql-case-id="clickhouse_select_safe_eq_subquery">
+        <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="48">
+            <expr>
+                <binary-operation-expression start-index="28" stop-index="48">
+                    <left>
+                        <column name="status" start-index="28" stop-index="33" 
/>
+                    </left>
+                    <operator>&lt;=&gt;</operator>
+                    <right>
+                        <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>
+                    </right>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
+    
+    <select sql-case-id="clickhouse_select_literal_mix" parameters="1">
+        <projections start-index="7" stop-index="32">
+            <expression-projection text="abc" start-index="7" stop-index="11">
+                <expr>
+                    <literal-expression value="abc" start-index="7" 
stop-index="11" />
+                </expr>
+            </expression-projection>
+            <expression-projection text="123" start-index="14" stop-index="16">
+                <expr>
+                    <literal-expression value="123" start-index="14" 
stop-index="16" />
+                </expr>
+            </expression-projection>
+            <expression-projection text="true" start-index="19" 
stop-index="22">
+                <expr>
+                    <literal-expression value="true" start-index="19" 
stop-index="22" />
+                </expr>
+            </expression-projection>
+            <expression-projection text="X'1A'" start-index="25" 
stop-index="29">
+                <expr>
+                    <common-expression text="X'1A'" start-index="25" 
stop-index="29" />
+                </expr>
+            </expression-projection>
+            <expression-projection text="?" start-index="32" stop-index="32">
+                <expr>
+                    <parameter-marker-expression parameter-index="0" 
start-index="32" stop-index="32" />
+                    <literal-expression value="1" start-index="32" 
stop-index="32" />
+                </expr>
+            </expression-projection>
+        </projections>
+        <from>
+            <simple-table name="t_order" start-index="39" stop-index="45" />
+        </from>
+    </select>
+    
+    <select sql-case-id="clickhouse_select_interval_plus">
+        <projections start-index="7" stop-index="45">
+            <expression-projection alias="next_day" text="order_time + 
INTERVAL 1 DAY" start-index="7" stop-index="45">
+                <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="INTERVAL1DAY" 
literal-text="INTERVAL1DAY" start-index="20" stop-index="33" />
+                        </right>
+                    </binary-operation-expression>
+                </expr>
+            </expression-projection>
+        </projections>
+        <from>
+            <simple-table name="t_order" start-index="52" stop-index="58" />
+        </from>
+    </select>
+    
+    <select sql-case-id="clickhouse_select_sum_distinct_expr">
+        <projections start-index="7" stop-index="30">
+            <aggregation-distinct-projection type="SUM" 
expression="SUM(DISTINCT amount + 1)" distinct-inner-expression="amount+1" 
start-index="7" stop-index="30" />
+        </projections>
+        <from>
+            <simple-table name="t_order" start-index="37" stop-index="43" />
+        </from>
+    </select>
+    
+    <select sql-case-id="clickhouse_select_cast_literal">
+        <projections start-index="7" stop-index="21">
+            <expression-projection text="CAST(1 AS INT8)" start-index="7" 
stop-index="21">
+                <expr>
+                    <function function-name="CAST" text="CAST(1 AS INT8)" 
start-index="7" stop-index="21">
+                        <parameter>
+                            <literal-expression value="1" start-index="12" 
stop-index="12" />
+                        </parameter>
+                        <parameter>
+                            <data-type value="INT8" start-index="17" 
stop-index="20" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+        <from>
+            <simple-table name="t_order" start-index="28" stop-index="34" />
+        </from>
+    </select>
 </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 13504b7cfc4..8041cd11c66 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
@@ -50,4 +50,10 @@
     <sql-case id="clickhouse_select_hex_bit_literals" value="SELECT * FROM 
t_order WHERE hex_col = X'1A' AND bit_col = B'101'" 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-case id="clickhouse_select_is_not_null" value="SELECT * FROM t_order 
WHERE status IS NOT NULL" db-types="ClickHouse" />
+    <sql-case id="clickhouse_select_safe_eq_subquery" value="SELECT * FROM 
t_order WHERE status &lt;=&gt; (SELECT 1)" db-types="ClickHouse" />
+    <sql-case id="clickhouse_select_literal_mix" value="SELECT 'abc', 123, 
TRUE, X'1A', ? FROM t_order" db-types="ClickHouse" case-types="PLACEHOLDER" />
+    <sql-case id="clickhouse_select_interval_plus" value="SELECT order_time + 
INTERVAL 1 DAY AS next_day FROM t_order" db-types="ClickHouse" />
+    <sql-case id="clickhouse_select_sum_distinct_expr" value="SELECT 
SUM(DISTINCT amount + 1) FROM t_order" db-types="ClickHouse" />
+    <sql-case id="clickhouse_select_cast_literal" value="SELECT CAST(1 AS 
INT8) FROM t_order" db-types="ClickHouse" />
 </sql-cases>
diff --git a/test/it/parser/src/main/resources/sql/unsupported/unsupported.xml 
b/test/it/parser/src/main/resources/sql/unsupported/unsupported.xml
index adfbcb535a9..4f13bf6f95a 100644
--- a/test/it/parser/src/main/resources/sql/unsupported/unsupported.xml
+++ b/test/it/parser/src/main/resources/sql/unsupported/unsupported.xml
@@ -28,6 +28,15 @@
     <sql-case id="select_case_when" value="select relname,c.oid = oldoid as 
orig_oid,case relfilenode when 0 then 'none' when c.oid then 'own' when 
oldfilenode then 'orig' else 'OTHER' end as storage, obj_description(c.oid, 
'pg_class') as desc from pg_class c left join old_oids using (relname) where 
relname like 'at_partitioned%' order by relname" db-types="PostgreSQL" />
     <sql-case id="select_like" value="select conname, obj_description(oid, 
'pg_constraint') as desc from pg_constraint where conname like 
'at_partitioned%' order by conname" db-types="PostgreSQL" />
     <sql-case id="select_keyword" value="select relname,c.oid = oldoid as 
orig_oid,case relfilenode when 0 then 'none' when c.oid then 'own' when 
oldfilenode then 'orig' else 'OTHER' end as storage, obj_description(c.oid, 
'pg_class') as desc from pg_class c left join old_oids using (relname) where 
relname like 'at_partitioned%' order by relname" db-types="PostgreSQL" />
+    <sql-case id="unsupported_date_literal_for_clickhouse" value="SELECT DATE 
'2024-01-01'" db-types="ClickHouse" />
+    <sql-case id="unsupported_merge_for_clickhouse" value="MERGE INTO t_order 
AS o USING t_order_item AS i ON o.order_id = i.order_id WHEN MATCHED THEN 
UPDATE SET status = 1" db-types="ClickHouse" />
+    <sql-case id="unsupported_create_table_for_clickhouse" value="CREATE TABLE 
t_order (order_id INT)" db-types="ClickHouse" />
+    <sql-case id="unsupported_commit_for_clickhouse" value="COMMIT" 
db-types="ClickHouse" />
+    <sql-case id="unsupported_grant_for_clickhouse" value="GRANT SELECT ON 
t_order TO user1" db-types="ClickHouse" />
+    <sql-case id="unsupported_show_tables_for_clickhouse" value="SHOW TABLES" 
db-types="ClickHouse" />
+    <sql-case id="unsupported_function_call_for_clickhouse" value="SELECT 
FUNCTION()" db-types="ClickHouse" />
+    <sql-case id="unsupported_lock_tables_for_clickhouse" value="LOCK TABLES 
t_order READ" db-types="ClickHouse" />
+    <sql-case id="unsupported_unlock_tables_for_clickhouse" value="UNLOCK 
TABLES" db-types="ClickHouse" />
     <sql-case id="unsupported_select_case_for_opengauss_13" value="select 
count(*) from partition_list_tab01 partition for ('20');" db-types="openGauss" 
/>
     <sql-case id="unsupported_select_case_for_opengauss_14" value="select 
count(*) from partition_list_tab partition for ('10');" db-types="openGauss" />
     <sql-case id="unsupported_select_case_for_opengauss_15" value="select 
count(*) from partition_list_tab partition for ('20');" db-types="openGauss" />

Reply via email to