Skip to content

[fix](topn) Skip TopN lazy materialization when light_schema_change=false#64441

Open
HappenLee wants to merge 1 commit into
apache:masterfrom
HappenLee:docs
Open

[fix](topn) Skip TopN lazy materialization when light_schema_change=false#64441
HappenLee wants to merge 1 commit into
apache:masterfrom
HappenLee:docs

Conversation

@HappenLee

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

TopN lazy materialization relies on BE adding GLOBAL_ROWID_COL to the tablet schema through columns_desc. When light_schema_change=false, table columns have col_unique_id=-1, which causes BE to skip rebuilding the schema from columns_desc. As a result, GLOBAL_ROWID_COL is not added and the scan can fail with field name is invalid.

This PR skips TopN lazy materialization for Olap tables with light_schema_change=false, so FE keeps the regular scan output and avoids generating a plan that requires the missing row id column.

It also adds FE unit test coverage for:

  • skipping TopN lazy materialization when light_schema_change=false
  • preserving nested column access paths in TopN lazy materialization

Issue Number: close #xxx

Related PR: #xxx

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

sh run-fe-ut.sh --run org.apache.doris.nereids.postprocess.TopnLazyMaterializeTest

  • 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

…alse

TopN lazy materialization relies on BE adding GLOBAL_ROWID_COL to the
tablet schema via columns_desc. When light_schema_change=false, table
columns have col_unique_id=-1, causing BE to skip the schema rebuild
from columns_desc, so GLOBAL_ROWID_COL is never added and the scan
fails with "field name is invalid".

Skip the optimization at FE for tables with light_schema_change=false
to avoid the BE error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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?

StatementContext threadStatementContext = StatementScopeIdGenerator.getStatementContext();
for (Relation relation : relationToLazySlotMap.keySet()) {
// TopN lazy materialization relies on BE adding a GLOBAL_ROWID_COL to the
// tablet schema. When light_schema_change=false, the table columns have

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When a table has light_schema_change=false, does that mean lazy materialization cannot be used for any tables involved in the query?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@morrySnow Light schema change was introduced in doris version 1.2.
Legacy tables are rare, and this is not the default behavior. Simply avoid this optimization.

@HappenLee

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29192 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit b18b86090509ec3005f69a1c449c14c897eb9267, 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	17734	4103	4010	4010
q2	q3	10811	1428	808	808
q4	4689	469	340	340
q5	7517	853	575	575
q6	179	169	135	135
q7	761	816	627	627
q8	9329	1528	1590	1528
q9	5829	4480	4504	4480
q10	6745	1805	1554	1554
q11	428	275	256	256
q12	635	427	298	298
q13	18106	3382	2721	2721
q14	265	256	243	243
q15	q16	819	765	711	711
q17	985	904	931	904
q18	6984	5809	5537	5537
q19	1355	1284	1187	1187
q20	502	399	260	260
q21	6337	2839	2699	2699
q22	457	387	319	319
Total cold run time: 100467 ms
Total hot run time: 29192 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	5070	4848	4794	4794
q2	q3	4885	5319	4763	4763
q4	2091	2247	1398	1398
q5	4770	4897	4639	4639
q6	227	173	127	127
q7	1850	1891	1549	1549
q8	2414	2121	2105	2105
q9	7930	7608	7406	7406
q10	4732	4653	4254	4254
q11	529	382	350	350
q12	717	732	525	525
q13	2979	3361	2781	2781
q14	271	281	254	254
q15	q16	673	701	611	611
q17	1281	1262	1244	1244
q18	7355	6944	6655	6655
q19	1085	1066	1125	1066
q20	2220	2229	1957	1957
q21	5246	4539	4355	4355
q22	499	479	394	394
Total cold run time: 56824 ms
Total hot run time: 51227 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 169601 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 b18b86090509ec3005f69a1c449c14c897eb9267, data reload: false

query5	4321	619	471	471
query6	435	186	172	172
query7	4897	562	327	327
query8	390	228	203	203
query9	8714	4010	4054	4010
query10	441	307	256	256
query11	5903	2373	2176	2176
query12	151	100	98	98
query13	1261	620	428	428
query14	6329	5393	5050	5050
query14_1	4372	4383	4389	4383
query15	205	194	175	175
query16	1036	462	452	452
query17	1134	715	575	575
query18	2487	479	349	349
query19	208	187	154	154
query20	113	105	113	105
query21	219	144	118	118
query22	13762	13515	13425	13425
query23	17379	16506	16199	16199
query23_1	16303	16223	16389	16223
query24	7549	1772	1312	1312
query24_1	1315	1282	1316	1282
query25	577	463	395	395
query26	1302	310	175	175
query27	2673	600	343	343
query28	4418	2035	2033	2033
query29	1102	622	497	497
query30	325	247	201	201
query31	1114	1084	968	968
query32	107	66	62	62
query33	533	320	259	259
query34	1187	1152	689	689
query35	736	773	666	666
query36	1399	1433	1271	1271
query37	145	101	90	90
query38	3189	3141	2979	2979
query39	927	928	879	879
query39_1	882	863	863	863
query40	216	122	98	98
query41	63	61	62	61
query42	94	93	91	91
query43	313	321	274	274
query44	
query45	194	185	179	179
query46	1072	1215	721	721
query47	2378	2353	2315	2315
query48	401	428	280	280
query49	617	465	352	352
query50	985	348	261	261
query51	4293	4339	4299	4299
query52	87	88	81	81
query53	240	271	187	187
query54	261	216	196	196
query55	77	74	69	69
query56	232	255	207	207
query57	1435	1411	1332	1332
query58	245	206	208	206
query59	1595	1648	1441	1441
query60	284	247	224	224
query61	154	150	149	149
query62	697	649	594	594
query63	232	184	189	184
query64	2518	863	585	585
query65	
query66	1822	442	332	332
query67	29583	29662	29551	29551
query68	
query69	408	306	248	248
query70	993	951	977	951
query71	290	214	207	207
query72	2907	2651	2309	2309
query73	826	780	423	423
query74	5092	4974	4745	4745
query75	2627	2549	2238	2238
query76	2329	1141	776	776
query77	356	368	289	289
query78	12401	12362	11954	11954
query79	1459	1057	779	779
query80	585	479	367	367
query81	445	280	242	242
query82	605	155	118	118
query83	350	271	246	246
query84	
query85	868	516	407	407
query86	370	294	291	291
query87	3402	3338	3171	3171
query88	3611	2726	2728	2726
query89	426	378	338	338
query90	1972	178	174	174
query91	170	157	133	133
query92	65	59	59	59
query93	1502	1370	940	940
query94	547	328	297	297
query95	657	468	339	339
query96	1036	791	326	326
query97	2735	2703	2555	2555
query98	211	208	206	206
query99	1154	1174	1030	1030
Total cold run time: 250470 ms
Total hot run time: 169601 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 1.54% (1/65) 🎉
Increment coverage report
Complete coverage report

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.

3 participants