Skip to content

Conversation

@feiniaofeiafei
Copy link
Contributor

@feiniaofeiafei feiniaofeiafei commented Jan 21, 2026

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #59116 #60045

Problem Summary:
There are 2 problems:

  1. When DecomposeRepeatWithPreAggregation optimization removes the maximum grouping set, grouping functions (e.g., grouping(), grouping_id()) that reference expressions only existing in the removed grouping set would fail because of index lookup failure: When computing grouping function values, GroupingSetShapes.indexOf() would return -1 for expressions not in flattenGroupingSetExpression, causing incorrect behavior.

Example scenario:

SELECT a, b, c, grouping(c) 
FROM t1 
GROUP BY GROUPING SETS ((a, b, c), (a, b), (a), ());

After optimization removes the maximum grouping set (a, b, c), the expression c no longer exists in the remaining grouping sets. When computing grouping(c), the index lookup would fail.
2. The repeatSlotIdList calculation was incorrect because it relied on the assumption that the order of physicalRepeat.getOutputExpressions() matches the order of outputTuple. However, this assumption can be broken during rule rewriting (e.g., in DecomposeRepeatWithPreAggregation.constructRepeat() at line 502-503, where replacedRepeatOutputs is constructed by new ArrayList<>(child.getOutput()) and then appends grouping functions, potentially changing the order). This mismatch causes incorrect slot ID mapping and wrong query results.

Example scenario:
When DecomposeRepeatWithPreAggregation rewrites a repeat plan, the output expressions order may differ from the output tuple order, leading to incorrect slot ID mapping in repeatSlotIdList.

Solution:

  1. For problem 1: Modified Repeat.toShapes() method to ensure all expressions referenced by grouping functions are included in flattenGroupingSetExpression, even if they are not in any grouping set. For expressions that only exist in the removed maximum grouping set, they are correctly marked as shouldBeErasedToNull = true in all remaining grouping sets, which is the correct SQL semantics.

Key changes:

  • Repeat.toShapes(): Enhanced to collect all expressions referenced by grouping functions using ExpressionUtils.collectToList() and merge them into flattenGroupingSetExpression
  • For expressions not in any grouping set, they are correctly marked as shouldBeErasedToNull = true in all GroupingSetShape instances
  • This ensures GroupingSetShapes.indexOf() always returns a valid index for grouping function arguments, preventing index lookup failures
  1. For problem 2: Modified Repeat.computeRepeatSlotIdList() method to accept an additional outputSlots parameter. Instead of relying on the order of outputExpressions matching outputTuple, the method now uses outputSlots to correctly map grouping set expressions to their indices in the output tuple. This ensures correct slot ID calculation even when rule rewriting changes the order of output expressions.

Key changes:

  • computeRepeatSlotIdList(List<Integer> slotIdList, List<Slot> outputSlots): Added outputSlots parameter
  • getGroupingSetsIndexesInOutput(List<Slot> outputSlots): Modified to use outputSlots instead of getOutputExpressions()
  • indexesOfOutput(List<Slot> outputSlots): Modified to build index map from outputSlots instead of getOutputExpressions()
  • PhysicalPlanTranslator.visitPhysicalRepeat(): Updated to pass outputSlots to computeRepeatSlotIdList()

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

@hello-stephen
Copy link
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?

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17632	4102	4048	4048
q2	2027	388	234	234
q3	10127	1252	712	712
q4	10189	761	297	297
q5	7517	2069	1881	1881
q6	182	167	135	135
q7	953	786	648	648
q8	9276	1443	1151	1151
q9	4957	4631	4565	4565
q10	6714	1779	1392	1392
q11	523	300	275	275
q12	668	733	612	612
q13	17805	3838	3084	3084
q14	284	302	286	286
q15	591	510	505	505
q16	682	687	647	647
q17	631	771	491	491
q18	6714	6516	6860	6516
q19	1163	1023	686	686
q20	411	374	259	259
q21	3246	2623	2390	2390
q22	1141	1076	1043	1043
Total cold run time: 103433 ms
Total hot run time: 31857 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4314	4384	4317	4317
q2	337	416	328	328
q3	2232	2791	2432	2432
q4	1403	1890	1453	1453
q5	4474	4293	4529	4293
q6	213	174	125	125
q7	1943	1907	1796	1796
q8	2528	2378	2488	2378
q9	7232	7081	7160	7081
q10	2536	2776	2229	2229
q11	551	478	487	478
q12	715	754	682	682
q13	3620	4075	3223	3223
q14	264	277	271	271
q15	528	485	482	482
q16	632	661	610	610
q17	1097	1229	1343	1229
q18	7608	7325	7293	7293
q19	800	775	775	775
q20	1885	1950	1789	1789
q21	4557	4293	4158	4158
q22	1093	1006	989	989
Total cold run time: 50562 ms
Total hot run time: 48411 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 174145 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 ae3ef77b571d969bce5ce50f8524285f3009c2bb, data reload: false

query5	4860	625	494	494
query6	341	240	221	221
query7	4214	461	266	266
query8	354	258	255	255
query9	8798	2889	2887	2887
query10	550	381	345	345
query11	15250	15303	14915	14915
query12	200	120	119	119
query13	1264	486	386	386
query14	7162	3056	2732	2732
query14_1	2649	2645	2671	2645
query15	196	193	166	166
query16	975	472	469	469
query17	1084	633	540	540
query18	2684	414	327	327
query19	214	216	188	188
query20	122	114	111	111
query21	215	140	116	116
query22	4063	3970	4017	3970
query23	16410	15695	15398	15398
query23_1	15416	15512	15459	15459
query24	6938	1525	1147	1147
query24_1	1138	1164	1151	1151
query25	500	431	373	373
query26	1231	260	146	146
query27	2764	439	281	281
query28	4534	2159	2159	2159
query29	734	531	420	420
query30	312	241	206	206
query31	804	616	582	582
query32	90	76	73	73
query33	529	357	318	318
query34	915	878	541	541
query35	715	761	689	689
query36	896	898	853	853
query37	139	98	86	86
query38	2737	2752	2683	2683
query39	772	755	729	729
query39_1	709	713	731	713
query40	220	139	118	118
query41	66	62	60	60
query42	106	100	110	100
query43	420	440	458	440
query44	1316	743	743	743
query45	187	195	189	189
query46	829	937	570	570
query47	1403	1498	1420	1420
query48	325	320	240	240
query49	608	436	341	341
query50	615	272	202	202
query51	3771	3867	3806	3806
query52	102	108	96	96
query53	284	324	272	272
query54	288	289	275	275
query55	82	87	78	78
query56	313	302	309	302
query57	1049	1002	968	968
query58	267	252	255	252
query59	1993	2204	2058	2058
query60	340	333	318	318
query61	149	146	143	143
query62	393	344	309	309
query63	289	264	269	264
query64	4785	1269	957	957
query65	3841	3712	3735	3712
query66	1395	424	314	314
query67	15593	15599	15372	15372
query68	2408	1090	757	757
query69	450	363	327	327
query70	996	948	918	918
query71	317	311	290	290
query72	5299	3176	3335	3176
query73	610	721	313	313
query74	8730	8780	8545	8545
query75	2753	2810	2494	2494
query76	2293	1059	672	672
query77	366	379	308	308
query78	9706	9921	9148	9148
query79	1063	906	581	581
query80	672	584	525	525
query81	493	266	237	237
query82	1330	149	116	116
query83	380	260	253	253
query84	261	127	105	105
query85	901	542	496	496
query86	362	298	287	287
query87	2834	2861	2754	2754
query88	3531	2610	2574	2574
query89	403	363	326	326
query90	1893	181	169	169
query91	183	211	136	136
query92	82	69	69	69
query93	915	918	537	537
query94	454	323	281	281
query95	573	397	328	328
query96	653	500	232	232
query97	2328	2382	2304	2304
query98	228	211	204	204
query99	615	575	524	524
Total cold run time: 248461 ms
Total hot run time: 174145 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 26.84 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit ae3ef77b571d969bce5ce50f8524285f3009c2bb, data reload: false

query1	0.06	0.05	0.04
query2	0.10	0.05	0.04
query3	0.26	0.09	0.08
query4	1.62	0.12	0.11
query5	0.28	0.25	0.24
query6	1.15	0.67	0.64
query7	0.04	0.03	0.02
query8	0.05	0.04	0.04
query9	0.57	0.50	0.51
query10	0.55	0.54	0.55
query11	0.14	0.10	0.10
query12	0.15	0.11	0.10
query13	0.59	0.58	0.58
query14	0.93	0.96	0.95
query15	0.79	0.78	0.79
query16	0.39	0.40	0.38
query17	1.01	1.07	1.01
query18	0.23	0.21	0.21
query19	1.93	1.84	1.90
query20	0.02	0.02	0.01
query21	15.48	0.23	0.15
query22	5.43	0.06	0.04
query23	15.99	0.27	0.11
query24	1.50	0.25	0.32
query25	0.12	0.07	0.04
query26	0.14	0.14	0.13
query27	0.06	0.08	0.06
query28	3.26	1.10	0.88
query29	12.52	3.93	3.15
query30	0.27	0.13	0.12
query31	2.82	0.65	0.38
query32	3.24	0.57	0.46
query33	3.02	3.06	3.10
query34	16.44	5.10	4.49
query35	4.45	4.44	4.50
query36	0.64	0.50	0.49
query37	0.11	0.07	0.07
query38	0.07	0.04	0.04
query39	0.05	0.03	0.03
query40	0.16	0.14	0.14
query41	0.09	0.03	0.03
query42	0.05	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.81 s
Total hot run time: 26.84 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 80.00% (16/20) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (20/20) 🎉
Increment coverage report
Complete coverage report

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17614	4788	4589	4589
q2	2030	325	188	188
q3	10218	1278	738	738
q4	10199	814	301	301
q5	7494	2121	1798	1798
q6	186	169	137	137
q7	955	705	587	587
q8	9293	1457	1102	1102
q9	4805	4555	4618	4555
q10	6741	1659	1277	1277
q11	533	302	285	285
q12	337	391	232	232
q13	17787	3838	3090	3090
q14	239	231	221	221
q15	583	521	524	521
q16	654	630	590	590
q17	646	805	498	498
q18	6780	6464	6336	6336
q19	1093	969	624	624
q20	397	351	229	229
q21	2658	1969	1876	1876
q22	1025	996	954	954
Total cold run time: 102267 ms
Total hot run time: 30728 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4749	4719	4678	4678
q2	323	410	335	335
q3	2121	2665	2304	2304
q4	1346	1771	1313	1313
q5	4105	3969	3997	3969
q6	208	170	130	130
q7	1889	1848	1728	1728
q8	2828	2525	2523	2523
q9	7246	7299	7179	7179
q10	2510	2824	2368	2368
q11	579	474	483	474
q12	703	728	655	655
q13	3593	4125	3418	3418
q14	293	326	311	311
q15	562	517	518	517
q16	645	691	663	663
q17	1134	1260	1297	1260
q18	8279	7961	7918	7918
q19	882	832	845	832
q20	2040	2127	1942	1942
q21	4865	4478	4468	4468
q22	1108	1095	1100	1095
Total cold run time: 52008 ms
Total hot run time: 50080 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 173968 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 43a94541c6ec2325f1bef1dbe989761f8da5f8b1, data reload: false

query5	4410	673	504	504
query6	332	219	200	200
query7	4219	451	247	247
query8	342	247	236	236
query9	8737	2878	2876	2876
query10	460	325	322	322
query11	15341	15217	16004	15217
query12	204	127	129	127
query13	1309	480	365	365
query14	5618	3137	2996	2996
query14_1	2876	2826	2777	2777
query15	209	199	181	181
query16	1035	498	464	464
query17	909	683	606	606
query18	2469	413	341	341
query19	204	190	150	150
query20	125	119	117	117
query21	214	132	116	116
query22	4077	4285	4052	4052
query23	16169	15492	15498	15492
query23_1	15391	15303	15455	15303
query24	7211	1518	1145	1145
query24_1	1190	1145	1153	1145
query25	540	448	413	413
query26	1239	262	151	151
query27	2780	432	276	276
query28	4597	2161	2160	2160
query29	791	544	443	443
query30	310	233	201	201
query31	752	620	551	551
query32	83	77	72	72
query33	552	354	313	313
query34	918	882	534	534
query35	737	738	680	680
query36	883	854	823	823
query37	139	97	87	87
query38	2705	2680	2675	2675
query39	774	763	747	747
query39_1	710	697	711	697
query40	220	138	117	117
query41	70	65	61	61
query42	97	91	96	91
query43	439	426	390	390
query44	1340	752	749	749
query45	195	188	178	178
query46	815	953	581	581
query47	1464	1444	1397	1397
query48	319	342	262	262
query49	630	440	356	356
query50	672	280	204	204
query51	3730	3793	3752	3752
query52	94	94	80	80
query53	212	223	175	175
query54	297	270	259	259
query55	86	84	82	82
query56	310	340	316	316
query57	1079	1062	875	875
query58	274	265	244	244
query59	2077	2085	2080	2080
query60	324	320	313	313
query61	150	141	148	141
query62	414	343	304	304
query63	200	161	161	161
query64	4939	1136	855	855
query65	3818	3758	3786	3758
query66	1450	410	314	314
query67	15645	15671	15501	15501
query68	2441	1072	729	729
query69	397	314	273	273
query70	1015	930	948	930
query71	313	292	278	278
query72	5351	3130	3251	3130
query73	579	721	315	315
query74	8711	8858	8568	8568
query75	2278	2286	1910	1910
query76	2260	1061	648	648
query77	342	377	304	304
query78	9796	10038	9205	9205
query79	2349	905	584	584
query80	1750	517	443	443
query81	557	262	228	228
query82	1250	148	130	130
query83	340	259	243	243
query84	303	122	100	100
query85	874	476	407	407
query86	413	299	281	281
query87	2829	2913	2772	2772
query88	3461	2591	2533	2533
query89	307	255	244	244
query90	1997	166	160	160
query91	168	159	135	135
query92	79	75	71	71
query93	1504	998	674	674
query94	644	312	285	285
query95	587	389	312	312
query96	632	494	229	229
query97	2324	2362	2303	2303
query98	234	202	196	196
query99	625	592	505	505
Total cold run time: 248861 ms
Total hot run time: 173968 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 26.83 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 43a94541c6ec2325f1bef1dbe989761f8da5f8b1, data reload: false

query1	0.06	0.05	0.05
query2	0.09	0.04	0.04
query3	0.25	0.09	0.08
query4	1.61	0.12	0.11
query5	0.27	0.25	0.26
query6	1.15	0.67	0.65
query7	0.04	0.03	0.02
query8	0.05	0.03	0.04
query9	0.58	0.50	0.50
query10	0.56	0.54	0.55
query11	0.14	0.09	0.10
query12	0.15	0.11	0.11
query13	0.60	0.59	0.59
query14	0.94	0.96	0.94
query15	0.78	0.77	0.80
query16	0.37	0.39	0.40
query17	1.08	1.08	1.07
query18	0.23	0.21	0.20
query19	2.04	1.87	1.93
query20	0.02	0.01	0.01
query21	15.44	0.27	0.14
query22	4.91	0.05	0.04
query23	15.74	0.29	0.10
query24	2.48	0.32	1.07
query25	0.07	0.05	0.05
query26	0.14	0.13	0.12
query27	0.07	0.05	0.06
query28	5.06	1.06	0.89
query29	12.52	3.91	3.12
query30	0.29	0.14	0.11
query31	2.82	0.64	0.38
query32	3.23	0.56	0.45
query33	3.01	3.00	3.05
query34	15.92	5.10	4.42
query35	4.45	4.49	4.49
query36	0.65	0.50	0.49
query37	0.12	0.06	0.07
query38	0.07	0.04	0.04
query39	0.04	0.03	0.04
query40	0.16	0.13	0.13
query41	0.09	0.04	0.03
query42	0.05	0.03	0.03
query43	0.05	0.04	0.03
Total cold run time: 98.39 s
Total hot run time: 26.83 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 75.00% (6/8) 🎉
Increment coverage report
Complete coverage report

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 81.82% (18/22) 🎉
Increment coverage report
Complete coverage report

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17663	4708	4564	4564
q2	1994	307	215	215
q3	10246	1327	758	758
q4	10231	883	312	312
q5	8079	2067	1882	1882
q6	236	170	136	136
q7	898	693	590	590
q8	9272	1435	1044	1044
q9	4938	4547	4691	4547
q10	6843	1705	1269	1269
q11	502	300	263	263
q12	373	366	215	215
q13	17788	3824	3029	3029
q14	254	237	210	210
q15	650	516	526	516
q16	667	656	586	586
q17	739	781	505	505
q18	6782	6254	6796	6254
q19	1581	1044	665	665
q20	434	355	244	244
q21	2952	2268	2105	2105
q22	1142	1084	1030	1030
Total cold run time: 104264 ms
Total hot run time: 30939 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5136	4979	4931	4931
q2	338	397	346	346
q3	2354	2946	2566	2566
q4	1416	1894	1401	1401
q5	4480	4430	4251	4251
q6	215	195	130	130
q7	2257	1929	1818	1818
q8	2578	2448	2342	2342
q9	7238	7262	7241	7241
q10	2480	2850	2303	2303
q11	538	485	449	449
q12	707	800	630	630
q13	3601	3784	3106	3106
q14	270	285	257	257
q15	536	491	501	491
q16	614	655	617	617
q17	1111	1274	1347	1274
q18	7583	7305	7113	7113
q19	826	777	787	777
q20	1902	1984	1849	1849
q21	4529	4311	4085	4085
q22	1076	1038	978	978
Total cold run time: 51785 ms
Total hot run time: 48955 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 173439 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 8b4c9510229ae3641152b528cdb62e3dfdc2e650, data reload: false

query5	4438	651	491	491
query6	330	230	210	210
query7	4215	464	267	267
query8	348	252	237	237
query9	8703	2850	2839	2839
query10	463	322	286	286
query11	15233	15078	15041	15041
query12	178	115	115	115
query13	1238	460	374	374
query14	5558	2972	2706	2706
query14_1	2633	2547	2571	2547
query15	211	189	167	167
query16	968	476	481	476
query17	982	652	548	548
query18	2412	429	332	332
query19	194	178	150	150
query20	122	114	112	112
query21	208	159	113	113
query22	4213	4340	4173	4173
query23	16170	15742	15563	15563
query23_1	15555	15531	15547	15531
query24	7088	1552	1181	1181
query24_1	1145	1146	1162	1146
query25	511	438	385	385
query26	1242	287	146	146
query27	2747	440	268	268
query28	4595	2151	2134	2134
query29	732	517	413	413
query30	301	239	201	201
query31	807	617	553	553
query32	85	77	75	75
query33	540	349	305	305
query34	901	867	541	541
query35	701	759	665	665
query36	889	900	843	843
query37	165	96	86	86
query38	2704	2800	2665	2665
query39	775	746	732	732
query39_1	722	716	730	716
query40	220	131	113	113
query41	71	62	62	62
query42	97	94	91	91
query43	456	481	412	412
query44	1323	747	743	743
query45	186	184	172	172
query46	817	945	573	573
query47	1475	1448	1402	1402
query48	323	327	233	233
query49	604	441	353	353
query50	667	262	214	214
query51	3766	3801	3760	3760
query52	92	91	87	87
query53	217	224	163	163
query54	281	251	252	251
query55	85	77	74	74
query56	299	315	310	310
query57	1016	1027	962	962
query58	270	257	252	252
query59	2054	2107	2176	2107
query60	322	339	325	325
query61	146	150	139	139
query62	422	350	307	307
query63	187	161	163	161
query64	4934	1238	915	915
query65	3759	3746	3737	3737
query66	1480	435	327	327
query67	15619	15507	15407	15407
query68	2477	1043	709	709
query69	415	312	325	312
query70	1005	930	860	860
query71	292	275	269	269
query72	5238	3156	3192	3156
query73	598	717	307	307
query74	8670	8684	8522	8522
query75	2297	2299	1884	1884
query76	2258	1034	683	683
query77	352	375	312	312
query78	9705	9837	9222	9222
query79	1112	927	569	569
query80	620	536	422	422
query81	471	261	231	231
query82	1381	151	122	122
query83	367	265	247	247
query84	280	126	91	91
query85	848	467	413	413
query86	355	296	295	295
query87	2847	2819	2731	2731
query88	3495	2574	2550	2550
query89	299	252	239	239
query90	1903	173	167	167
query91	170	151	134	134
query92	77	72	71	71
query93	1074	1019	647	647
query94	463	313	292	292
query95	568	328	333	328
query96	646	501	230	230
query97	2348	2398	2322	2322
query98	222	203	200	200
query99	596	567	504	504
Total cold run time: 245134 ms
Total hot run time: 173439 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 27.16 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 8b4c9510229ae3641152b528cdb62e3dfdc2e650, data reload: false

query1	0.05	0.04	0.05
query2	0.10	0.05	0.05
query3	0.26	0.08	0.08
query4	1.61	0.12	0.12
query5	0.29	0.25	0.25
query6	1.15	0.65	0.64
query7	0.03	0.02	0.03
query8	0.05	0.04	0.04
query9	0.57	0.50	0.50
query10	0.54	0.55	0.55
query11	0.14	0.10	0.10
query12	0.14	0.11	0.11
query13	0.61	0.58	0.59
query14	0.95	0.93	0.96
query15	0.79	0.78	0.80
query16	0.42	0.39	0.38
query17	1.04	1.09	1.06
query18	0.24	0.22	0.21
query19	1.84	1.87	1.74
query20	0.02	0.01	0.02
query21	15.43	0.29	0.14
query22	5.04	0.04	0.04
query23	15.81	0.28	0.11
query24	1.05	0.66	0.80
query25	0.11	0.19	0.14
query26	0.14	0.14	0.13
query27	0.09	0.06	0.05
query28	5.36	1.07	0.89
query29	12.52	3.93	3.16
query30	0.27	0.13	0.11
query31	2.81	0.63	0.39
query32	3.23	0.57	0.45
query33	3.05	2.98	3.01
query34	16.01	5.14	4.44
query35	4.46	4.48	4.46
query36	0.69	0.51	0.49
query37	0.11	0.07	0.07
query38	0.07	0.04	0.03
query39	0.05	0.03	0.02
query40	0.16	0.14	0.13
query41	0.09	0.04	0.03
query42	0.04	0.02	0.02
query43	0.05	0.04	0.03
Total cold run time: 97.48 s
Total hot run time: 27.16 s

@feiniaofeiafei
Copy link
Contributor Author

run cloud_p0

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 90.91% (20/22) 🎉
Increment coverage report
Complete coverage report

1 similar comment
@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 90.91% (20/22) 🎉
Increment coverage report
Complete coverage report

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@feiniaofeiafei feiniaofeiafei changed the title [fix](agg) Not rewrite when grouping scalar function reference expressions that only exist in the largest grouping set [fix](agg) Fix grouping function handling and repeatSlotIdList calculation in DecomposeRepeatWithPreAggregation Jan 27, 2026
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17651	5220	5004	5004
q2	2108	303	194	194
q3	10173	1271	749	749
q4	10209	830	310	310
q5	7535	2138	1925	1925
q6	196	179	151	151
q7	859	720	599	599
q8	9267	1403	1170	1170
q9	5159	4748	4771	4748
q10	6812	1935	1544	1544
q11	523	291	283	283
q12	335	375	226	226
q13	17774	4075	3197	3197
q14	232	249	221	221
q15	905	836	807	807
q16	670	675	632	632
q17	637	775	517	517
q18	6658	6469	6311	6311
q19	1230	994	622	622
q20	403	363	242	242
q21	2644	2070	1892	1892
q22	1033	999	966	966
Total cold run time: 103013 ms
Total hot run time: 32310 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5318	5279	5293	5279
q2	269	326	244	244
q3	2169	2657	2245	2245
q4	1353	1725	1305	1305
q5	4309	4207	4238	4207
q6	218	184	143	143
q7	2408	2088	1855	1855
q8	2571	2454	2442	2442
q9	7603	7680	7616	7616
q10	2859	3134	2786	2786
q11	555	482	460	460
q12	697	736	639	639
q13	4045	4559	3679	3679
q14	318	348	339	339
q15	891	870	897	870
q16	696	803	751	751
q17	1173	1336	1646	1336
q18	8059	8248	7834	7834
q19	901	860	868	860
q20	2083	2155	1993	1993
q21	4501	4205	4122	4122
q22	1060	1024	990	990
Total cold run time: 54056 ms
Total hot run time: 51995 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 28.57 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit ad4f86f0707d0d8924818c84e2502184a611628a, data reload: false

query1	0.05	0.04	0.04
query2	0.09	0.05	0.04
query3	0.26	0.09	0.08
query4	1.62	0.11	0.10
query5	0.27	0.24	0.24
query6	1.17	0.68	0.67
query7	0.04	0.03	0.03
query8	0.06	0.04	0.05
query9	0.56	0.51	0.50
query10	0.54	0.54	0.55
query11	0.15	0.10	0.10
query12	0.15	0.10	0.11
query13	0.63	0.62	0.63
query14	1.08	1.07	1.05
query15	0.87	0.87	0.86
query16	0.42	0.39	0.42
query17	1.11	1.11	1.13
query18	0.23	0.21	0.22
query19	2.01	2.03	1.98
query20	0.02	0.01	0.02
query21	15.42	0.26	0.14
query22	4.89	0.05	0.05
query23	15.73	0.29	0.11
query24	1.07	0.60	0.59
query25	0.08	0.06	0.11
query26	0.14	0.14	0.14
query27	0.07	0.07	0.05
query28	3.90	1.15	0.95
query29	12.55	3.97	3.16
query30	0.28	0.13	0.12
query31	2.82	0.64	0.40
query32	3.24	0.59	0.49
query33	3.24	3.26	3.25
query34	16.47	5.38	4.72
query35	4.73	4.77	4.78
query36	0.64	0.49	0.49
query37	0.11	0.07	0.06
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.19	0.17	0.15
query41	0.09	0.03	0.04
query42	0.05	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 97.2 s
Total hot run time: 28.57 s

@feiniaofeiafei
Copy link
Contributor Author

run p0

@feiniaofeiafei
Copy link
Contributor Author

run cloud_p0

@feiniaofeiafei
Copy link
Contributor Author

run feut

@feiniaofeiafei
Copy link
Contributor Author

run p0

@feiniaofeiafei
Copy link
Contributor Author

run cloud_p0

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 92.59% (25/27) 🎉
Increment coverage report
Complete coverage report

1 similar comment
@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 92.59% (25/27) 🎉
Increment coverage report
Complete coverage report

* This is necessary for optimization scenarios where some expressions may only exist
* in the maximum grouping set that was removed during optimization.
*/
default GroupingSetShapes toShapes() {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a ut for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
default List<Set<Integer>> computeRepeatSlotIdList(List<Integer> slotIdList) {
List<Set<Integer>> groupingSetsIndexesInOutput = getGroupingSetsIndexesInOutput();
default List<Set<Integer>> computeRepeatSlotIdList(List<Integer> slotIdList, List<Slot> outputSlots) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a ut for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
default List<Set<Integer>> getGroupingSetsIndexesInOutput() {
Map<Expression, Integer> indexMap = indexesOfOutput();
default List<Set<Integer>> getGroupingSetsIndexesInOutput(List<Slot> outputSlots) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a ut for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* )
*/
default Map<Expression, Integer> indexesOfOutput() {
default Map<Expression, Integer> indexesOfOutput(List<Slot> outputSlots) {
Copy link
Contributor

Choose a reason for hiding this comment

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

add a ut for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}

public Set<GroupingScalarFunction> getGroupingScalarFunctions() {
return new HashSet<>(
Copy link
Contributor

Choose a reason for hiding this comment

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

return immutable set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

*/
default GroupingSetShapes toShapes() {
Set<Expression> flattenGroupingSet = ImmutableSet.copyOf(ExpressionUtils.flatExpressions(getGroupingSets()));
Set<Expression> flattenGroupingSet = ImmutableSet.copyOf(getGroupByExpressions());
Copy link
Contributor

Choose a reason for hiding this comment

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

if flattenGroupingSet only used in L138 to construct allExpresssions, why copy twice in this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

* )
*/
default Map<Expression, Integer> indexesOfOutput() {
default Map<Expression, Integer> indexesOfOutput(List<Slot> outputSlots) {
Copy link
Contributor

Choose a reason for hiding this comment

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

should add comment to explain why need pass outputSlots, not use outputExpression

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17713	5242	5028	5028
q2	2144	309	220	220
q3	10224	1293	755	755
q4	10239	869	321	321
q5	7506	2275	1893	1893
q6	190	178	148	148
q7	868	730	593	593
q8	9268	1334	1071	1071
q9	5065	4783	4747	4747
q10	7168	1939	1579	1579
q11	516	290	262	262
q12	337	371	226	226
q13	17776	4067	3251	3251
q14	229	236	229	229
q15	905	810	831	810
q16	673	681	622	622
q17	631	761	536	536
q18	6834	6488	7446	6488
q19	1646	1041	640	640
q20	406	345	243	243
q21	2906	2493	2155	2155
q22	371	308	287	287
Total cold run time: 103615 ms
Total hot run time: 32104 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5645	5427	5573	5427
q2	262	341	269	269
q3	2409	2875	2489	2489
q4	1459	1840	1683	1683
q5	4732	4447	4504	4447
q6	221	178	133	133
q7	2017	2054	1782	1782
q8	2564	2642	2332	2332
q9	7471	7384	7346	7346
q10	2727	3050	2596	2596
q11	529	448	429	429
q12	632	675	567	567
q13	3576	4021	3245	3245
q14	270	286	268	268
q15	841	802	793	793
q16	634	695	632	632
q17	1060	1298	1293	1293
q18	7387	7240	7350	7240
q19	820	780	779	779
q20	1948	2016	1888	1888
q21	4540	4188	4062	4062
q22	567	564	521	521
Total cold run time: 52311 ms
Total hot run time: 50221 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 28.33 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit ba33730c9a9eae32d12fb119cca04aec2b09282e, data reload: false

query1	0.05	0.05	0.04
query2	0.09	0.04	0.04
query3	0.26	0.09	0.08
query4	1.61	0.12	0.11
query5	0.28	0.24	0.25
query6	1.16	0.67	0.68
query7	0.03	0.03	0.02
query8	0.06	0.03	0.04
query9	0.56	0.50	0.49
query10	0.53	0.55	0.55
query11	0.14	0.09	0.09
query12	0.13	0.10	0.10
query13	0.64	0.61	0.61
query14	1.05	1.08	1.06
query15	0.87	0.86	0.88
query16	0.40	0.40	0.39
query17	1.14	1.13	1.08
query18	0.22	0.21	0.20
query19	2.10	2.02	1.94
query20	0.02	0.01	0.02
query21	15.42	0.26	0.15
query22	5.20	0.06	0.05
query23	16.04	0.28	0.10
query24	1.74	0.58	0.55
query25	0.10	0.06	0.08
query26	0.14	0.13	0.12
query27	0.06	0.08	0.05
query28	4.96	1.15	0.95
query29	12.57	3.93	3.15
query30	0.29	0.13	0.12
query31	2.82	0.63	0.39
query32	3.23	0.61	0.50
query33	3.36	3.19	3.33
query34	16.02	5.38	4.71
query35	4.82	4.83	4.79
query36	0.66	0.50	0.49
query37	0.11	0.07	0.06
query38	0.08	0.03	0.04
query39	0.04	0.02	0.02
query40	0.19	0.15	0.15
query41	0.10	0.03	0.03
query42	0.05	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 99.38 s
Total hot run time: 28.33 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (22/22) 🎉
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.

4 participants