yujun777 opened a new pull request, #70799: URL: https://github.com/apache/doris/pull/70799
### Background Doris uses `REFRESH AUTO` by default for asynchronous materialized views. During creation, AUTO probes whether the view can use incremental view maintenance (IVM). IVM reads base table changes through internal table streams. ### What problem does this PR solve? Issue Number: None Related PR: #62606 (introduced the IVM CREATE probe) PR Type: Bugfix Problem Summary: Creating an asynchronous materialized view over a changelog-enabled table could fail when the FE stream switch was disabled or a merge-on-write base table had no historical changelog values. For example, `CREATE MATERIALIZED VIEW mv BUILD DEFERRED AS SELECT k, SUM(v) FROM t GROUP BY k` could reach Stream creation and fail after the IVM view was registered. AUTO now creates a regular asynchronous materialized view in either case. ### Details - **Frequency:** Always when IVM query analysis succeeds and a required stream fails either prerequisite. - **Root cause:** `CreateMTMVInfo` only retried regular MV analysis when the IVM query probe failed. The catalog checked Stream availability after the IVM schema was already registered. - **Why existing tests missed it:** `CreateMTMVCommandTest` enabled table streams in class setup, and its prior AUTO fallback tests exercised query analysis errors. `test_ivm_basic_mtmv` exercises explicit incremental refresh with the required changelog history enabled. - **Fix:** Reuse the catalog's Stream enablement and base table checks during IVM CREATE analysis. Skip excluded base tables and existing targets of `IF NOT EXISTS`. Restore the original MV properties before retrying regular analysis. - **Other paths and branches:** Both deployment modes share this FE precheck. Stream DDL still validates the live state when it provisions streams. The AUTO IVM probe is absent from the upstream 3.1, 4.0, 4.1, and 4.2 branches. - **Behavior change:** AUTO reports the qualified materialized view name and the fallback reason in the FE log. Explicit INCREMENTAL reports missing Stream prerequisites during analysis. ### Testing - Ran `./run-fe-ut.sh --run CreateMTMVCommandTest` locally. All 101 tests passed. - The new cases check AUTO and explicit INCREMENTAL with the Stream switch disabled or historical values missing. They also cover an existing `IF NOT EXISTS` target and verify that IVM-derived properties do not survive fallback. - The existing excluded-table case now uses a base table without historical values and still provisions only the required Stream. - The new cases were run on the fixed code. ### Release note None ### Check List (For Author) - Behavior changed: Yes (see Details). - Does this need documentation: No. AUTO follows the documented fallback behavior. - Pre-submission status: Ready. The focused FE unit tests cover both reported prerequisites. -- 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]
