Skip to content

[draft](ivm) for run the test pipeline#61496

Draft
yujun777 wants to merge 23 commits intoapache:masterfrom
yujun777:ivm-yj-1
Draft

[draft](ivm) for run the test pipeline#61496
yujun777 wants to merge 23 commits intoapache:masterfrom
yujun777:ivm-yj-1

Conversation

@yujun777
Copy link
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
Contributor

Thearas commented Mar 18, 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
Contributor Author

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 26843 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 289882c2417314ec86137188792dc2435d5b89f0, 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	17620	4500	4281	4281
q2	q3	10649	767	518	518
q4	4675	345	255	255
q5	7552	1197	1019	1019
q6	171	174	146	146
q7	785	852	674	674
q8	9310	1499	1375	1375
q9	4726	4674	4627	4627
q10	6245	1892	1627	1627
q11	446	264	235	235
q12	698	582	467	467
q13	18040	2929	2207	2207
q14	230	240	208	208
q15	q16	718	734	673	673
q17	725	822	486	486
q18	5898	5381	5327	5327
q19	1235	990	614	614
q20	542	494	378	378
q21	4716	1844	1391	1391
q22	345	335	436	335
Total cold run time: 95326 ms
Total hot run time: 26843 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	4809	4636	4602	4602
q2	q3	3900	4318	3806	3806
q4	899	1237	791	791
q5	4103	4379	4361	4361
q6	183	175	170	170
q7	1804	1693	1527	1527
q8	2491	2694	2580	2580
q9	7612	7393	7511	7393
q10	3853	4016	3609	3609
q11	518	440	422	422
q12	500	613	459	459
q13	2802	3231	2443	2443
q14	293	306	281	281
q15	q16	706	765	719	719
q17	1141	1333	1282	1282
q18	7178	6894	6708	6708
q19	895	881	902	881
q20	2077	2156	2000	2000
q21	3955	3687	3329	3329
q22	467	417	375	375
Total cold run time: 50186 ms
Total hot run time: 47738 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 168011 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 289882c2417314ec86137188792dc2435d5b89f0, data reload: false

query5	4327	663	514	514
query6	334	228	207	207
query7	4226	462	262	262
query8	334	244	223	223
query9	8735	2694	2683	2683
query10	495	398	361	361
query11	6963	5089	4902	4902
query12	194	134	125	125
query13	1274	468	356	356
query14	5808	3721	3495	3495
query14_1	2863	2862	2908	2862
query15	205	192	181	181
query16	986	470	463	463
query17	898	757	627	627
query18	2452	450	353	353
query19	233	212	190	190
query20	140	130	133	130
query21	216	137	113	113
query22	13178	13406	13154	13154
query23	15901	15482	15804	15482
query23_1	15876	15712	15669	15669
query24	7441	1661	1266	1266
query24_1	1270	1329	1270	1270
query25	613	486	451	451
query26	1388	278	167	167
query27	3326	514	313	313
query28	4467	1822	1806	1806
query29	840	574	479	479
query30	296	221	187	187
query31	1027	952	894	894
query32	93	74	73	73
query33	512	336	280	280
query34	907	901	527	527
query35	638	663	602	602
query36	1087	1132	956	956
query37	131	95	81	81
query38	2962	2920	2886	2886
query39	842	862	822	822
query39_1	800	792	784	784
query40	234	149	140	140
query41	67	58	58	58
query42	261	258	254	254
query43	245	260	216	216
query44	
query45	196	194	186	186
query46	872	980	619	619
query47	2109	2108	2043	2043
query48	306	338	225	225
query49	636	454	387	387
query50	680	274	207	207
query51	4093	4075	4021	4021
query52	267	267	262	262
query53	292	343	281	281
query54	320	278	266	266
query55	92	93	82	82
query56	326	322	329	322
query57	1920	1884	1623	1623
query58	293	279	282	279
query59	2800	2970	2740	2740
query60	339	338	330	330
query61	165	159	159	159
query62	638	592	534	534
query63	310	281	276	276
query64	5079	1301	1042	1042
query65	
query66	1474	468	364	364
query67	24292	24335	24177	24177
query68	
query69	403	316	287	287
query70	918	946	997	946
query71	343	308	304	304
query72	2829	2751	2691	2691
query73	551	550	315	315
query74	9632	9555	9453	9453
query75	2904	2798	2533	2533
query76	2298	1036	684	684
query77	378	409	326	326
query78	11113	11177	10476	10476
query79	1111	751	561	561
query80	853	647	546	546
query81	531	263	220	220
query82	1353	157	131	131
query83	372	265	245	245
query84	301	118	109	109
query85	988	500	482	482
query86	404	305	293	293
query87	3140	3128	3043	3043
query88	3533	2653	2655	2653
query89	421	369	342	342
query90	1859	180	171	171
query91	175	165	136	136
query92	81	75	74	74
query93	929	838	498	498
query94	549	323	306	306
query95	603	395	322	322
query96	638	517	229	229
query97	2440	2460	2387	2387
query98	235	223	220	220
query99	1011	985	914	914
Total cold run time: 250050 ms
Total hot run time: 168011 ms

@yujun777 yujun777 force-pushed the ivm-yj-1 branch 2 times, most recently from dc5d312 to c1b3f3a Compare March 19, 2026 01:29
yujun777 added 19 commits March 19, 2026 09:29
…ogging

- Require non-null detailMessage in IVMRefreshResult.fallback() to match
  IVMCapabilityResult.unsupported() contract; remove single-arg overload
- Add toString() to IVMRefreshResult for log readability
- Add WARN logging on all fallback paths in IVMRefreshManager with MV name
- Make doRefresh() the public API; remove redundant ivmRefresh() wrapper
- Remove IVMPlanPattern, IVMPlanAnalysis, IVMPlanAnalyzer, IVMDeltaPlannerDispatcher
- IVMCapabilityChecker now takes List<DeltaPlanBundle> instead of IVMPlanAnalysis
- IVMRefreshManager simplified to 2 deps: capabilityChecker + deltaExecutor
- Delta bundles produced by Nereids rules, retrieved via MTMVAnalyzeQueryInfo
- Add analyzeDeltaBundles() hook for testability
- Add ivmDeltaBundles to MTMVAnalyzeQueryInfo, populated from CascadesContext
- Update tests to JUnit 5 and new interface signatures
- Fix checkstyle import order in CreateTableCommandTest
- Delete IvmRewriteMtmvPlan placeholder and its test
- Remove rewriteRootPlan field from CascadesContext (no longer needed)
- Replace IVM_REWRITE_MTMV_PLAN with IVM_NORMALIZE_MTMV_PLAN in RuleType
- Add IvmNormalizeMtmvPlan skeleton (row-id injection, avg rewrite, TODO)
- Add IvmDeltaScanOnly and IvmDeltaAggRoot skeletons
- Merge delta rules into single topic in Rewriter
- Add IvmAnalyzeMode enum (NONE/NORMALIZE_ONLY/FULL) to replace boolean flags
- Replace enableIvmRewriteInNereids with enableIvmNormalRewrite + enableIvmDeltaRewrite
- MTMVPlanUtil.analyzeQuery/analyzeQueryWithSql take IvmAnalyzeMode parameter
- CreateMTMVInfo: NORMALIZE_ONLY for incremental MV, NONE otherwise
- ensureMTMVQueryUsable: same mode as CREATE MV
- IVMRefreshManager: FULL mode (normalize + delta)
- Update IvmNormalizeMtmvPlan/IvmDeltaScanOnly/IvmDeltaAggRoot to use new session vars
- Fix MTMVPlanUtilTest: JUnit5, IvmAnalyzeMode.NONE, updated CountingSessionVariable
- Add testAnalyzeQueryIvmAnalyzeModeSetSessionVariables covering all 3 modes
- Add IvmContext: holds Map<Slot, isDeterministic> rowIdDeterminism + List<DeltaPlanBundle>
- Replace ivmDeltaBundles in CascadesContext with Optional<IvmContext>
- IvmNormalizeMtmvPlan: whitelist-based visitor (DefaultPlanRewriter<IvmContext>)
  - visitLogicalOlapScan: inject __IVM_ROW_ID__ at index 0 via LogicalProject
    - MOW: Alias(buildRowIdHash(uk...), __IVM_ROW_ID__) -> deterministic
    - DUP_KEYS: Alias(UuidNumeric(), __IVM_ROW_ID__) -> non-deterministic
    - MOR / AGG_KEYS: throw AnalysisException
  - visitLogicalProject: propagate child row-id; throw if child has none
  - visit: throw for any unwhitelisted node
  - buildRowIdHash: uses murmur_hash3_64 (TODO: replace with 128-bit hash)
- MTMVPlanUtil: read delta bundles from IvmContext instead of direct field
- Tests: DUP_KEYS, MOW (deterministic), MOR (throws), AGG_KEYS (throws),
  project propagation, unsupported node, gate disabled
- IvmNormalizeMtmvPlan: whitelist LogicalResultSink, prepend row-id;
  extract hasRowIdInOutputs/prependRowId helpers
- ColumnDefinition: add newIvmRowIdColumnDefinition with mv_ prefix
- MTMVPlanUtil: prepend row-id ColumnDefinition at index 0; reset IVM
  session vars in finally block to prevent test leakage
- BaseViewInfo: extract static rewriteProjectsToUserDefineAlias overload
- CreateMTMVInfo: fix rewriteQuerySql to snapshot/restore rewrite map
  and call alias rewrite when simpleColumnDefinitions present
- CreateTableCommandTest: add 4 IVM UTs covering scan, project-scan,
  no-alias, alias rewrite, and column count mismatch
- CreateMTMVInfo: set UNIQUE_KEYS + enable_unique_key_merge_on_write=true
  for INCREMENTAL refresh MVs; reject user-specified key columns
- MTMVPlanUtil.analyzeKeys: return new List instead of mutating the
  immutable input list; throw if IVM row-id column not found in columns
- MTMVPlanUtil.analyzeQuery: only reset IVM session vars in finally block
  for modes that actually set them (NORMALIZE_ONLY resets NORMAL only,
  FULL resets both, NONE resets neither)
- MTMVPlanUtilTest: add 4 new UTs covering UNIQUE_KEYS+MOW assertion,
  DUP_KEYS for non-IVM, and rejection of user-specified UNIQUE/DUP keys
- CountingSessionVariable: count only enabling ("true") setVarOnce calls
…aRewriter

Move IVM delta plan generation out of Nereids rewrite rules into an
external IvmDeltaRewriter that will be called by IVMRefreshManager.
IvmNormalizeMtmvPlan now stores the normalized plan in IvmContext so
IVMRefreshManager can retrieve it for delta rewriting.

- Add normalizedPlan field to IvmContext, store after normalization
- Add ivmNormalizedPlan field to MTMVAnalyzeQueryInfo
- Delete IvmDeltaScanOnly, IvmDeltaAggRoot, IvmAnalyzeMode
- Remove IVM_DELTA_SCAN_ONLY/IVM_DELTA_AGG_ROOT from RuleType/Rewriter
- Remove ENABLE_IVM_DELTA_REWRITE session variable
- Remove deltaCommandBundles from IvmContext
- Replace IvmAnalyzeMode enum with boolean enableIvmNormalize
- Create skeleton IvmDeltaRewriter + IvmDeltaRewriteContext
- Rewrite IVMRefreshManager.analyzeDeltaCommandBundles to use
  normalized plan (returns empty bundles for now, triggers fallback)
IvmDeltaRewriter no longer extends DefaultPlanRewriter. It now validates
the normalized plan is a supported scan-only or project-scan pattern,
extracts the base table, and produces an INSERT INTO mv command wrapped
in a DeltaCommandBundle. IvmDeltaRewriteContext gains a ConnectContext
field, and IVMRefreshManager.analyzeDeltaCommandBundles is wired to
call the rewriter.
…es to concrete classes

IVMDeltaExecutor now contains real execution logic following the MTMVTask.exec()
pattern: creates ConnectContext/StatementContext/StmtExecutor, runs the command,
and checks query state. IVMCapabilityChecker returns ok() by default.
IVMRefreshManager uses a no-arg public constructor, instantiating both
collaborators internally, with a @VisibleForTesting constructor for injection.
For INCREMENTAL MVs, attempt IVM refresh first via IVMRefreshManager.
On success, return early and skip partition-based refresh.
On fallback, log the reason and continue with existing refresh path.
…eltaExecutor

Extract common command execution boilerplate shared by MTMVTask.exec()
and IVMDeltaExecutor.executeBundle() into MTMVPlanUtil.executeCommand().
This also adds the missing audit logging to IVM delta execution.
@yujun777
Copy link
Contributor Author

run buildall

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