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

panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 9450f5ede20 [fix](Operator) RepeatNode does not handle empty 
expressions. (#32112)
9450f5ede20 is described below

commit 9450f5ede205ba731c66ee0a74150699dc20b7e9
Author: Mryange <59914473+mrya...@users.noreply.github.com>
AuthorDate: Thu Mar 14 13:09:49 2024 +0800

    [fix](Operator) RepeatNode does not handle empty expressions. (#32112)
    
    In the past, RepeatNode did not handle empty expressions.
    It used DCHECK to check if the expression was non-empty.
    In non-debug mode, this caused _child_block to remain unprocessed, 
resulting in a deadlock.
    Now, if the expression is empty, the output block directly outputs 
_child_block
---
 be/src/pipeline/exec/repeat_operator.cpp           |  6 ++-
 be/src/vec/exec/vrepeat_node.cpp                   |  5 +-
 .../correctness_p0/test_grouping_sets_empty.out    | 13 +++++
 .../correctness_p0/test_grouping_sets_empty.groovy | 59 ++++++++++++++++++++++
 4 files changed, 80 insertions(+), 3 deletions(-)

diff --git a/be/src/pipeline/exec/repeat_operator.cpp 
b/be/src/pipeline/exec/repeat_operator.cpp
index 13f7a9e8d06..5554599af00 100644
--- a/be/src/pipeline/exec/repeat_operator.cpp
+++ b/be/src/pipeline/exec/repeat_operator.cpp
@@ -183,8 +183,6 @@ Status RepeatOperatorX::push(RuntimeState* state, 
vectorized::Block* input_block
     auto& _intermediate_block = local_state._intermediate_block;
     auto& _expr_ctxs = local_state._expr_ctxs;
     DCHECK(!_intermediate_block || _intermediate_block->rows() == 0);
-    DCHECK(!_expr_ctxs.empty());
-
     if (input_block->rows() > 0) {
         _intermediate_block = vectorized::Block::create_unique();
 
@@ -229,6 +227,10 @@ Status RepeatOperatorX::pull(doris::RuntimeState* state, 
vectorized::Block* outp
             
_child_block.clear_column_data(_child_x->row_desc().num_materialized_slots());
             _repeat_id_idx = 0;
         }
+    } else if (local_state._expr_ctxs.empty()) {
+        DCHECK(!_intermediate_block || (_intermediate_block && 
_intermediate_block->rows() == 0));
+        output_block->swap(_child_block);
+        
_child_block.clear_column_data(_child_x->row_desc().num_materialized_slots());
     }
     RETURN_IF_ERROR(vectorized::VExprContext::filter_block(_conjuncts, 
output_block,
                                                            
output_block->columns()));
diff --git a/be/src/vec/exec/vrepeat_node.cpp b/be/src/vec/exec/vrepeat_node.cpp
index 921473a8fed..d494ff514e9 100644
--- a/be/src/vec/exec/vrepeat_node.cpp
+++ b/be/src/vec/exec/vrepeat_node.cpp
@@ -193,6 +193,10 @@ Status VRepeatNode::pull(doris::RuntimeState* state, 
vectorized::Block* output_b
             release_block_memory(*_child_block);
             _repeat_id_idx = 0;
         }
+    } else if (_expr_ctxs.empty()) {
+        DCHECK(!_intermediate_block || (_intermediate_block && 
_intermediate_block->rows() == 0));
+        output_block->swap(*_child_block);
+        release_block_memory(*_child_block);
     }
     RETURN_IF_ERROR(VExprContext::filter_block(_conjuncts, output_block, 
output_block->columns()));
     *eos = _child_eos && _child_block->rows() == 0;
@@ -205,7 +209,6 @@ Status VRepeatNode::push(RuntimeState* state, 
vectorized::Block* input_block, bo
     SCOPED_TIMER(_exec_timer);
     _child_eos = eos;
     DCHECK(!_intermediate_block || _intermediate_block->rows() == 0);
-    DCHECK(!_expr_ctxs.empty());
 
     if (input_block->rows() > 0) {
         _intermediate_block = Block::create_unique();
diff --git a/regression-test/data/correctness_p0/test_grouping_sets_empty.out 
b/regression-test/data/correctness_p0/test_grouping_sets_empty.out
new file mode 100644
index 00000000000..4d3b2c82c87
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_grouping_sets_empty.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select1 --
+1
+
+-- !select2 --
+1
+
+-- !select3 --
+1
+
+-- !select4 --
+1
+
diff --git 
a/regression-test/suites/correctness_p0/test_grouping_sets_empty.groovy 
b/regression-test/suites/correctness_p0/test_grouping_sets_empty.groovy
new file mode 100644
index 00000000000..23f35e3b80f
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_grouping_sets_empty.groovy
@@ -0,0 +1,59 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_grouping_sets_empty") {
+
+    sql"""
+        create table test_grouping_sets_empty (a int) distributed by hash(a) 
buckets 1 properties ( 'replication_num' = '1');
+    """
+
+    sql """
+        insert into test_grouping_sets_empty values (1);
+    """
+
+
+    sql """ 
+        set experimental_enable_pipeline_x_engine=true;
+    """
+
+    qt_select1 """
+        select count(a) from test_grouping_sets_empty group by grouping sets 
(());
+    """
+
+
+    qt_select2 """
+        select count(*) from test_grouping_sets_empty group by grouping sets 
(());
+    """
+
+
+    sql """ 
+        set experimental_enable_pipeline_x_engine=false;
+    """
+
+
+    qt_select3 """
+        select count(a) from test_grouping_sets_empty group by grouping sets 
(());
+    """
+
+
+    qt_select4 """
+        select count(*) from test_grouping_sets_empty group by grouping sets 
(());
+    """
+
+
+
+}


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

Reply via email to