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 315a2d5fc9f [Chore](execution) add check for do_projections (#60389)
315a2d5fc9f is described below

commit 315a2d5fc9f871d393965737ee87ad3a54e43263
Author: Pxl <[email protected]>
AuthorDate: Mon Feb 2 16:38:43 2026 +0800

    [Chore](execution) add check for do_projections (#60389)
    
    This pull request introduces additional validation checks to ensure the
    integrity of column sizes during projection and expression evaluation
    operations. These changes help catch and report inconsistencies early,
    improving the robustness and debuggability of the code.
    
    **Validation and Error Handling Improvements:**
    
    * Added checks in `OperatorXBase::do_projections` to return an internal
    error if any intermediate projection is empty, or if the result column
    size does not match the expected number of input rows, including
    detailed error messages for easier debugging.
    * Added validation after all intermediate projections to ensure the
    final input block row count matches the original, returning an error if
    not.
    * Added a check in the main projection loop of
    `OperatorXBase::do_projections` to verify that the result column size
    matches the input, with error reporting including the expression's debug
    string.
    * Updated `VCaseExpr::execute_column` to return an internal error if the
    result column size does not match the expected count, replacing the
    previous debug assertion with a runtime check and descriptive error
    message.
---
 be/src/pipeline/exec/operator.cpp | 24 +++++++++++++++++++++++-
 be/src/vec/exprs/vcase_expr.cpp   |  5 ++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/be/src/pipeline/exec/operator.cpp 
b/be/src/pipeline/exec/operator.cpp
index 7258b4ca028..70843ad94ff 100644
--- a/be/src/pipeline/exec/operator.cpp
+++ b/be/src/pipeline/exec/operator.cpp
@@ -312,16 +312,32 @@ Status OperatorXBase::do_projections(RuntimeState* state, 
vectorized::Block* ori
     size_t bytes_usage = 0;
     vectorized::ColumnsWithTypeAndName new_columns;
     for (const auto& projections : local_state->_intermediate_projections) {
+        if (projections.empty()) {
+            return Status::InternalError("meet empty intermediate projection, 
node id: {}",
+                                         node_id());
+        }
         new_columns.resize(projections.size());
         for (int i = 0; i < projections.size(); i++) {
             RETURN_IF_ERROR(projections[i]->execute(&input_block, 
new_columns[i]));
+            if (new_columns[i].column->size() != rows) {
+                return Status::InternalError(
+                        "intermediate projection result column size {} not 
equal input rows {}, "
+                        "expr: {}",
+                        new_columns[i].column->size(), rows,
+                        projections[i]->root()->debug_string());
+            }
         }
         vectorized::Block tmp_block {new_columns};
         bytes_usage += tmp_block.allocated_bytes();
         input_block.swap(tmp_block);
     }
 
-    DCHECK_EQ(rows, input_block.rows());
+    if (input_block.rows() != rows) {
+        return Status::InternalError(
+                "after intermediate projections input block rows {} not equal 
origin rows {}, "
+                "input_block: {}",
+                input_block.rows(), rows, input_block.dump_structure());
+    }
     auto insert_column_datas = [&](auto& to, vectorized::ColumnPtr& from, 
size_t rows) {
         if (to->is_nullable() && !from->is_nullable()) {
             if (_keep_origin || !from->is_exclusive()) {
@@ -354,6 +370,12 @@ Status OperatorXBase::do_projections(RuntimeState* state, 
vectorized::Block* ori
             auto result_column_id = -1;
             ColumnPtr column_ptr;
             
RETURN_IF_ERROR(local_state->_projections[i]->execute(&input_block, 
column_ptr));
+            if (column_ptr->size() != rows) {
+                return Status::InternalError(
+                        "projection result column size {} not equal input rows 
{}, expr: {}",
+                        column_ptr->size(), rows,
+                        local_state->_projections[i]->root()->debug_string());
+            }
             column_ptr = column_ptr->convert_to_full_column_if_const();
             if (result_column_id >= origin_columns_count) {
                 bytes_usage += column_ptr->allocated_bytes();
diff --git a/be/src/vec/exprs/vcase_expr.cpp b/be/src/vec/exprs/vcase_expr.cpp
index fd1e1b75b58..93016c72cb2 100644
--- a/be/src/vec/exprs/vcase_expr.cpp
+++ b/be/src/vec/exprs/vcase_expr.cpp
@@ -119,7 +119,10 @@ Status VCaseExpr::execute_column(VExprContext* context, 
const Block* block, Sele
     } else {
         result_column = _execute_impl<uint8_t>(when_columns, then_columns, 
rows_count);
     }
-    DCHECK_EQ(result_column->size(), count);
+    if (result_column->size() != count) {
+        return Status::InternalError("case when result column size {} not 
equal input count {}",
+                                     result_column->size(), count);
+    }
     return Status::OK();
 }
 


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

Reply via email to