yiguolei commented on code in PR #65324:
URL: https://github.com/apache/doris/pull/65324#discussion_r3577510935


##########
be/src/exec/operator/union_sink_operator.cpp:
##########
@@ -104,38 +104,35 @@ Status UnionSinkOperatorX::sink_impl(RuntimeState* state, 
Block* in_block, bool
         local_state._output_block =
                 
local_state._shared_state->data_queue.get_free_block(_cur_child_id);
     }
+    std::unique_ptr<Block> output_block;
     if (_cur_child_id < _get_first_materialized_child_idx()) { //pass_through
         if (in_block->rows() > 0) {
             local_state._output_block->swap(*in_block);
-            RETURN_IF_ERROR(local_state._shared_state->data_queue.push_block(
-                    std::move(local_state._output_block), _cur_child_id));
+            output_block = std::move(local_state._output_block);
         }
     } else if (_get_first_materialized_child_idx() != children_count() &&
                _cur_child_id < children_count()) { //need materialized
         RETURN_IF_ERROR(materialize_child_block(state, _cur_child_id, in_block,
                                                 
local_state._output_block.get()));
+        if (eos || local_state._output_block->rows() >= state->batch_size()) {
+            if (local_state._output_block->rows() > 0) {
+                output_block = std::move(local_state._output_block);
+            } else {
+                local_state._output_block.reset();
+            }
+        }
     } else {
         return Status::InternalError("maybe can't reach here, execute const 
expr: {}, {}, {}",
                                      _cur_child_id, 
_get_first_materialized_child_idx(),
                                      children_count());
     }
-    if (UNLIKELY(eos)) {
-        //if _cur_child_id eos, need check to push block
-        //Now here can't check _output_block rows, even it's row==0, also need 
push block
-        //because maybe sink is eos and queue have none data, if not push block
-        //the source can't can_read again and can't set source finished
-        if (local_state._output_block) {
-            RETURN_IF_ERROR(local_state._shared_state->data_queue.push_block(
-                    std::move(local_state._output_block), _cur_child_id));
-        }
 
-        local_state._shared_state->data_queue.set_finish(_cur_child_id);
-        return Status::OK();
-    }
-    // not eos and block rows is enough to output,so push block
-    if (local_state._output_block && (local_state._output_block->rows() >= 
state->batch_size())) {
-        RETURN_IF_ERROR(local_state._shared_state->data_queue.push_block(
-                std::move(local_state._output_block), _cur_child_id));
+    if (output_block || eos) {
+        if (eos && !output_block) {
+            local_state._output_block.reset();

Review Comment:
   这个逻辑是啥含义



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to