CalvinKirs commented on code in PR #67438:
URL: https://github.com/apache/doris/pull/67438#discussion_r3942500311


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -1192,12 +1235,110 @@ public List<Expression> bindSlotByScope(UnboundSlot 
unboundSlot, Scope scope) {
         }
     }
 
+    protected SlotBinding bindSlotByScope(
+            UnboundSlot unboundSlot, Scope scope, boolean 
bindRelationQualifierOnly) {
+        return bindRelationQualifierOnly
+                ? bindSlotByRelationQualifier(unboundSlot, scope)
+                : new SlotBinding(bindSlotByScope(unboundSlot, scope), false);
+    }
+
+    /** Bind a multipart slot as a relation-qualified column, without treating 
its first part as a column. */
+    protected SlotBinding bindSlotByRelationQualifier(UnboundSlot unboundSlot, 
Scope scope) {
+        List<String> nameParts = unboundSlot.getNameParts();
+        Optional<Pair<Integer, Integer>> idxInSql = 
unboundSlot.getIndexInSqlString();
+        List<? extends Expression> bounded;
+        switch (nameParts.size()) {
+            case 1:
+                bounded = ImmutableList.of();
+                break;
+            case 2:
+                bounded = bindExpressionByTableColumn(
+                        unboundSlot, nameParts, idxInSql, scope, false);
+                break;
+            case 3:
+                bounded = bindExpressionByDbTableColumn(
+                        unboundSlot, nameParts, idxInSql, scope, false);
+                break;
+            default:
+                bounded = bindExpressionByCatalogDbTableColumn(
+                        unboundSlot, nameParts, idxInSql, scope, false);
+                break;
+        }
+        return new SlotBinding(bounded, containsRelationQualifier(nameParts, 
scope));
+    }

Review Comment:
   Fixed in 1b401b432c7. Qualifier occupancy is now evaluated lazily only after 
the complete local binding chain misses. Successful local bindings and the 
bound-only outer-scope probe do not evaluate occupancy, and Scope now memoizes 
a case-insensitive relation-name index of distinct qualifiers so wide scopes 
are indexed once instead of scanned once per reference. Added unit coverage for 
local-hit, outer-probe, exact-binding laziness, and qualifier-index 
deduplication.



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