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

   ### What problem does this PR solve?
   
   Issue Number: close #xxxxx
   
   Problem Summary:
   
   Fixed a critical bug in nested **Hive view** slot binding that caused 
"Unknown column" errors when querying nested Hive views through Doris where 
inner views contain table aliases.
   
   **Important Note:** This bug only occurs when querying **Hive views** 
through Doris, not regular Doris views.
   
   **Root Cause:**
   The bug was in `LogicalSubQueryAlias.computeOutput()` method. When 
processing nested Hive views, the qualifier replacement logic was missing a 
crucial case:
   - When a slot has a short qualifier (e.g., `["b"]` from table alias)
   - And the LogicalSubQueryAlias has a longer qualifier (e.g., `["hive", 
"app", "view_name"]`)
   - The original logic didn't handle this case, causing slots to retain 
incorrect qualifiers
   
   **Specific Scenario:**
   1. Inner Hive view contains JOINs with table aliases (`a`, `b`, `c`)
   2. Column `rev_area_name` comes from alias `b`, so slot has qualifier `["b"]`
   3. Outer Hive view references `inner_view.rev_area_name`
   4. When querying through Doris, slot binding fails because slot qualifier 
`["b"]` doesn't match expected view qualifier
   
   **Error Message:**
   ```
   (1054, "errCode = 2, detailMessage = Unknown column 'rev_area_name' in 
'inner_view' in FILTER clause")
   ```
   
   **Fix:**
   Added missing case in `LogicalSubQueryAlias.computeOutput()` to handle short 
qualifiers being replaced with longer qualifiers:
   ```java
   } else {
       // If originQualifier is shorter than the new qualifier, replace it 
entirely
       // This handles cases where slots from table aliases (e.g., ["b"]) need 
to be
       // qualified with the full view qualifier (e.g., ["hive", "app", 
"view_name"])
       newQualifier.clear();
       newQualifier.addAll(qualifier);
   }
   ```
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:


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