You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/01/08 15:08:44 UTC

(shardingsphere) branch master updated: Add more test cases on Doris SQL parser (#37692)

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 31e68a9bda1 Add more test cases on Doris SQL parser (#37692)
31e68a9bda1 is described below

commit 31e68a9bda1617ca03c85a7583dc2747980f39a2
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jan 8 23:08:38 2026 +0800

    Add more test cases on Doris SQL parser (#37692)
    
    * Parameterize SQL parse/route advice tests
    
    * Add more test cases on Doris SQL parser
---
 .../parser/src/main/resources/case/dml/select.xml  | 78 ++++++++++++++++++++++
 .../main/resources/sql/supported/dml/select.xml    |  4 ++
 2 files changed, 82 insertions(+)

diff --git a/test/it/parser/src/main/resources/case/dml/select.xml b/test/it/parser/src/main/resources/case/dml/select.xml
index 7ce9e494486..5d5a82dc724 100644
--- a/test/it/parser/src/main/resources/case/dml/select.xml
+++ b/test/it/parser/src/main/resources/case/dml/select.xml
@@ -6803,6 +6803,84 @@
         </order-by>
     </select>
 
+    <select sql-case-id="select_window_named_partition_doris">
+        <projections start-index="7" stop-index="38" literal-start-index="7" literal-stop-index="38">
+            <aggregation-projection type="SUM" expression="SUM(sales) OVER w" alias="total_sales" start-index="7" stop-index="23" literal-start-index="7" literal-stop-index="23" />
+        </projections>
+        <from>
+            <simple-table name="orders" start-index="45" stop-index="50" literal-start-index="45" literal-stop-index="50" />
+        </from>
+        <window start-index="52" stop-index="102">
+            <window-item start-index="59" stop-index="102">
+                <window-name>w</window-name>
+                <partition-by>
+                    <expression-projection text="region" start-index="78" stop-index="83" literal-start-index="78" literal-stop-index="83">
+                        <expr>
+                            <column name="region" start-index="78" stop-index="83" literal-start-index="78" literal-stop-index="83" />
+                        </expr>
+                    </expression-projection>
+                </partition-by>
+                <order-by>
+                    <column-item name="order_id" order-direction="ASC" start-index="94" stop-index="101" literal-start-index="94" literal-stop-index="101" />
+                </order-by>
+            </window-item>
+        </window>
+    </select>
+
+    <select sql-case-id="select_window_frame_lag_doris">
+        <projections start-index="7" stop-index="124" literal-start-index="7" literal-stop-index="124">
+            <expression-projection text="LAG(amount, 1, 0) OVER (PARTITION BY customer_id ORDER BY tx_time ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)" alias="lag_amt" start-index="7" stop-index="124" literal-start-index="7" literal-stop-index="124">
+                <expr>
+                    <function function-name="LAG" text="LAG(amount, 1, 0) OVER (PARTITION BY customer_id ORDER BY tx_time ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)" start-index="7" stop-index="113" literal-start-index="7" literal-stop-index="113">
+                        <parameter>
+                            <column name="amount" start-index="11" stop-index="16" literal-start-index="11" literal-stop-index="16" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+        <from>
+            <simple-table name="payments" start-index="131" stop-index="138" literal-start-index="131" literal-stop-index="138" />
+        </from>
+    </select>
+
+    <select sql-case-id="select_first_value_doris">
+        <projections start-index="7" stop-index="66" literal-start-index="7" literal-stop-index="66">
+            <expression-projection text="FIRST_VALUE(price) OVER (ORDER BY created_at)" alias="first_price" start-index="7" stop-index="66" literal-start-index="7" literal-stop-index="66">
+                <expr>
+                    <function function-name="FIRST_VALUE" text="FIRST_VALUE(price) OVER (ORDER BY created_at)" start-index="7" stop-index="51" literal-start-index="7" literal-stop-index="51">
+                        <parameter>
+                            <column name="price" start-index="19" stop-index="23" literal-start-index="19" literal-stop-index="23" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+        <from>
+            <simple-table name="product_prices" start-index="73" stop-index="86" literal-start-index="73" literal-stop-index="86" />
+        </from>
+    </select>
+
+    <select sql-case-id="select_nth_value_doris">
+        <projections start-index="7" stop-index="63" literal-start-index="7" literal-stop-index="63">
+            <expression-projection text="NTH_VALUE(score, 2) OVER (ORDER BY score)" alias="second_score" start-index="7" stop-index="63" literal-start-index="7" literal-stop-index="63">
+                <expr>
+                    <function function-name="NTH_VALUE" text="NTH_VALUE(score, 2) OVER (ORDER BY score)" start-index="7" stop-index="47" literal-start-index="7" literal-stop-index="47">
+                        <parameter>
+                            <column name="score" start-index="17" stop-index="21" literal-start-index="17" literal-stop-index="21" />
+                        </parameter>
+                        <parameter>
+                            <literal-expression value="2" start-index="24" stop-index="24" literal-start-index="24" literal-stop-index="24" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+        <from>
+            <simple-table name="rankings" start-index="70" stop-index="77" literal-start-index="70" literal-stop-index="77" />
+        </from>
+    </select>
+
     <select sql-case-id="select_with_percentile_functions">
         <projections start-index="7" stop-index="163" literal-start-index="7" literal-stop-index="163">
             <column-projection name="department_id" start-index="7" stop-index="19" literal-start-index="7" literal-stop-index="19" />
diff --git a/test/it/parser/src/main/resources/sql/supported/dml/select.xml b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
index 8264a07a440..b7a75296b97 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select.xml
@@ -236,6 +236,10 @@
     <sql-case id="select_with_lead_and_lag_function" value="SELECT hire_date, LAG(hire_date, 1) OVER (ORDER BY hire_date) AS LAG1, LEAD(hire_date, 1) OVER (ORDER BY hire_date) AS LEAD1 FROM employees WHERE department_id = 30 ORDER BY hire_date;" db-types="Oracle,MySQL" />
     <sql-case id="select_with_connect_by_root" value="SELECT CONNECT_BY_ROOT last_name 'Manager' FROM employees CONNECT BY PRIOR employee_id = manager_id" db-types="Oracle" />
     <sql-case id="select_with_ntile_function" value="SELECT NTILE(4) OVER (ORDER BY salary DESC) AS quartile FROM employees WHERE department_id = 100 ORDER BY last_name" db-types="Oracle,MySQL,Doris" />
+    <sql-case id="select_window_named_partition_doris" value="SELECT SUM(sales) OVER w AS total_sales FROM orders WINDOW w AS (PARTITION BY region ORDER BY order_id)" db-types="Doris" />
+    <sql-case id="select_window_frame_lag_doris" value="SELECT LAG(amount, 1, 0) OVER (PARTITION BY customer_id ORDER BY tx_time ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS lag_amt FROM payments" db-types="Doris" />
+    <sql-case id="select_first_value_doris" value="SELECT FIRST_VALUE(price) OVER (ORDER BY created_at) AS first_price FROM product_prices" db-types="Doris" />
+    <sql-case id="select_nth_value_doris" value="SELECT NTH_VALUE(score, 2) OVER (ORDER BY score) AS second_score FROM rankings" db-types="Doris" />
     <sql-case id="select_from_dual_doris" value="SELECT 1 FROM DUAL" db-types="Doris" />
     <sql-case id="select_date_literal_doris" value="SELECT DATE '2020-01-01'" db-types="Doris" />
     <sql-case id="select_hex_literal_doris" value="SELECT 0x1AF" db-types="Doris" />