Skip to content

[fix](mtmv) support qualified materialized view rename target#63216

Merged
morrySnow merged 2 commits into
apache:masterfrom
officialasishkumar:fix/mtmv-qualified-rename
May 18, 2026
Merged

[fix](mtmv) support qualified materialized view rename target#63216
morrySnow merged 2 commits into
apache:masterfrom
officialasishkumar:fix/mtmv-qualified-rename

Conversation

@officialasishkumar
Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #62226

Related PR: None

Problem Summary:

ALTER MATERIALIZED VIEW db.mv RENAME db.new_mv failed during parsing because the MTMV RENAME target accepted only a single identifier. The underlying rename still operates inside the source database, so this PR parses the target as a multipart identifier and validates that any supplied catalog or database qualifier matches the source materialized view.

Release note

Support qualified target names in ALTER MATERIALIZED VIEW ... RENAME when the qualifier matches the source materialized view.

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. Qualified rename targets for MTMV are now accepted when they resolve to the same catalog and database.
  • 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

@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

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one correctness issue in the qualified rename validation. The change otherwise stays focused on the MTMV rename parser/analyzer path, and the included unit test covers the happy path for a same-database qualified target.

Critical checkpoint conclusions:

  • Goal/test: The PR aims to accept ALTER MATERIALIZED VIEW db.mv RENAME db.new_mv; the positive same-db case is tested, but the cross-db rejection is incomplete for case-distinct DB names.
  • Scope: The code change is small and localized to parser/analyzer/test code.
  • Concurrency/lifecycle: No new concurrency or special lifecycle management is introduced.
  • Config/compatibility: No new config or storage/protocol compatibility impact.
  • Parallel paths: This affects the Nereids MTMV alter path; no duplicate existing review threads were present.
  • Tests: Positive unit coverage was added, but a negative case for Test vs test is needed because internal DB lookup is case-sensitive.
  • Observability/performance/transactions: No new observability need or meaningful performance impact; rename persistence remains delegated to the existing renameTable path.

User focus: No additional user-provided review focus was supplied.

Copy link
Copy Markdown
Contributor

@yujun777 yujun777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate review comment removed.

@officialasishkumar officialasishkumar force-pushed the fix/mtmv-qualified-rename branch from 62505d5 to 5a0751a Compare May 14, 2026 05:31
@officialasishkumar
Copy link
Copy Markdown
Contributor Author

Updated in 5a0751a: qualified MTMV rename validation now compares catalog/database names exactly, so names like Test and test are not treated as the same database. I also added a focused negative test for ALTER MATERIALIZED VIEW Test.mv_case RENAME test.mv_case_new.

Validation: git diff --check HEAD~1 HEAD passed. I attempted the narrow JUnit command mvn -pl fe-core -Dtest=org.apache.doris.mtmv.AlterMTMVTest#testAlterMTMV test, but this fresh runner did not reach test execution because Maven dependency resolution failed/hung on the large FE dependency graph.

Copy link
Copy Markdown
Contributor

@yujun777 yujun777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yujun777
Copy link
Copy Markdown
Contributor

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 70.00% (7/10) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31861 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 5a0751a3a6ff5048740507de6148e0ccb57be418, 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	17801	4104	4120	4104
q2	q3	10809	1464	841	841
q4	4718	494	359	359
q5	8140	2395	2230	2230
q6	368	192	142	142
q7	1002	788	622	622
q8	9617	1781	1717	1717
q9	7091	5029	5038	5029
q10	6432	2281	1786	1786
q11	456	281	253	253
q12	694	466	314	314
q13	18169	3471	2817	2817
q14	275	261	237	237
q15	q16	828	782	702	702
q17	945	951	1000	951
q18	6993	5834	5588	5588
q19	1181	1305	1131	1131
q20	487	427	266	266
q21	5690	2591	2467	2467
q22	442	363	305	305
Total cold run time: 102138 ms
Total hot run time: 31861 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	4405	4331	4326	4326
q2	q3	4668	4970	4311	4311
q4	2251	2337	1409	1409
q5	4595	4450	5419	4450
q6	272	211	148	148
q7	2013	1888	1643	1643
q8	2715	2387	2315	2315
q9	8068	7915	7953	7915
q10	4859	4552	4144	4144
q11	624	441	370	370
q12	783	783	521	521
q13	3301	3802	3005	3005
q14	295	327	277	277
q15	q16	740	754	655	655
q17	1431	1369	1388	1369
q18	8274	7202	6815	6815
q19	1145	1110	1112	1110
q20	2261	2234	1929	1929
q21	5580	4874	4703	4703
q22	540	464	414	414
Total cold run time: 58820 ms
Total hot run time: 51829 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 168991 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 5a0751a3a6ff5048740507de6148e0ccb57be418, data reload: false

query5	4374	650	513	513
query6	352	222	204	204
query7	4254	546	312	312
query8	333	231	214	214
query9	8807	3992	3978	3978
query10	447	354	300	300
query11	5801	2347	2232	2232
query12	186	127	127	127
query13	1314	626	439	439
query14	6028	5370	5061	5061
query14_1	4366	4326	4341	4326
query15	216	204	188	188
query16	1004	470	456	456
query17	1151	744	614	614
query18	2750	502	365	365
query19	253	206	176	176
query20	147	143	134	134
query21	220	137	121	121
query22	13601	13603	13284	13284
query23	17214	16341	16069	16069
query23_1	16102	16234	16161	16161
query24	7416	1742	1351	1351
query24_1	1270	1316	1283	1283
query25	540	469	416	416
query26	1293	314	174	174
query27	2720	588	340	340
query28	4415	1934	1927	1927
query29	988	609	500	500
query30	318	238	196	196
query31	1134	1086	935	935
query32	89	76	74	74
query33	538	341	287	287
query34	1165	1112	637	637
query35	757	786	692	692
query36	1360	1335	1187	1187
query37	154	110	101	101
query38	3212	3141	3050	3050
query39	942	914	899	899
query39_1	894	876	874	874
query40	226	148	125	125
query41	65	64	64	64
query42	110	109	110	109
query43	321	329	282	282
query44	
query45	204	198	200	198
query46	1082	1209	710	710
query47	2343	2298	2182	2182
query48	361	432	298	298
query49	630	486	389	389
query50	962	342	259	259
query51	4294	4324	4242	4242
query52	103	105	93	93
query53	263	275	218	218
query54	304	265	266	265
query55	94	88	83	83
query56	289	311	300	300
query57	1432	1387	1318	1318
query58	301	269	275	269
query59	1542	1617	1400	1400
query60	313	318	319	318
query61	160	158	154	154
query62	665	620	555	555
query63	245	197	210	197
query64	2335	807	623	623
query65	
query66	1643	484	349	349
query67	30010	29903	29813	29813
query68	
query69	452	339	303	303
query70	995	952	975	952
query71	297	288	272	272
query72	3004	2755	2558	2558
query73	836	749	401	401
query74	5123	4941	4772	4772
query75	2672	2589	2262	2262
query76	2315	1118	799	799
query77	395	410	336	336
query78	12164	12080	11598	11598
query79	1411	1013	758	758
query80	652	524	456	456
query81	452	279	239	239
query82	1379	157	119	119
query83	374	298	249	249
query84	261	145	112	112
query85	877	533	479	479
query86	386	338	329	329
query87	3378	3376	3199	3199
query88	3489	2631	2636	2631
query89	425	394	337	337
query90	1942	179	182	179
query91	178	165	139	139
query92	75	76	73	73
query93	1545	1497	895	895
query94	543	349	347	347
query95	676	466	351	351
query96	1006	820	316	316
query97	2708	2697	2574	2574
query98	244	230	240	230
query99	1132	1082	941	941
Total cold run time: 252629 ms
Total hot run time: 168991 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 45.45% (5/11) 🎉
Increment coverage report
Complete coverage report

@morrySnow
Copy link
Copy Markdown
Contributor

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review completed. I did not find additional blocking issues beyond the existing inline thread, which the current head appears to address by comparing catalog/db with exact equality and adding a case-distinct DB test.\n\nCritical checkpoint conclusions:\n- Goal/test: The PR allows qualified MTMV rename targets while preventing cross-database/catalog renames; the updated covers same-DB qualified rename and case-distinct DB rejection.\n- Scope: The change is small and focused on the MTMV rename grammar, plan builder, analyze logic, and focused test.\n- Concurrency/lifecycle: No new shared state, locks, threads, or non-obvious lifecycle/static initialization concerns were introduced.\n- Config/compatibility: No new configuration, storage format, edit log, or FE-BE protocol compatibility impact found.\n- Parallel paths: The renamed grammar labels keep REPLACE handling separate, and I did not find another MTMV rename path requiring the same change.\n- Error handling/data correctness: Cross-db/catalog rename is rejected during analysis; rename execution still uses the original database and target table name only. No transaction/data visibility concerns found.\n- Observability/performance: No new hot path or observability requirement identified.\n- Tests: Attempted [INFO] Scanning for projects...
[ERROR] [ERROR] Could not find the selected project in the reactor: fe-core @
[ERROR] Could not find the selected project in the reactor: fe-core -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException, but it could not run in this runner because is missing.\n\nUser focus: No additional user-provided review focus was specified.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction to my previous review summary: shell command substitution stripped parts of the test-command text in that comment. The review outcome is unchanged: I did not find additional blocking issues beyond the existing inline thread, and the current head appears to address that thread with exact catalog/db comparison plus a case-distinct DB test.

Critical checkpoint conclusions:

  • Goal/test: The PR allows qualified MTMV rename targets while preventing cross-database/catalog renames; the updated AlterMTMVTest covers same-DB qualified rename and case-distinct DB rejection.
  • Scope: The change is small and focused on the MTMV rename grammar, plan builder, analyze logic, and focused test.
  • Concurrency/lifecycle: No new shared state, locks, threads, or non-obvious lifecycle/static initialization concerns were introduced.
  • Config/compatibility: No new configuration, storage format, edit log, or FE-BE protocol compatibility impact found.
  • Parallel paths: The renamed grammar labels keep REPLACE handling separate, and I did not find another MTMV rename path requiring the same change.
  • Error handling/data correctness: Cross-db/catalog rename is rejected during analysis; rename execution still uses the original database and target table name only. No transaction/data visibility concerns found.
  • Observability/performance: No new hot path or observability requirement identified.
  • Tests: Attempted focused FE test with Maven, but it could not run in this runner because thirdparty/installed/bin/thrift is missing.

User focus: No additional user-provided review focus was specified.

@hello-stephen
Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 4.13% (5/121) 🎉
Increment coverage report
Complete coverage report

@morrySnow morrySnow merged commit 92c9c21 into apache:master May 18, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] rename MATERIALIZED VIEW using table_schema and table_name error

4 participants