CalvinKirs opened a new pull request, #67438:
URL: https://github.com/apache/doris/pull/67438

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: None
   
   Problem Summary:
   
   In a correlated subquery, a multipart reference can represent either a 
relation-qualified column (`table_alias.column`) or a nested-field dereference 
(`column.field`). Nereids previously searched the inner scope completely before 
checking the outer scope. If an inner table had a physical column with the same 
name as an outer table alias, the outer reference could therefore be 
interpreted as a nested field of that inner column.
   
   For scalar inner columns this raised a `No such field` analysis error. For 
complex inner columns it could bind successfully to the wrong expression and 
produce incorrect results.
   
   This change resolves relation-qualified columns in the current and outer 
scopes before falling back to first-part-as-column dereference. It preserves 
current-scope relation priority while allowing an outer relation alias to take 
priority over an unrelated inner column name.
   
   ### Release note
   
   Fix incorrect Nereids column binding when an outer table alias conflicts 
with an inner column name in a correlated subquery.
   
   ### Check List (For Author)
   
   - Test: Unit Test
       - `./run-fe-ut.sh --run 
org.apache.doris.nereids.rules.analysis.TestDereference`
       - Result: 3 tests passed, 0 failures
       - Added `query_p0/test_dereference` regression coverage for scalar and 
complex inner columns; the regression suite was not run locally because a 
dedicated FE/BE worktree cluster was not started
   - Behavior changed: Yes (relation-qualified correlated references now take 
priority over inner column-field dereference)
   - Does this need documentation: No


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