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

   ### Background
   
   Materialized view rewrite caches logical expressions by the tables or 
relation IDs they contain. Each cached expression records a candidate bitmap 
for each child, which is later used to reconstruct a complete query plan.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Bugfix
   
   Problem Summary: A join whose leading child has no struct info candidates 
can cause a null pointer exception during materialized view rewrite. The 
refresh traversal omits that child and associates a later child's bitmap with 
the wrong group. Preserve one candidate set per child so the existing Cartesian 
product rejects expressions with unavailable children before plan 
reconstruction.
   
   ### Details
   
   - **Frequency:** Deterministic for the covered plan shape; production 
frequency is unknown.
   - **Root cause:** `refresh` checks the cumulative `filteredTableMaps` before 
adding each child's candidate set. An empty leading child is skipped, shifting 
subsequent bitmaps away from their corresponding child groups. `constructPlan` 
then dereferences a missing mapping.
   - **Why existing tests missed it:** Existing coverage exercises complete 
candidate sets and MV alternatives, but does not cover an unavailable leading 
join child.
   - **Fix:** Keep empty candidate sets in the child list. The Cartesian 
product then produces no parent candidates if any child is unavailable. Remove 
the now-unreachable empty-child-list check; leaf expressions already exit 
before child enumeration.
   - **Other paths and branches:** The shared refresh implementation serves 
both table-ID and relation-ID modes. Tests exercise excluded children in both 
modes and subsequent forced refresh. No backports are included.
   - **Behavior change:** Incomplete struct info candidates are rejected before 
plan construction; valid alternatives remain available.
   
   ### Testing
   
   Validated locally:
   
   - Before the fix, `StructInfoMapTest#testTablelessJoinChild` reproduces 
`Cannot read field "first" because "groupExpressionBitSetPair" is null`.
   - `bash run-fe-ut.sh --run StructInfoMapTest`: 5 tests passed, 0 
failures/errors, `BUILD SUCCESS`. Coverage includes tableless children on 
either side of a join, excluded children in both ID modes, and complete 
reconstruction after forced refresh.
   - FE core Checkstyle: 0 violations, `BUILD SUCCESS`.
   - `git diff --check`: passed.
   
   No live-cluster regression was run; the nested-MV refresh and SQL-cache 
scenario remains to be validated in CI.
   
   ### Release note
   
   Fix a null pointer exception during materialized view rewrite when a join 
child has no struct info candidates.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Ready
   


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