HappenLee commented on code in PR #64563:
URL: https://github.com/apache/doris/pull/64563#discussion_r3481151991


##########
be/src/exprs/vcolumn_ref.h:
##########
@@ -91,8 +110,45 @@ class VColumnRef final : public VExpr {
     double execute_cost() const override { return 0.0; }
 
 private:
+    int _get_column_position(VExprContext* context, const Block* block) const {
+        if (context != nullptr) {
+            const auto resolve_result =
+                    
context->lambda_execution_context().resolve_column_position(_column_name);
+            if (resolve_result.found) {
+                return resolve_result.column_position;
+            }
+            if (resolve_result.searched_named_scope) {
+                return -1;
+            }
+        }
+        return _get_column_position_without_context(block);
+    }
+
+    int _get_column_position_without_context(const Block* block) const {
+        if (!_gap_set.load()) {
+            const int position_by_name = _find_column_position_by_name(block);
+            if (position_by_name >= 0) {
+                return position_by_name;
+            }
+        }
+        return _column_id + _gap.load();
+    }
+
+    int _find_column_position_by_name(const Block* block) const {
+        if (block == nullptr) {
+            return -1;
+        }
+        for (int position = block->columns() - 1; position >= 0; --position) {
+            if (block->get_by_position(position).name == _column_name) {
+                return position;
+            }
+        }
+        return -1;
+    }
+
     int _column_id;
     std::atomic<int> _gap = 0;
+    std::atomic<bool> _gap_set = false;

Review Comment:
   感觉用-1初始化_gap就能规避这个变量了,你看看是否可以



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