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

   ## Proposed changes
   
   Issue Number: close #N/A
   
   ### What problem does this PR solve?
   
   Related Jira: DORIS-22946
   
   `OlapTableFactory.withExtraParams` only attaches a `TableIndexes` to plain 
OLAP tables; the MTMV branch (`CreateMTMVInfo` path) never calls 
`withIndexes()`, so a freshly created MTMV has `OlapTable.indexes == null`.
   
   When the optimizer transparently rewrites a `MATCH` predicate to an MTMV, 
`ExpressionTranslator.visitMatch()` calls `OlapTable.getInvertedIndex(column, 
subPath)` on that MTMV. The method dereferences `indexes.getIndexes()` without 
a null check, so the query fails with:
   
   ```
   Cannot invoke "org.apache.doris.catalog.TableIndexes.getIndexes()" because 
"this.indexes" is null
   ```
   
   This matches the exception observed when a `MATCH` query against a base 
table is transparently rewritten to an MTMV whose `TableIndexes` has not been 
initialized.
   
   Sibling accessors (`getIndexes()`, `getIndexIds()`, `hasIndexOfType()`, 
`getIndexesMap()`) already guard against `indexes == null`. Master / 4.1 
already null-guard `getInvertedIndex` (via #63637). This change brings the same 
guard to branch-4.0 so the NPE no longer surfaces during MV rewrite. Returning 
\`null\` is consistent with "no inverted index found on this column", which is 
the correct semantics here.
   
   ### Release note
   
   Fix a NullPointerException raised by MATCH predicates that are rewritten to 
an asynchronous materialized view whose \`TableIndexes\` has not been 
initialized.
   
   ### Check List (For Author)
   
   - Test
       - [x] Unit Test
   
   - Behavior changed:
       - [ ] No.
   
   - Does this need documentation?
       - [ ] No.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [x] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label


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