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

commit 9b7e007ef6a2afda48869a422cb273b407894cda
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Mon Apr 29 13:35:58 2024 +0800

    [Bug](union) fix union operator set eos is not incorrect (#34250)
    
    * [test](case) fix unstable case without order by distinct row
    
    * [Bug](union) fix union operator set eos is not incorrect
---
 be/src/pipeline/exec/union_source_operator.cpp | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/be/src/pipeline/exec/union_source_operator.cpp 
b/be/src/pipeline/exec/union_source_operator.cpp
index 10f98a8d1cb..c89112261c1 100644
--- a/be/src/pipeline/exec/union_source_operator.cpp
+++ b/be/src/pipeline/exec/union_source_operator.cpp
@@ -172,12 +172,20 @@ std::string UnionSourceLocalState::debug_string(int 
indentation_level) const {
 Status UnionSourceOperatorX::get_block(RuntimeState* state, vectorized::Block* 
block, bool* eos) {
     auto& local_state = get_local_state(state);
     Defer set_eos {[&]() {
-        //have executing const expr, queue have no data anymore, and child 
could be closed
-        *eos = (_child_size == 0 && !local_state._need_read_for_const_expr) ||
-               // here should check `_has_data` first, or when `is_all_finish` 
is false,
-               // the data queue will have no chance to change the 
`_flag_queue_idx`.
-               (!_has_data(state) && _child_size > 0 &&
-                local_state._shared_state->data_queue.is_all_finish());
+        // the eos check of union operator is complex, need check all logical 
if you want modify
+        // could ref this PR: https://github.com/apache/doris/pull/29677
+        // have executing const expr, queue have no data anymore, and child 
could be closed
+        if (_child_size == 0 && !local_state._need_read_for_const_expr) {
+            *eos = true;
+        } else if (_has_data(state)) {
+            *eos = false;
+        } else if (local_state._shared_state->data_queue.is_all_finish()) {
+            // Here, check the value of `_has_data(state)` again after 
`data_queue.is_all_finish()` is TRUE
+            // as there may be one or more blocks when 
`data_queue.is_all_finish()` is TRUE.
+            *eos = !_has_data(state);
+        } else {
+            *eos = false;
+        }
     }};
 
     SCOPED_TIMER(local_state.exec_time_counter());


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

Reply via email to