Skip to content

[draft](ivm) Add mv ivm test for pipeline#62606

Draft
yujun777 wants to merge 112 commits into
apache:masterfrom
yujun777:ivm
Draft

[draft](ivm) Add mv ivm test for pipeline#62606
yujun777 wants to merge 112 commits into
apache:masterfrom
yujun777:ivm

Conversation

@yujun777
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Apr 20, 2026

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?

@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 77.99% (1155/1481) 🎉
Increment coverage report
Complete coverage report

@abcxyz333
Copy link
Copy Markdown

run feut

@abcxyz333
Copy link
Copy Markdown

run nonConcurrent

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 76.44% (1155/1511) 🎉
Increment coverage report
Complete coverage report

@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 78.12% (1157/1481) 🎉
Increment coverage report
Complete coverage report

@abcxyz333
Copy link
Copy Markdown

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 79.36% (1307/1647) 🎉
Increment coverage report
Complete coverage report

@abcxyz333
Copy link
Copy Markdown

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 79.66% (1351/1696) 🎉
Increment coverage report
Complete coverage report

@abcxyz333
Copy link
Copy Markdown

run feut

@abcxyz333
Copy link
Copy Markdown

run buildall

@yujun777 yujun777 force-pushed the ivm branch 2 times, most recently from 13a1dd6 to 1166da3 Compare May 12, 2026 12:00
@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 29676 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 1166da317da02cf6346164c38addb1dca437ab7a, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17697	3854	3824	3824
q2	q3	10703	877	612	612
q4	4676	458	344	344
q5	7468	1342	1159	1159
q6	202	173	142	142
q7	927	979	775	775
q8	9622	1405	1302	1302
q9	6065	5386	5366	5366
q10	6305	2072	1816	1816
q11	489	275	263	263
q12	701	419	303	303
q13	18157	3252	2764	2764
q14	293	286	270	270
q15	q16	913	855	794	794
q17	1088	1093	695	695
q18	6413	5677	5629	5629
q19	1578	1215	1069	1069
q20	530	396	272	272
q21	4588	2341	1939	1939
q22	481	377	338	338
Total cold run time: 98896 ms
Total hot run time: 29676 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4680	4456	4523	4456
q2	q3	4652	4765	4205	4205
q4	2098	2113	1403	1403
q5	4958	4940	5269	4940
q6	196	167	139	139
q7	2102	1856	1619	1619
q8	3336	3105	3111	3105
q9	8406	8752	8417	8417
q10	4473	4494	4225	4225
q11	603	430	401	401
q12	679	741	533	533
q13	3298	3541	2897	2897
q14	321	332	280	280
q15	q16	787	796	716	716
q17	1382	1342	1313	1313
q18	8013	7186	7101	7101
q19	1160	1148	1142	1142
q20	2275	2262	1959	1959
q21	6037	5345	4781	4781
q22	513	471	405	405
Total cold run time: 59969 ms
Total hot run time: 54037 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169641 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 1166da317da02cf6346164c38addb1dca437ab7a, data reload: false

query5	4360	643	498	498
query6	327	225	199	199
query7	4262	550	317	317
query8	332	230	209	209
query9	8818	3990	3956	3956
query10	444	343	300	300
query11	5743	2385	2229	2229
query12	189	132	136	132
query13	1276	573	441	441
query14	6739	5349	5094	5094
query14_1	4359	4386	4336	4336
query15	216	201	181	181
query16	1022	469	423	423
query17	1150	790	642	642
query18	2752	495	361	361
query19	227	214	165	165
query20	147	138	133	133
query21	217	140	118	118
query22	13576	13495	13411	13411
query23	17079	16339	15964	15964
query23_1	16075	16117	16100	16100
query24	7465	1776	1344	1344
query24_1	1348	1344	1377	1344
query25	566	522	476	476
query26	1298	309	177	177
query27	2710	571	345	345
query28	4393	1976	1942	1942
query29	1016	649	545	545
query30	307	250	204	204
query31	1156	1076	940	940
query32	104	77	75	75
query33	538	356	302	302
query34	1186	1138	623	623
query35	765	817	662	662
query36	1287	1336	1145	1145
query37	157	102	87	87
query38	3213	3079	3034	3034
query39	924	907	896	896
query39_1	863	865	870	865
query40	229	154	137	137
query41	64	63	60	60
query42	111	108	106	106
query43	316	331	280	280
query44	
query45	204	201	190	190
query46	1062	1189	739	739
query47	2381	2386	2228	2228
query48	412	416	302	302
query49	627	529	428	428
query50	692	299	222	222
query51	4428	4283	4227	4227
query52	104	103	94	94
query53	249	277	201	201
query54	315	273	248	248
query55	91	91	84	84
query56	296	315	296	296
query57	1379	1381	1339	1339
query58	292	272	264	264
query59	1536	1600	1405	1405
query60	343	330	325	325
query61	159	155	153	153
query62	666	632	569	569
query63	256	199	201	199
query64	2323	848	669	669
query65	
query66	1687	526	398	398
query67	30010	29864	29725	29725
query68	
query69	445	343	305	305
query70	990	981	948	948
query71	306	267	269	267
query72	2980	2738	2368	2368
query73	850	768	408	408
query74	5052	4872	4718	4718
query75	2760	2657	2353	2353
query76	2269	1123	789	789
query77	410	417	340	340
query78	12954	12931	12362	12362
query79	2205	954	798	798
query80	1377	591	504	504
query81	528	275	247	247
query82	992	169	122	122
query83	324	274	248	248
query84	279	144	113	113
query85	937	530	462	462
query86	452	320	329	320
query87	3443	3353	3166	3166
query88	3549	2677	2658	2658
query89	445	394	332	332
query90	1924	174	183	174
query91	180	171	139	139
query92	78	77	73	73
query93	1228	961	572	572
query94	704	345	310	310
query95	669	456	342	342
query96	1043	784	331	331
query97	2694	2705	2566	2566
query98	236	240	230	230
query99	1094	1112	1011	1011
Total cold run time: 255158 ms
Total hot run time: 169641 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 83.03% (1453/1750) 🎉
Increment coverage report
Complete coverage report

@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 29321 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 7aae0b6b091942580609be80d534c19ec72cc087, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17664	3851	3799	3799
q2	q3	10723	860	592	592
q4	4662	462	344	344
q5	7440	1317	1134	1134
q6	187	168	138	138
q7	910	930	756	756
q8	9301	1381	1246	1246
q9	5524	5338	5361	5338
q10	6270	2085	1845	1845
q11	473	267	252	252
q12	625	419	289	289
q13	18064	3344	2786	2786
q14	282	281	267	267
q15	q16	866	866	793	793
q17	959	1103	750	750
q18	6450	5645	5474	5474
q19	1176	1301	980	980
q20	532	394	264	264
q21	5290	2395	1940	1940
q22	478	416	334	334
Total cold run time: 97876 ms
Total hot run time: 29321 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4814	4716	4882	4716
q2	q3	4652	4742	4210	4210
q4	2143	2191	1407	1407
q5	5011	4920	5156	4920
q6	191	174	143	143
q7	2082	1834	1612	1612
q8	3344	3144	3150	3144
q9	8441	8436	8511	8436
q10	4510	4556	4238	4238
q11	596	450	410	410
q12	704	735	530	530
q13	3314	3610	2925	2925
q14	304	310	271	271
q15	q16	768	788	802	788
q17	1342	1287	1267	1267
q18	7953	7120	7007	7007
q19	1156	1170	1163	1163
q20	2237	2207	1929	1929
q21	6146	5428	4866	4866
q22	544	508	414	414
Total cold run time: 60252 ms
Total hot run time: 54396 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 170433 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 7aae0b6b091942580609be80d534c19ec72cc087, data reload: false

query5	4319	645	525	525
query6	334	229	201	201
query7	4226	595	308	308
query8	337	245	228	228
query9	8819	4058	4035	4035
query10	455	348	312	312
query11	5723	2405	2247	2247
query12	190	130	125	125
query13	1307	596	428	428
query14	5982	5352	5086	5086
query14_1	4393	4383	4358	4358
query15	214	203	187	187
query16	990	476	451	451
query17	1087	813	633	633
query18	2449	504	365	365
query19	224	217	177	177
query20	145	135	134	134
query21	219	150	119	119
query22	13717	13669	14570	13669
query23	17363	16460	16190	16190
query23_1	16384	16224	16176	16176
query24	7499	1744	1407	1407
query24_1	1361	1340	1336	1336
query25	573	477	425	425
query26	1307	310	167	167
query27	2737	563	345	345
query28	4384	1966	1935	1935
query29	968	629	510	510
query30	304	233	198	198
query31	1099	1056	942	942
query32	77	74	74	74
query33	541	345	299	299
query34	1181	1115	654	654
query35	764	775	673	673
query36	1319	1343	1177	1177
query37	143	99	82	82
query38	3186	3148	3076	3076
query39	929	915	885	885
query39_1	875	868	890	868
query40	233	149	135	135
query41	64	62	58	58
query42	107	104	103	103
query43	319	326	280	280
query44	
query45	257	201	198	198
query46	1066	1228	700	700
query47	2310	2265	2186	2186
query48	393	410	308	308
query49	626	534	438	438
query50	709	288	213	213
query51	4286	4307	4226	4226
query52	105	105	92	92
query53	246	278	203	203
query54	306	270	253	253
query55	92	90	83	83
query56	301	317	293	293
query57	1391	1410	1303	1303
query58	317	279	267	267
query59	1564	1622	1393	1393
query60	349	336	322	322
query61	156	158	153	153
query62	670	618	561	561
query63	241	199	198	198
query64	2420	836	688	688
query65	
query66	1739	516	392	392
query67	30097	29946	29929	29929
query68	
query69	446	341	314	314
query70	1001	996	978	978
query71	306	270	266	266
query72	2868	2706	2443	2443
query73	835	779	453	453
query74	5050	4902	4750	4750
query75	2784	2669	2351	2351
query76	2282	1142	749	749
query77	430	436	348	348
query78	12802	13023	12332	12332
query79	1491	976	744	744
query80	1229	573	478	478
query81	503	291	239	239
query82	1376	160	130	130
query83	367	282	249	249
query84	276	141	109	109
query85	904	510	435	435
query86	421	362	324	324
query87	3399	3369	3241	3241
query88	3524	2669	2647	2647
query89	435	375	328	328
query90	1774	181	177	177
query91	180	168	138	138
query92	73	73	74	73
query93	984	950	556	556
query94	608	347	307	307
query95	686	451	343	343
query96	1067	783	313	313
query97	2682	2688	2543	2543
query98	257	227	225	225
query99	1121	1139	1005	1005
Total cold run time: 253681 ms
Total hot run time: 170433 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 77.79% (1573/2022) 🎉
Increment coverage report
Complete coverage report

@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

yujun777 and others added 21 commits May 20, 2026 19:37
IvmDeltaCommandBundle was a trivial wrapper around Command with no extra
fields. Replace it with Command directly throughout the IVM pipeline.

Key changes:
- Delete IvmDeltaCommandBundle.java
- Change IvmDeltaStrategy.rewrite() return type to List<Command>
- Update IvmDeltaRewriter, IvmDeltaExecutor, IvmRefreshManager signatures
- Update all IVM test files accordingly

Unit Test: all 42 IVM FE unit tests pass
Use the aggregate row-id slot when checking grouped aggregate determinism instead of relying on insertion order from the normalize result map.

Key changes:
- Assert determinism through normalizeResult.isDeterministic(rowIdAlias.toSlot()).
- Keep child scan row-id tracking behavior unchanged.

Unit Test:
- ./run-fe-ut.sh --run org.apache.doris.nereids.rules.rewrite.IvmNormalizeMtmvTest#testGroupedAggInjectsRowIdAndHiddenColumns
- ./run-fe-ut.sh --run org.apache.doris.mtmv.ivm.IvmStreamRefTest,org.apache.doris.mtmv.ivm.IvmNormalizeMtmvUnionTest,org.apache.doris.mtmv.ivm.IvmAggDeltaStrategyTest,org.apache.doris.mtmv.ivm.IvmUtilTest,org.apache.doris.mtmv.ivm.IvmRefreshManagerTest,org.apache.doris.mtmv.ivm.IvmDeltaExecutorTest,org.apache.doris.mtmv.ivm.IvmSimpleScanDeltaStrategyTest,org.apache.doris.mtmv.ivm.IvmNormalizeMtmvJoinTest,org.apache.doris.mtmv.ivm.IvmDeltaRewriterTest,org.apache.doris.nereids.rules.rewrite.IvmNormalizeMtmvTest

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ategy

The class no longer covers only scan/project. It also handles inner join
and union all, and is the home for any operator whose delta propagates
linearly (output delta = combination of input deltas without base-table
lookup or aggregate replay). Rename it to reflect the actual scope; outer
join will get its own strategy in the future.

Key changes:
- Rename IvmSimpleScanDeltaStrategy -> IvmLinearDeltaStrategy (main + test)
  via git mv to preserve history
- Update all references in IvmAggDeltaStrategy, IvmDeltaRewriter, tests,
  and mtmv/ivm/AGENTS.md
- Rewrite class Javadoc to describe linear delta propagation and the
  currently supported operators (Scan/Project/Filter/InnerJoin/UnionAll)

Unit Test:
- IvmLinearDeltaStrategyTest: 32/32 pass
- IvmAggDeltaStrategyTest: 25/25 pass
- IvmDeltaRewriterTest: 21/21 pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
run() was ~147 lines mixing partition sync, refresh planning,
IVM fast-path and partition-based execution. Extract three private
helpers; the moved blocks are kept verbatim.

Key changes:
- Extract syncPartitionsIfNeeded(ctx, tableIfs): schema-change check,
  pct table validity, alignMvPartition + drop/add partitions
- Extract tryIvmFastPath(): IVM AUTO/INCREMENTAL fast path; returns
  true if IVM completed the refresh, false to fall through to
  partition-based refresh; throws JobException on INCREMENTAL failure.
  Use early-return guard for the non-IVM case
- Extract executePartitionBasedRefresh(context): TSO capture, batch
  exec loop and post-refresh IVM state reset

Unit Test:
- MTMVTaskTest: 7/7 pass
- IvmLinearDeltaStrategyTest: 32/32 pass
- IvmAggDeltaStrategyTest: 25/25 pass
- IvmDeltaRewriterTest: 21/21 pass
- IvmRefreshManagerTest: 17/17 pass

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
### What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary: AUTO refresh materialized views that are eligible for incremental refresh should be persisted as IVM MVs. Before this change, CreateMTMVInfo.isEnableIvm() only checked whether the refresh method was explicitly INCREMENTAL, so AUTO MVs stayed non-IVM even when query analysis could build an incremental-refresh plan.

Root cause: In CreateMTMVInfo.isEnableIvm(), the IVM flag was derived directly from RefreshMethod.INCREMENTAL, which ignored AUTO refresh capability decided during create-time query analysis.

This patch introduces an independent create-time enableIvm flag. AUTO refresh MVs probe IVM capability through analyzeQuery(); if the probe succeeds, the MV keeps IVM metadata, and if it fails, analysis state is restored and the MV continues as a normal non-IVM MV. Explicit INCREMENTAL remains strict and does not fallback.

### Release note

Fixed an issue where AUTO materialized views that can be incrementally refreshed were not persisted as IVM materialized views.

### Check List (For Author)

- Test: Regression test and Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.mtmv.ivm.IvmDeltaExecutorTest,org.apache.doris.mtmv.ivm.IvmStreamRefTest,org.apache.doris.mtmv.ivm.IvmNormalizeMtmvJoinTest,org.apache.doris.mtmv.ivm.IvmAggDeltaStrategyTest,org.apache.doris.mtmv.ivm.IvmDeltaRewriterTest,org.apache.doris.mtmv.ivm.IvmRefreshManagerTest,org.apache.doris.mtmv.ivm.IvmNormalizeMtmvUnionTest,org.apache.doris.mtmv.ivm.IvmLinearDeltaStrategyTest,org.apache.doris.mtmv.ivm.IvmUtilTest,org.apache.doris.nereids.rules.rewrite.IvmNormalizeMtmvTest,org.apache.doris.nereids.trees.plans.CreateMTMVCommandTest,org.apache.doris.catalog.ShowCreateMTMVTest
    - ./run-regression-test.sh --run -d mtmv_p0/ivm
- Behavior changed: Yes. AUTO MVs that pass create-time IVM analysis now persist IVM metadata.
- Does this need documentation: No
Issue Number: None

Related PR: None

Problem Summary: IVM delta refresh did not surface base table binlog-disabled cases to MV task info, so AUTO refresh could silently fall back without a task-visible reason.

Record IVM fallback reason in MV task info when base table binlog is disabled.

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.nereids.rules.rewrite.IvmNormalizeMtmvTest,org.apache.doris.mtmv.ivm.IvmRefreshManagerTest,org.apache.doris.mtmv.MTMVTaskTest
- Behavior changed: Yes (IVM AUTO refresh records BINLOG_NOT_ENABLED fallback reason; explicit INCREMENTAL refresh still fails on IVM fallback)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: AUTO MTMV query analysis used a boolean return value only to make the caller retry regular analysis after IVM probe fallback. Move that retry into the helper so the caller only selects the analysis path.

### Release note

None

### Check List (For Author)

- Test: Manual test
    - git diff --check -- fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
- Behavior changed: No
- Does this need documentation: No
Implement O1 delta rewrite for root LEFT OUTER JOIN IVM MVs and route normalized outer-join MVs to the new strategy. Keep full refresh behavior independent from unfinished TSO binding by clearing only the stale running refresh flag for now.

Key changes:
- Add outer join delta strategy for preserved-side delta, nullable-side joined delta, and pad-null repair rows.
- Mark and validate outer join MVs during IVM normalization, including root-only restrictions and nullable-side snapshot limitations.
- Merge delta rewrite context into IvmRefreshContext and keep base table stream lookup centralized.
- Add FE unit tests and regression coverage for supported and unsupported outer join IVM cases.

Unit Test:
- FE UT: IVM unit tests plus CreateMTMVCommandTest, 189 tests passed.
- Regression: mtmv_p0/ivm, 18 suites passed.
- Check: git diff --check.
Optimize nullable-side left outer join IVM rewrites by converting pure equi-join right deltas into right-side events, so the preserved-side snapshot is probed once while preserving fallback behavior for general join predicates.

Key changes:
- Build right-event plans for detail rows and padded-null repair rows on pure deterministic equi join keys.
- Fall back to repair branches when residual non-hash predicates or unique functions appear in join keys.
- Add comments explaining the event rewrite and extend outer join IVM FE/regression coverage.

Unit Test:
- IvmOuterJoinDeltaStrategyTest
- Regression test: test_ivm_outer_join_1
### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: AUTO refresh MTMV uses IVM analysis as a capability probe before falling back to regular MTMV analysis. When the IVM probe fails after mutating the create state, the fallback path can reuse polluted analyze state and fail cases that should be accepted by regular MTMV analysis. This change restores the create state, reparses the original query through the same query parser path used by CREATE MTMV, resets the statement context, and then reruns regular analysis.

### Release note

None

### Check List (For Author)

- Test: Regression test / Unit Test
    - `mvn test -pl fe-core -am -Dcheckstyle.skip=true -DfailIfNoTests=false -Dmaven.build.cache.enabled=false -Dtest=org.apache.doris.nereids.trees.plans.CreateMTMVCommandTest -Dfe_ut_parallel=0`
    - `./run-regression-test.sh --run -d nereids_rules_p0/mv/increment_create -s self_conn_list_str_increment_create`
    - `./run-regression-test.sh --run -d nereids_rules_p0/mv/increment_create -s self_conn_range_date_increment_create`
    - `./run-regression-test.sh --run -d nereids_rules_p0/mv/increment_create -s self_conn_range_number_increment_create`
- Behavior changed: Yes. AUTO refresh MTMV now treats IVM probe analysis failures as capability probe failures and retries clean regular MTMV analysis.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Add EXPLAIN REFRESH MATERIALIZED VIEW ... INCREMENTAL support for IVM dry-run debugging, including normalized plan overview and per-delta logical plan inspection.

### Release note

Add EXPLAIN REFRESH MATERIALIZED VIEW ... INCREMENTAL for IVM refresh plan debugging.

### Check List (For Author)

- Test: Unit Test and Regression test
    - Unit Test: mvn test -Dcheckstyle.skip=true -DfailIfNoTests=false -Dmaven.build.cache.enabled=false -Dfe_ut_parallel=0 -Dtest=org.apache.doris.nereids.trees.plans.commands.ExplainRefreshIvmCommandTest
    - Unit Test: mvn test -Dcheckstyle.skip=true -DfailIfNoTests=false -Dmaven.build.cache.enabled=false -Dfe_ut_parallel=0 -Dtest=Ivm*Test,CreateMTMVCommandTest,ShowCreateMTMVTest,ExplainRefreshIvmCommandTest
    - Regression test: ./run-regression-test.sh --run -d mtmv_p0/ivm -s test_ivm_explain_refresh
    - Regression test: ./run-regression-test.sh --run -d mtmv_p0/ivm
- Behavior changed: Yes. Adds a new EXPLAIN command form for IVM refresh dry-run plans.
- Does this need documentation: Yes. IVM developer guidance was updated in fe/fe-core/src/main/java/org/apache/doris/mtmv/ivm/AGENTS.md.
Add EXPLAIN REFRESH handling for IVM dry-run overview and per-delta plans, including planner explain support for a selected delta.

Key changes:

- Add ExplainRefreshIvmCommand for overview and FOR DELTA explain paths.

- Format IVM normalized and delta plan metadata in explain output.

- Add FE unit coverage and an IVM explain refresh regression case with non-empty base tables.

Unit Test:

- ExplainRefreshIvmCommandTest

- mtmv_p0/ivm/test_ivm_explain_refresh
Keep ExplainRefreshIvmCommand aligned with FE style by removing an unused import and wrapping a long method signature.

Key changes:

- Remove unused java.util.List import.

- Wrap explainDeltaPlan parameters to satisfy style.

Unit Test:

- Not run; format-only change.
Extend IVM normalization and delta rewriting so left outer join chains can propagate through non-aggregate plans and root aggregates.

Key changes:
- Track nullable-side context while normalizing IVM plans and reject outer joins only inside left outer join nullable sides.
- Route non-aggregate rewrites through the outer join strategy and let aggregate strategy inherit outer join handling.
- Remove the normalize-result outer join flag and add positive and negative coverage for the new O2 topology.

Unit Test:
- IvmNormalizeMtmvJoinTest, IvmOuterJoinDeltaStrategyTest, IvmAggDeltaStrategyTest, IvmDeltaRewriterTest
- All IVM FE UTs
- mtmv_p0/ivm regression suites
Generalize IVM outer join delta rewrite and normalize checks from left-outer-only assumptions to preserved/nullable side handling, enabling right outer join while keeping nullable-side restrictions explicit.

Key changes:
- Make IvmOuterJoinDeltaStrategy side-aware for preserved-side and nullable-side deltas.
- Allow RIGHT_OUTER_JOIN in IVM normalize and move nullable-side UNION ALL with OlapScan rejection to UNION handling.
- Add FE UT coverage for right outer join normalize and delta rewrite paths.
- Split large outer join regression into smaller suites and add right outer join regression cases.

Unit Test:
- IvmNormalizeMtmvJoinTest
- IvmOuterJoinDeltaStrategyTest
- mtmv_p0/ivm test_ivm_outer_join_1,test_ivm_outer_join_2,test_ivm_outer_join_3
- mtmv_p0/ivm full regression
Unify IVM delta rewriting through the aggregate strategy entry point and remove the bare delta strategy interface. Pass refresh context explicitly through linear and outer join strategies so strategy instances no longer hold per-refresh state.

Key changes:
- Add singleton entry for IvmAggDeltaStrategy and route IvmDeltaRewriter through it.
- Remove IvmDeltaStrategy and make linear/outer join strategy context handling visitor-based.
- Update normalize result tests to check aggregate metadata directly.
- Clean fully qualified class references from IVM FE unit tests.
- Document that IVM FE unit test runs must include CreateMTMVCommandTest.

Unit Test:
- IvmAggDeltaStrategyTest, IvmDeltaExecutorTest, IvmDeltaRewriterTest, IvmLinearDeltaStrategyTest, IvmNormalizeMtmvJoinTest, IvmNormalizeMtmvUnionTest, IvmOuterJoinDeltaStrategyTest, IvmRefreshManagerTest, IvmStreamRefTest, IvmUtilTest, IvmNormalizeMtmvTest, ExplainRefreshIvmCommandTest
- Regression test mtmv_p0/ivm
Split the IVM delta rewrite implementation into linear, outer join, and aggregate handlers coordinated by a visitor and command builder.

Key changes:
- Replace the strategy inheritance chain with independent handler classes.
- Move shared rewrite utilities into IvmDeltaRewriteHelper.
- Add IvmDeltaCommandBuilder for wrapping rewritten plans into insert commands.
- Keep project dispatch in the visitor while routing aggregate-root projects to the aggregate handler.
- Update IVM tests and CreateMTMVCommandTest coverage for filter above outer join.

Unit Test:
- IVM FE unit test set, including CreateMTMVCommandTest.
- IvmDeltaRewriterTest and IvmLinearDeltaHandlerTest.
- mtmv_p0/ivm regression suites.
…ling

Move the nullable-side UNION ALL rejection down to the OlapScan check, and track union nesting explicitly in the normalize context so outer-join rules can reason about the actual scan position.

Key changes:
- Add an inside-union flag to NormalizeContext and reuse a child context while visiting UNION children.
- Reject non-excluded OlapScan under nullable-side UNION ALL during scan normalization instead of at the union node.
- Add regression coverage for UNION DISTINCT and project-wrapped scan cases under nullable-side outer joins.

Unit Test:
- tools/fast-compile-fe.sh --test IvmNormalizeMtmvJoinTest.java
- mvn test for IVM FE UT subset including IvmNormalizeMtmvJoinTest, IvmNormalizeMtmvTest, and CreateMTMVCommandTest
- IvmNormalizeMtmvTest and IvmNormalizeMtmvJoinTest passed; CreateMTMVCommandTest passed; remaining failures were environment-related in other tests
Fix FE compilation and checkstyle issues left by the IVM branch rebase onto upstream master.

Key changes:

- Add missing Consumer imports for MTMV command execution customizers.

- Replace removed containsUniqueFunction API with containsVolatileExpression for IVM outer join key validation.

- Update MTMV refresh test code for the RefreshMode-based RefreshMTMVInfo constructor and import order.

Unit Test:

- build.sh --fe
Support IVM rewrite for full outer joins and clean up outer join retained/null-side validation.

Key changes:
- Normalize full outer joins with retained/null-side row-id checks and null-side nested-outer-join rejection.
- Refactor outer join delta rewrite to handle left, right, and full outer joins with shared retained/null-side repair logic.
- Add FE unit and regression coverage for full outer join behavior under current mock-full-scan delta semantics.

Unit Test:
- IvmNormalizeMtmvJoinTest
- IvmOuterJoinDeltaHandlerTest
- CreateMTMVCommandTest
- IVM FE unit test batch
- mtmv_p0/ivm regression suite
- FE build and fast FE compile
@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31203 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit cdd582ad143ec48df32a839105dd312f4aeddb08, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17741	3914	3884	3884
q2	q3	10767	1445	826	826
q4	4695	481	351	351
q5	7591	2258	2108	2108
q6	241	178	138	138
q7	957	808	667	667
q8	9436	1886	1666	1666
q9	6744	4991	4895	4895
q10	6461	2135	1793	1793
q11	445	272	253	253
q12	704	426	302	302
q13	18185	3474	2747	2747
q14	266	257	234	234
q15	q16	831	767	711	711
q17	950	883	955	883
q18	6975	5783	5477	5477
q19	1220	1246	1164	1164
q20	526	438	274	274
q21	6055	2819	2520	2520
q22	459	369	310	310
Total cold run time: 101249 ms
Total hot run time: 31203 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4585	4483	4806	4483
q2	q3	4781	5327	4643	4643
q4	2417	2241	1388	1388
q5	4863	4765	4709	4709
q6	235	179	128	128
q7	1843	1748	1495	1495
q8	2445	1911	1972	1911
q9	7315	7221	7252	7221
q10	4471	4390	3971	3971
q11	534	381	344	344
q12	713	715	514	514
q13	3030	3385	2809	2809
q14	269	275	261	261
q15	q16	690	711	612	612
q17	1254	1234	1229	1229
q18	7358	6834	6750	6750
q19	1103	1114	1080	1080
q20	2226	2226	1947	1947
q21	5287	4572	4456	4456
q22	524	453	405	405
Total cold run time: 55943 ms
Total hot run time: 50356 ms

Update the MTMV refresh unit test to validate FE planning and translation instead of executing INSERT or refresh work that requires a real BE. Also make IVM rewrite session state cleanup local to the tests that enable it.

Key changes:

- Remove real data INSERT and refresh execution from the one-row complete MTMV test.

- Verify the generated refresh plan translates to an OlapTableSink fragment.

- Reset enableIvmNormalRewrite in finally blocks for tests that enable it.

Unit Test:

- UpdateMvByPartitionCommandTest

- IVM FE unit test batch

- mtmv_p0/ivm regression suites
@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169980 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit cdd582ad143ec48df32a839105dd312f4aeddb08, data reload: false

query5	4332	700	522	522
query6	336	226	205	205
query7	4246	582	313	313
query8	328	237	217	217
query9	8805	4066	4047	4047
query10	451	337	294	294
query11	5821	2411	2285	2285
query12	187	141	131	131
query13	1274	607	435	435
query14	6052	5393	5226	5226
query14_1	4418	4414	4392	4392
query15	212	206	186	186
query16	1052	452	431	431
query17	1140	718	602	602
query18	2462	496	347	347
query19	218	203	159	159
query20	143	137	132	132
query21	212	141	122	122
query22	13667	13580	13403	13403
query23	17154	16345	16013	16013
query23_1	16052	16203	16208	16203
query24	7335	1777	1312	1312
query24_1	1323	1330	1312	1312
query25	585	493	425	425
query26	1297	345	179	179
query27	2667	567	351	351
query28	4442	1928	1972	1928
query29	1006	632	496	496
query30	304	244	200	200
query31	1103	1059	935	935
query32	87	103	76	76
query33	535	367	312	312
query34	1207	1123	647	647
query35	759	778	689	689
query36	1336	1335	1156	1156
query37	159	107	87	87
query38	3212	3131	3097	3097
query39	922	928	896	896
query39_1	895	889	865	865
query40	228	152	132	132
query41	67	62	62	62
query42	111	112	111	111
query43	324	330	284	284
query44	
query45	209	203	194	194
query46	1090	1260	747	747
query47	2373	2345	2185	2185
query48	403	428	287	287
query49	648	508	415	415
query50	1022	356	253	253
query51	4327	4353	4266	4266
query52	107	106	95	95
query53	252	300	208	208
query54	315	277	269	269
query55	97	92	88	88
query56	305	316	305	305
query57	1426	1382	1312	1312
query58	300	277	269	269
query59	1565	1603	1396	1396
query60	329	334	309	309
query61	167	162	168	162
query62	664	620	558	558
query63	239	211	209	209
query64	2442	852	722	722
query65	
query66	1798	468	347	347
query67	30134	29437	29243	29243
query68	
query69	465	355	320	320
query70	1018	966	948	948
query71	304	284	274	274
query72	3050	2693	2420	2420
query73	872	765	428	428
query74	5070	4917	4759	4759
query75	2690	2606	2265	2265
query76	2317	1168	787	787
query77	402	431	329	329
query78	12180	12121	11653	11653
query79	1250	1019	748	748
query80	611	603	497	497
query81	452	282	245	245
query82	260	166	129	129
query83	371	295	260	260
query84	273	148	121	121
query85	993	552	454	454
query86	405	315	310	310
query87	3393	3502	3213	3213
query88	3554	2676	2626	2626
query89	427	402	346	346
query90	1906	184	187	184
query91	183	169	142	142
query92	80	80	79	79
query93	1475	1427	863	863
query94	543	373	321	321
query95	701	404	450	404
query96	1042	884	334	334
query97	2668	2688	2539	2539
query98	238	235	232	232
query99	1109	1113	979	979
Total cold run time: 251986 ms
Total hot run time: 169980 ms

@yujun777
Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31264 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 02eed18007cfb9c270cc5f8a007172f4745e03ec, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17635	3870	3873	3870
q2	q3	10754	1403	862	862
q4	4713	473	351	351
q5	7902	2237	2110	2110
q6	369	179	140	140
q7	986	785	663	663
q8	9466	1786	1655	1655
q9	7108	4915	4920	4915
q10	6466	2174	1811	1811
q11	433	273	246	246
q12	636	425	295	295
q13	18137	3504	2823	2823
q14	273	255	235	235
q15	q16	827	780	703	703
q17	975	957	1018	957
q18	7021	5706	5491	5491
q19	1164	1249	1183	1183
q20	508	413	256	256
q21	5601	2592	2397	2397
q22	430	365	301	301
Total cold run time: 101404 ms
Total hot run time: 31264 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4208	4115	4097	4097
q2	q3	4546	4948	4296	4296
q4	2146	2210	1436	1436
q5	4386	4243	4483	4243
q6	294	225	154	154
q7	2025	1838	1626	1626
q8	2448	2137	2078	2078
q9	7698	7826	7636	7636
q10	4555	4491	4090	4090
q11	781	414	381	381
q12	728	759	517	517
q13	3325	3618	3019	3019
q14	313	305	269	269
q15	q16	706	754	642	642
q17	1344	1363	1286	1286
q18	8075	7385	6868	6868
q19	1130	1120	1097	1097
q20	2218	2227	1925	1925
q21	5338	4673	4520	4520
q22	539	458	417	417
Total cold run time: 56803 ms
Total hot run time: 50597 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 169846 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 02eed18007cfb9c270cc5f8a007172f4745e03ec, data reload: false

query5	4346	656	538	538
query6	338	227	207	207
query7	4243	581	313	313
query8	340	252	243	243
query9	8851	4061	4008	4008
query10	453	335	293	293
query11	5798	2441	2199	2199
query12	191	134	134	134
query13	1283	578	427	427
query14	6046	5401	5076	5076
query14_1	4375	4352	4383	4352
query15	218	212	182	182
query16	994	460	464	460
query17	1167	749	618	618
query18	2494	503	365	365
query19	221	213	166	166
query20	142	133	138	133
query21	224	148	121	121
query22	13541	13517	13308	13308
query23	17092	16454	15986	15986
query23_1	16065	16252	16103	16103
query24	7441	1754	1303	1303
query24_1	1338	1319	1331	1319
query25	581	497	443	443
query26	1319	337	171	171
query27	2694	560	329	329
query28	4429	1967	1980	1967
query29	1038	639	532	532
query30	311	232	206	206
query31	1111	1083	954	954
query32	93	81	76	76
query33	553	357	311	311
query34	1197	1118	649	649
query35	813	776	683	683
query36	1336	1345	1203	1203
query37	155	107	88	88
query38	3210	3152	3028	3028
query39	935	923	895	895
query39_1	875	880	875	875
query40	229	144	128	128
query41	66	62	62	62
query42	113	107	108	107
query43	321	327	283	283
query44	
query45	209	205	192	192
query46	1076	1190	713	713
query47	2334	2378	2215	2215
query48	410	424	314	314
query49	633	482	385	385
query50	960	340	255	255
query51	4315	4287	4213	4213
query52	108	108	95	95
query53	258	271	218	218
query54	311	282	267	267
query55	92	90	85	85
query56	305	325	312	312
query57	1432	1401	1275	1275
query58	287	306	261	261
query59	1528	1618	1443	1443
query60	325	329	321	321
query61	151	159	155	155
query62	680	629	566	566
query63	243	202	211	202
query64	2421	805	637	637
query65	
query66	1726	481	355	355
query67	30019	30009	29813	29813
query68	
query69	472	340	304	304
query70	1021	1051	961	961
query71	311	279	274	274
query72	3031	2705	2508	2508
query73	855	801	411	411
query74	5090	4908	4718	4718
query75	2681	2631	2251	2251
query76	2321	1144	764	764
query77	401	412	325	325
query78	12319	12112	11656	11656
query79	1466	1041	743	743
query80	656	540	459	459
query81	481	276	239	239
query82	1353	160	128	128
query83	383	283	249	249
query84	270	140	111	111
query85	882	546	466	466
query86	415	342	309	309
query87	3418	3379	3164	3164
query88	3545	2684	2655	2655
query89	439	380	341	341
query90	1957	182	184	182
query91	176	171	142	142
query92	79	80	76	76
query93	1588	1403	911	911
query94	551	368	324	324
query95	676	375	450	375
query96	1106	776	325	325
query97	2713	2717	2569	2569
query98	241	233	239	233
query99	1108	1107	1009	1009
Total cold run time: 253438 ms
Total hot run time: 169846 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 79.35% (2017/2542) 🎉
Increment coverage report
Complete coverage report

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.

5 participants