cambyzju commented on code in PR #30331:
URL: https://github.com/apache/doris/pull/30331#discussion_r1465986838


##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -389,6 +389,39 @@ Status VScanNode::_normalize_conjuncts() {
     return Status::OK();
 }
 
+bool _expr_inside_stale_ctx_exprs_tree(VExpr* root, VExpr* target_expr) {
+    if (root == nullptr) {
+        return false;
+    }
+    if (root == target_expr) {
+        return true;
+    }
+    for (auto& child : root->children()) {
+        if (_expr_inside_stale_ctx_exprs_tree(child, target_expr)) {
+            return true;
+        }
+    }
+    return false;
+}
+void VScanNode::_close_expr_inside_stale_ctxs(VExpr* expr, VExpr* new_root) {
+    DCHECK(expr != nullptr);
+    for (auto& ctx : _stale_vexpr_ctxs) {
+        VExpr* root = (*ctx)->root();
+        if (root == expr) {

Review Comment:
   @JackDrogon After combine the call of `close`,  I think the code is harder 
to understand.
   
   Refractor Code:
   ```
   if (_expr_inside_stale_ctx_exprs_tree(root, expr)) {
       if (root == expr && new_root == nullptr) {
           continue;
       }
       expr->close(_state, *ctx, (*ctx)->get_function_state_scope());
       if (root == expr && new_root != nullptr) {
           (*ctx)->set_root(new_root);
       }
   }
   ```



-- 
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