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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new a3510d3b73e [cherry-pick](branch-21)fix the exchange not skip offset 
rows (#42190) (#42330)
a3510d3b73e is described below

commit a3510d3b73e2f9db76d053a5c9dcc3bfb9e8bc66
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Thu Oct 24 11:08:17 2024 +0800

    [cherry-pick](branch-21)fix the exchange not skip offset rows (#42190) 
(#42330)
    
    cherry-pick from master (#42190)
---
 be/src/pipeline/exec/exchange_source_operator.cpp          | 6 ++++--
 be/src/vec/exec/vexchange_node.cpp                         | 4 ++--
 regression-test/data/nereids_syntax_p0/test_limit.out      | 4 ++++
 regression-test/suites/nereids_syntax_p0/test_limit.groovy | 5 +++++
 4 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/be/src/pipeline/exec/exchange_source_operator.cpp 
b/be/src/pipeline/exec/exchange_source_operator.cpp
index 94cbe439a3e..016d86ecb5b 100644
--- a/be/src/pipeline/exec/exchange_source_operator.cpp
+++ b/be/src/pipeline/exec/exchange_source_operator.cpp
@@ -17,6 +17,7 @@
 
 #include "exchange_source_operator.h"
 
+#include <cstdint>
 #include <memory>
 
 #include "pipeline/exec/operator.h"
@@ -176,9 +177,10 @@ Status ExchangeSourceOperatorX::get_block(RuntimeState* 
state, vectorized::Block
                 local_state.num_rows_skipped += block->rows();
                 block->set_num_rows(0);
             } else if (local_state.num_rows_skipped < _offset) {
-                auto offset = _offset - local_state.num_rows_skipped;
+                int64_t offset = _offset - local_state.num_rows_skipped;
                 local_state.num_rows_skipped = _offset;
-                block->set_num_rows(block->rows() - offset);
+                // should skip some rows
+                block->skip_num_rows(offset);
             }
         }
         if (local_state.num_rows_returned() + block->rows() < _limit) {
diff --git a/be/src/vec/exec/vexchange_node.cpp 
b/be/src/vec/exec/vexchange_node.cpp
index 5b3e38af56a..c7689246b90 100644
--- a/be/src/vec/exec/vexchange_node.cpp
+++ b/be/src/vec/exec/vexchange_node.cpp
@@ -116,9 +116,9 @@ Status VExchangeNode::get_next(RuntimeState* state, Block* 
block, bool* eos) {
                 _num_rows_skipped += block->rows();
                 block->set_num_rows(0);
             } else if (_num_rows_skipped < _offset) {
-                auto offset = _offset - _num_rows_skipped;
+                int64_t offset = _offset - _num_rows_skipped;
                 _num_rows_skipped = _offset;
-                block->set_num_rows(block->rows() - offset);
+                block->skip_num_rows(offset);
             }
         }
         if (_num_rows_returned + block->rows() < _limit) {
diff --git a/regression-test/data/nereids_syntax_p0/test_limit.out 
b/regression-test/data/nereids_syntax_p0/test_limit.out
index f36542a7375..3e83144c18b 100644
--- a/regression-test/data/nereids_syntax_p0/test_limit.out
+++ b/regression-test/data/nereids_syntax_p0/test_limit.out
@@ -4,3 +4,7 @@
 
 -- !lmit2 --
 3      7934    MILLER  CLERK   7782    1982-01-23      1300.0  0.0     10
+
+-- !lmit3 --
+3      7934    MILLER  CLERK   7782    1982-01-23      1300.0  0.0     10
+
diff --git a/regression-test/suites/nereids_syntax_p0/test_limit.groovy 
b/regression-test/suites/nereids_syntax_p0/test_limit.groovy
index 6856a5e7a20..bd63fc8b785 100644
--- a/regression-test/suites/nereids_syntax_p0/test_limit.groovy
+++ b/regression-test/suites/nereids_syntax_p0/test_limit.groovy
@@ -75,4 +75,9 @@ suite("test_limit") {
     qt_lmit2 """
             select row_number() over(order by k6 desc) k6s, t.* from 
row_number_limit_tbl t limit 1 offset 2;
         """
+
+    sql """ set parallel_pipeline_task_num = 1; """
+    qt_lmit3 """
+            select row_number() over(order by k6 desc) k6s, t.* from 
row_number_limit_tbl t limit 1 offset 2;
+        """
 }


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

Reply via email to