This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 91aeaf6b2142a5e59f2f6f4aaa2bc75f1418135d
Author: Jerry Hu <mrh...@gmail.com>
AuthorDate: Wed Aug 23 11:23:00 2023 +0800

    [fix](window_function) wrong order by range (#23346)
---
 be/src/vec/exec/vanalytic_eval_node.cpp                  |  2 +-
 .../data/nereids_syntax_p0/window_function.out           | 16 ++++++++++++++++
 .../suites/nereids_syntax_p0/window_function.groovy      |  7 +++++++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/exec/vanalytic_eval_node.cpp 
b/be/src/vec/exec/vanalytic_eval_node.cpp
index 09c64e752d..c31e65b8c1 100644
--- a/be/src/vec/exec/vanalytic_eval_node.cpp
+++ b/be/src/vec/exec/vanalytic_eval_node.cpp
@@ -487,7 +487,7 @@ BlockRowPos VAnalyticEvalNode::_compare_row_to_find_end(int 
idx, BlockRowPos sta
     }
     //binary search, set start and end pos
     int64_t start_pos = start_init_row_num;
-    int64_t end_pos = _input_blocks[start.block_num].rows() - 1;
+    int64_t end_pos = _input_blocks[start.block_num].rows();
     //if end_block_num haven't moved, only start_block_num go to the end block
     //so could use the end.row_num for binary search
     if (start.block_num == end.block_num) {
diff --git a/regression-test/data/nereids_syntax_p0/window_function.out 
b/regression-test/data/nereids_syntax_p0/window_function.out
index a3a30becb9..5e91a4682d 100644
--- a/regression-test/data/nereids_syntax_p0/window_function.out
+++ b/regression-test/data/nereids_syntax_p0/window_function.out
@@ -274,6 +274,22 @@
 7      3       4
 7      3       4
 
+-- !range --
+1      8
+1      8
+1      8
+1      8
+1      8
+1      8
+1      8
+1      8
+2      20
+2      20
+2      20
+2      20
+2      20
+2      20
+
 -- !cte --
 1      8
 1      8
diff --git a/regression-test/suites/nereids_syntax_p0/window_function.groovy 
b/regression-test/suites/nereids_syntax_p0/window_function.groovy
index 332bd070e3..538038c774 100644
--- a/regression-test/suites/nereids_syntax_p0/window_function.groovy
+++ b/regression-test/suites/nereids_syntax_p0/window_function.groovy
@@ -135,6 +135,13 @@ suite("window_function") {
         ) sub 
     """
 
+    sql """ set batch_size = 3; """
+    sql """ set parallel_pipeline_task_num = 8; """
+
+    order_qt_range """
+        SELECT c1, (sum(c1) over  (ORDER BY c1 range between UNBOUNDED 
preceding and CURRENT ROW)) FROM window_test;
+    """
+
     order_qt_cte """
         WITH cte as (select c1 as x from window_test) 
         SELECT x, (sum(x) over  (ORDER BY x range between UNBOUNDED preceding 
and CURRENT ROW)) FROM cte;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to