Skip to content

[fix](mtmv) Preserve origin statement in refresh task - #68272

Merged
yiguolei merged 1 commit into
apache:branch-4.1from
morrySnow:fix/mtmv-origin-statement-4.1
Sep 21, 2026
Merged

yiguolei merged 1 commit into
apache:branch-4.1from
morrySnow:fix/mtmv-origin-statement-4.1

Conversation

@morrySnow

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #68269

Problem Summary:

Internal MTMV refresh tasks could construct a StatementContext and LogicalPlanAdapter without an origin statement. StmtExecutor then copied the null adapter origin back into the context. If CBO candidate costing failed, CostBasedRewriteJob dereferenced that missing origin while logging and raised an unrelated NullPointerException.

This change initializes refresh planning with the MV query, propagates the same origin through the adapter, and makes the CBO failure log tolerate internal contexts without an origin statement.

Release note

Fix internal materialized view refresh failures caused by a missing origin statement.

Check List (For Author)

  • Test: Unit Test
    • ./run-fe-ut.sh --run org.apache.doris.mtmv.MTMVTaskTest,org.apache.doris.nereids.jobs.rewrite.CostBasedRewriteJobTest
    • 17 tests passed
  • Behavior changed: No
  • Does this need documentation: No

### What problem does this PR solve?

Problem Summary:

Internal MTMV refresh tasks could construct a StatementContext and LogicalPlanAdapter without an origin statement. StmtExecutor then copied the null adapter origin back into the context. If CBO candidate costing failed, CostBasedRewriteJob dereferenced that missing origin while logging and raised an unrelated NullPointerException.

Initialize refresh planning with the MV query, propagate the same origin through the adapter, and make the CBO failure log tolerate internal contexts without an origin statement.

### Release note

Fix internal materialized view refresh failures caused by a missing origin statement.

### Check List (For Author)

- Test: Unit Test
- Behavior changed: No
- Does this need documentation: No
@morrySnow
morrySnow requested a review from yiguolei as a code owner September 20, 2026 09:57
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@morrySnow

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 81.82% (9/11) 🎉
Increment coverage report
Complete coverage report

@yiguolei
yiguolei merged commit 1dbf5c6 into apache:branch-4.1 Sep 21, 2026
28 of 30 checks passed
@morrySnow
morrySnow deleted the fix/mtmv-origin-statement-4.1 branch September 24, 2026 06:35
morningman added a commit that referenced this pull request Sep 24, 2026
### What problem does this PR solve?

Issue Number: None (branch pick)

Related PR: #67490, #68141, #66963, #68269

Problem Summary: Pick the four merged `incremental-computation` PRs that
do not have the `incremental-computation-picked` label into
`branch-incremental-computation`, in their master merge order:

1. #67490: prevent a local exchange under a serial parent pipeline.
2. #68141: manage MTMV planning caches through a bounded global LRU
cache and expose cache statistics.
3. #66963: restrict HLL, QUANTILE_STATE, and AGG_STATE columns to
Aggregate Key tables by default, with a temporary compatibility setting.
4. #68269: preserve the origin statement for internal MTMV refreshes and
parse `SET_VAR` hints with the refresh context installed.

Dependency check: #33262, referenced by #68141, is already an ancestor
of this branch. #66664 is an open related row-binlog fix rather than a
code prerequisite for #66963. #68272 is the corresponding branch-4.1 fix
for #68269, not a master prerequisite. No additional PR needed picking.

### Release note

Bring the four fixes and MTMV cache management change above to the
incremental computation branch. In particular, non-Aggregate Key tables
now reject new HLL, QUANTILE_STATE, and AGG_STATE columns by default;
incremental MTMV refreshes and dry runs can parse MV queries with
`SET_VAR` hints.

### Check List (For Author)

- Test:
    - `./build.sh --fe` (passed, including Checkstyle with 0 violations)
- Focused `./run-fe-ut.sh --run ...` across 13 changed and related test
classes (356 tests passed, 0 failures/errors/skips)
- SQL regression tests were not run; this worktree has no BE cluster.
- Behavior changed: Yes, as described in the source PRs and release
note.
- Does this need documentation: No; the source PRs do not require a
documentation PR.

---------

Co-authored-by: Mryange <[email protected]>
Co-authored-by: xy720 <[email protected]>
Co-authored-by: Luwei <[email protected]>
Co-authored-by: morrySnow <[email protected]>
@yiguolei yiguolei mentioned this pull request Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants