CalvinKirs commented on code in PR #67438:
URL: https://github.com/apache/doris/pull/67438#discussion_r3912504638
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/ExpressionAnalyzer.java:
##########
@@ -309,14 +309,30 @@ public Expression visitElementAt(ElementAt elementAt,
ExpressionRewriteContext c
@Override
public Expression visitUnboundSlot(UnboundSlot unboundSlot,
ExpressionRewriteContext context) {
Optional<Scope> outerScope = getScope().getOuterScope();
- Optional<List<? extends Expression>> boundedOpt =
Optional.of(bindSlotByThisScope(unboundSlot));
- boolean foundInThisScope = !boundedOpt.get().isEmpty();
+ List<? extends Expression> bounded = ImmutableList.of();
+ boolean foundInThisScope = false;
+ boolean canBindOuterScope = bindSlotInOuterScope &&
outerScope.isPresent();
+
+ // A multipart name can be either a relation-qualified column (t.col)
or a nested field
+ // reference (col.field). In a correlated subquery, try the
relation-qualified interpretation
+ // in both visible scopes first, so an inner column named "t" does not
hide an outer alias "t".
+ if (canBindOuterScope && unboundSlot.getNameParts().size() > 1) {
+ bounded = bindSlotByRelationQualifier(unboundSlot, getScope());
+ foundInThisScope = !bounded.isEmpty();
+ if (!foundInThisScope) {
+ bounded = bindSlotByRelationQualifier(unboundSlot,
outerScope.get());
+ }
Review Comment:
Fixed in 3a350a08727. Correlation bookkeeping now records
firstBound.getInputSlots() instead of requiring firstBound itself to be a Slot,
so an Alias(ElementAt(outer_alias.payload, k)) contributes the underlying
payload slot. Added a test that asserts LogicalApply carries that correlated
slot, plus query_p0 coverage. The targeted FE test now passes (5 tests, 0
failures).
--
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]