Skip to content

[fix](mtmv) Fix NPE in show create materialized view after upgrade#61898

Closed
seawinde wants to merge 2 commits intoapache:masterfrom
seawinde:fix_show_create_mv_fail
Closed

[fix](mtmv) Fix NPE in show create materialized view after upgrade#61898
seawinde wants to merge 2 commits intoapache:masterfrom
seawinde:fix_show_create_mv_fail

Conversation

@seawinde
Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:
After upgrading from 4.0.2 to 4.0.4, executing SHOW CREATE MATERIALIZED VIEW throws NullPointerException because MTMV.getSessionVariables() returns null for materialized views created before the sessionVariables field was introduced.

The sessionVariables field (annotated with @SerializedName("sv")) was added after 4.0.2. MTMVs created in 4.0.2 do not have this field persisted, so after upgrade it deserializes as null. The code in ShowCreateMTMVInfo.getShowResultSet() called mtmv.getSessionVariables().toString() without null protection.

Fix: Add null check - when sessionVariables is null, display empty map {}.

Release note

Fix NPE when executing SHOW CREATE MATERIALIZED VIEW for materialized views created before the sessionVariables feature was introduced (e.g. upgrade from 4.0.2 to 4.0.4).

Check List (For Author)

  • Test: Unit Test
  • Behavior changed: No
  • Does this need documentation: No

What problem does this PR solve?

Issue Number: #58031

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

### What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:
After upgrading from 4.0.2 to 4.0.4, executing `SHOW CREATE MATERIALIZED VIEW`
throws NullPointerException because `MTMV.getSessionVariables()` returns null for
materialized views created before the `sessionVariables` field was introduced.

The `sessionVariables` field (annotated with `@SerializedName("sv")`) was added
after 4.0.2. MTMVs created in 4.0.2 do not have this field persisted, so after
upgrade it deserializes as null. The code in `ShowCreateMTMVInfo.getShowResultSet()`
called `mtmv.getSessionVariables().toString()` without null protection.

Fix: Add null check - when sessionVariables is null, display empty map `{}`.

### Release note

Fix NPE when executing SHOW CREATE MATERIALIZED VIEW for materialized views
created before the sessionVariables feature was introduced (e.g. upgrade from
4.0.2 to 4.0.4).

### Check List (For Author)

- Test: Unit Test
- Behavior changed: No
- Does this need documentation: No
@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?

@seawinde
Copy link
Copy Markdown
Member Author

run buildall

@seawinde
Copy link
Copy Markdown
Member Author

run buildall

@doris-robot
Copy link
Copy Markdown

TPC-H: Total hot run time: 26487 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 10221eeea1544ad5e0e35c3330c1d5b116835e7f, 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	17655	4409	4298	4298
q2	q3	10639	784	520	520
q4	4678	357	248	248
q5	7553	1210	1014	1014
q6	175	173	147	147
q7	779	849	692	692
q8	9662	1471	1302	1302
q9	5234	4696	4689	4689
q10	6306	1928	1630	1630
q11	471	256	244	244
q12	747	581	457	457
q13	18058	2723	1910	1910
q14	228	242	213	213
q15	q16	740	756	667	667
q17	734	833	442	442
q18	5870	5304	5272	5272
q19	1338	969	620	620
q20	546	499	383	383
q21	4443	1823	1418	1418
q22	446	443	321	321
Total cold run time: 96302 ms
Total hot run time: 26487 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	4786	4659	4693	4659
q2	q3	3901	4386	3876	3876
q4	930	1221	789	789
q5	4072	4395	4385	4385
q6	185	176	139	139
q7	1807	1683	1545	1545
q8	2467	2811	2541	2541
q9	7581	7346	7386	7346
q10	3813	4113	3768	3768
q11	516	453	414	414
q12	498	601	467	467
q13	2483	3208	2103	2103
q14	295	318	304	304
q15	q16	754	760	740	740
q17	1170	1375	1427	1375
q18	7310	6815	6584	6584
q19	909	946	1079	946
q20	2111	2195	2015	2015
q21	3886	3457	3289	3289
q22	447	425	376	376
Total cold run time: 49921 ms
Total hot run time: 47661 ms

@doris-robot
Copy link
Copy Markdown

TPC-DS: Total hot run time: 168478 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 10221eeea1544ad5e0e35c3330c1d5b116835e7f, data reload: false

query5	4330	636	507	507
query6	332	236	207	207
query7	4224	453	262	262
query8	351	248	230	230
query9	8716	2743	2721	2721
query10	497	401	344	344
query11	7011	5086	4830	4830
query12	174	127	124	124
query13	1276	446	357	357
query14	5732	3670	3432	3432
query14_1	2828	2851	2804	2804
query15	210	200	179	179
query16	965	395	457	395
query17	908	733	623	623
query18	2460	455	355	355
query19	219	212	186	186
query20	135	127	125	125
query21	222	136	114	114
query22	13289	13391	13240	13240
query23	16147	15772	16072	15772
query23_1	16132	16295	16187	16187
query24	8463	1706	1318	1318
query24_1	1386	1276	1294	1276
query25	588	518	460	460
query26	1400	275	159	159
query27	3323	506	326	326
query28	4531	1834	1834	1834
query29	807	558	481	481
query30	293	225	191	191
query31	991	926	868	868
query32	81	73	70	70
query33	511	345	278	278
query34	891	861	501	501
query35	629	667	588	588
query36	1110	1154	1000	1000
query37	138	92	83	83
query38	2892	2924	2866	2866
query39	860	826	810	810
query39_1	801	789	787	787
query40	234	151	136	136
query41	64	60	64	60
query42	260	258	254	254
query43	249	255	220	220
query44	
query45	197	182	176	176
query46	885	976	610	610
query47	2132	2160	2104	2104
query48	320	312	228	228
query49	628	477	392	392
query50	703	290	223	223
query51	4180	4143	4042	4042
query52	264	273	266	266
query53	300	341	294	294
query54	309	277	289	277
query55	89	85	90	85
query56	313	341	316	316
query57	1943	1931	1824	1824
query58	297	281	271	271
query59	2844	2999	2817	2817
query60	343	344	323	323
query61	166	159	158	158
query62	638	605	541	541
query63	312	281	281	281
query64	5029	1319	1027	1027
query65	
query66	1461	449	358	358
query67	24135	24264	24045	24045
query68	
query69	409	314	291	291
query70	997	960	949	949
query71	326	303	289	289
query72	2871	2685	2445	2445
query73	537	533	315	315
query74	9581	9592	9396	9396
query75	2846	2765	2438	2438
query76	2278	1016	658	658
query77	353	394	315	315
query78	10875	11074	10476	10476
query79	3052	789	577	577
query80	1758	632	521	521
query81	570	260	223	223
query82	1005	155	131	131
query83	330	260	240	240
query84	305	121	95	95
query85	952	535	453	453
query86	496	307	302	302
query87	3117	3107	3034	3034
query88	3541	2660	2639	2639
query89	417	367	345	345
query90	2023	180	173	173
query91	168	163	140	140
query92	85	71	73	71
query93	1487	841	498	498
query94	644	309	283	283
query95	582	395	310	310
query96	641	513	222	222
query97	2523	2479	2426	2426
query98	233	220	219	219
query99	1009	1011	906	906
Total cold run time: 254151 ms
Total hot run time: 168478 ms

@seawinde
Copy link
Copy Markdown
Member Author

another pr fix

@seawinde seawinde closed this Apr 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