Skip to content

Conversation

@seawinde
Copy link
Contributor

What problem does this PR solve?

if cte def has group sets, after cte inline, the aggregate source repeat output is different from child repeat
the pr fix this

such query as following

            with t as (
                select t1.l_partkey, t1.l_suppkey, o_orderdate,
                grouping(t1.l_suppkey),
                grouping(o_orderdate),
                grouping_id(t1.l_partkey, t1.l_suppkey),
                grouping_id(t1.l_partkey, t1.l_suppkey, o_orderdate),
                sum(o_totalprice),
                max(o_totalprice),
                min(o_totalprice),
                count(*),
                count(distinct case when o_shippriority > 1 and o_orderkey IN (1, 3) then o_custkey else null end)
                from (select * from lineitem where l_shipdate = '2023-12-11') t1
                left join orders on t1.l_orderkey = orders.o_orderkey and t1.l_shipdate = o_orderdate
                group by
                GROUPING SETS ((l_shipdate, o_orderdate, l_partkey), (l_partkey, l_suppkey), (l_suppkey), ())
            )
            select t1.l_suppkey, t2.o_orderdate
            from
            t t1
            inner join
            t t2 on t1.l_partkey = t2.l_partkey;

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 Nov 10, 2025

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
Contributor Author

run buildall

1 similar comment
@seawinde
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17673	5179	5261	5179
q2	2210	358	203	203
q3	10247	1302	722	722
q4	10235	867	365	365
q5	7438	2368	2302	2302
q6	187	171	136	136
q7	901	771	635	635
q8	9348	1334	1122	1122
q9	7015	5236	5199	5199
q10	7114	2217	1795	1795
q11	552	295	280	280
q12	345	365	223	223
q13	17783	3652	3031	3031
q14	235	230	207	207
q15	585	510	510	510
q16	962	999	947	947
q17	646	861	356	356
q18	7369	7207	7068	7068
q19	1186	935	551	551
q20	356	339	231	231
q21	3605	3172	2334	2334
q22	1093	1029	976	976
Total cold run time: 107085 ms
Total hot run time: 34372 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5143	5078	5100	5078
q2	247	344	226	226
q3	2177	2664	2330	2330
q4	1333	1751	1326	1326
q5	4209	4531	4589	4531
q6	202	171	128	128
q7	1993	2007	1810	1810
q8	2624	2594	2558	2558
q9	7379	7380	7353	7353
q10	3087	3274	2808	2808
q11	594	546	518	518
q12	676	832	638	638
q13	3551	3890	3337	3337
q14	280	308	314	308
q15	553	508	502	502
q16	1048	1098	1068	1068
q17	1172	1597	1364	1364
q18	7998	7818	7667	7667
q19	854	837	963	837
q20	1898	1955	1827	1827
q21	4708	4280	4358	4280
q22	1043	1041	1017	1017
Total cold run time: 52769 ms
Total hot run time: 51511 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 187623 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 847d97885430d3d0033362bab7dd9c763814e674, data reload: false

query1	1181	404	416	404
query2	6675	1720	1690	1690
query3	6834	235	223	223
query4	25989	23934	23231	23231
query5	4903	625	463	463
query6	328	239	219	219
query7	4665	503	307	307
query8	303	262	249	249
query9	8699	2593	2587	2587
query10	487	335	287	287
query11	15282	15243	14980	14980
query12	178	119	112	112
query13	1669	558	456	456
query14	10422	9285	9281	9281
query15	212	192	187	187
query16	7331	673	515	515
query17	1236	777	665	665
query18	2003	428	341	341
query19	215	206	197	197
query20	139	126	122	122
query21	267	133	117	117
query22	4136	4182	3928	3928
query23	34029	33014	33010	33010
query24	8448	2459	2453	2453
query25	641	533	487	487
query26	1311	276	162	162
query27	2665	502	366	366
query28	4397	2228	2176	2176
query29	860	657	522	522
query30	337	232	200	200
query31	912	822	734	734
query32	88	79	72	72
query33	639	401	343	343
query34	807	856	530	530
query35	903	842	735	735
query36	916	1007	869	869
query37	164	106	85	85
query38	3560	3459	3479	3459
query39	1507	1409	1404	1404
query40	225	128	117	117
query41	62	59	65	59
query42	129	112	111	111
query43	486	496	469	469
query44	1239	760	744	744
query45	192	181	180	180
query46	885	993	673	673
query47	1750	1775	1704	1704
query48	392	424	322	322
query49	789	510	430	430
query50	637	679	404	404
query51	3914	3882	3889	3882
query52	110	108	98	98
query53	246	276	200	200
query54	314	294	279	279
query55	85	86	84	84
query56	321	307	306	306
query57	1178	1188	1121	1121
query58	283	271	269	269
query59	2528	2735	2487	2487
query60	339	350	327	327
query61	164	164	161	161
query62	789	718	665	665
query63	228	229	194	194
query64	4519	1162	854	854
query65	4048	3913	3946	3913
query66	1191	464	339	339
query67	15314	15129	14931	14931
query68	8400	935	602	602
query69	484	323	286	286
query70	1365	1290	1264	1264
query71	490	343	311	311
query72	6015	4825	4875	4825
query73	665	561	355	355
query74	9089	8865	8640	8640
query75	4032	3316	2823	2823
query76	3808	1150	752	752
query77	837	407	319	319
query78	9473	9532	8860	8860
query79	4381	824	578	578
query80	702	568	505	505
query81	483	269	231	231
query82	599	162	132	132
query83	303	265	249	249
query84	303	109	91	91
query85	889	479	447	447
query86	392	310	296	296
query87	3781	3676	3620	3620
query88	3606	2265	2251	2251
query89	442	330	293	293
query90	1987	224	239	224
query91	169	162	133	133
query92	80	69	69	69
query93	3374	962	642	642
query94	689	445	343	343
query95	408	324	316	316
query96	489	586	294	294
query97	2949	2962	2870	2870
query98	245	221	213	213
query99	1440	1406	1298	1298
Total cold run time: 280064 ms
Total hot run time: 187623 ms

@doris-robot
Copy link

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

query1	0.05	0.04	0.05
query2	0.13	0.05	0.05
query3	0.27	0.08	0.09
query4	1.61	0.11	0.12
query5	0.27	0.25	0.25
query6	1.20	0.65	0.63
query7	0.04	0.03	0.04
query8	0.06	0.05	0.04
query9	0.62	0.53	0.51
query10	0.59	0.58	0.57
query11	0.18	0.11	0.11
query12	0.16	0.11	0.12
query13	0.61	0.59	0.60
query14	1.00	1.01	1.00
query15	0.85	0.83	0.83
query16	0.38	0.39	0.39
query17	0.98	1.04	1.07
query18	0.22	0.20	0.21
query19	1.88	1.81	1.78
query20	0.02	0.01	0.01
query21	15.44	0.18	0.12
query22	5.19	0.07	0.05
query23	15.67	0.26	0.10
query24	3.61	0.56	0.43
query25	0.08	0.05	0.05
query26	0.14	0.13	0.14
query27	0.08	0.05	0.07
query28	4.32	1.15	0.92
query29	12.59	3.85	3.25
query30	0.28	0.14	0.12
query31	2.82	0.61	0.38
query32	3.23	0.54	0.48
query33	3.02	3.02	3.12
query34	15.76	5.18	4.55
query35	4.55	4.62	4.61
query36	0.69	0.51	0.49
query37	0.12	0.06	0.07
query38	0.08	0.04	0.04
query39	0.05	0.03	0.03
query40	0.17	0.14	0.14
query41	0.11	0.04	0.03
query42	0.06	0.03	0.03
query43	0.05	0.03	0.04
Total cold run time: 99.23 s
Total hot run time: 27.48 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 85.71% (6/7) 🎉
Increment coverage report
Complete coverage report

@seawinde seawinde force-pushed the fix_aggregate_source_repeat_is_not_equals_child branch from 847d978 to 410eb1a Compare November 12, 2025 06:57
@seawinde
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17589	5233	5034	5034
q2	1990	307	210	210
q3	10277	1289	724	724
q4	10221	862	378	378
q5	7540	2284	2439	2284
q6	173	165	134	134
q7	877	772	613	613
q8	9336	1308	1142	1142
q9	6914	5118	5093	5093
q10	6894	2214	1840	1840
q11	495	297	274	274
q12	370	356	229	229
q13	18170	3706	3034	3034
q14	232	241	215	215
q15	583	508	510	508
q16	977	999	951	951
q17	612	859	351	351
q18	7445	7009	6961	6961
q19	1403	955	539	539
q20	342	336	227	227
q21	3746	3231	2336	2336
q22	1063	1003	946	946
Total cold run time: 107249 ms
Total hot run time: 34023 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5151	5120	5130	5120
q2	248	337	232	232
q3	2184	2648	2274	2274
q4	1385	1760	1299	1299
q5	4219	4352	4466	4352
q6	216	169	131	131
q7	2042	2006	1821	1821
q8	2644	2615	2618	2615
q9	7371	7331	7294	7294
q10	3068	3245	2762	2762
q11	596	552	506	506
q12	696	979	622	622
q13	3468	3918	3340	3340
q14	298	315	271	271
q15	553	520	511	511
q16	1166	1093	1080	1080
q17	1184	1521	1409	1409
q18	7823	7695	7549	7549
q19	968	862	1006	862
q20	1945	2045	1958	1958
q21	4690	4394	4254	4254
q22	1064	1050	991	991
Total cold run time: 52979 ms
Total hot run time: 51253 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 187121 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 410eb1a9d702e2d7b607d1547228fd017b47bbea, data reload: false

query1	1043	400	403	400
query2	6577	1739	1711	1711
query3	6755	225	224	224
query4	26553	23696	23135	23135
query5	4430	634	492	492
query6	325	232	210	210
query7	4639	489	289	289
query8	311	239	236	236
query9	8724	2574	2588	2574
query10	487	340	284	284
query11	16104	15130	14825	14825
query12	175	118	113	113
query13	1695	552	438	438
query14	10780	9176	9456	9176
query15	191	191	163	163
query16	7262	699	510	510
query17	1240	772	602	602
query18	1979	411	318	318
query19	208	201	171	171
query20	132	131	123	123
query21	214	136	110	110
query22	3947	4346	3920	3920
query23	33634	33062	32933	32933
query24	8469	2419	2392	2392
query25	601	506	436	436
query26	1238	270	162	162
query27	2772	505	351	351
query28	4375	2213	2169	2169
query29	828	614	482	482
query30	294	232	196	196
query31	916	833	713	713
query32	79	68	67	67
query33	616	365	322	322
query34	780	838	527	527
query35	808	830	736	736
query36	995	986	920	920
query37	121	111	82	82
query38	3526	3560	3433	3433
query39	1477	1447	1437	1437
query40	232	132	123	123
query41	71	64	67	64
query42	130	118	112	112
query43	496	483	477	477
query44	1238	762	742	742
query45	195	187	175	175
query46	890	1003	648	648
query47	1745	1781	1711	1711
query48	390	431	324	324
query49	798	565	433	433
query50	641	682	410	410
query51	3922	3946	3867	3867
query52	109	109	104	104
query53	243	276	206	206
query54	327	306	320	306
query55	95	87	83	83
query56	326	342	321	321
query57	1232	1193	1106	1106
query58	296	295	276	276
query59	2603	2643	2483	2483
query60	360	360	341	341
query61	195	193	185	185
query62	806	738	662	662
query63	227	196	192	192
query64	4692	1283	1030	1030
query65	4016	3933	3905	3905
query66	1196	450	354	354
query67	15387	15042	14781	14781
query68	8237	939	606	606
query69	522	330	299	299
query70	1362	1285	1235	1235
query71	480	346	312	312
query72	5837	4901	4907	4901
query73	667	608	362	362
query74	9006	9102	8654	8654
query75	3930	3323	2832	2832
query76	3739	1153	763	763
query77	813	401	310	310
query78	9567	9770	8940	8940
query79	2274	823	599	599
query80	655	561	512	512
query81	510	263	231	231
query82	453	163	134	134
query83	263	265	254	254
query84	256	110	101	101
query85	940	497	434	434
query86	391	311	307	307
query87	3675	3728	3630	3630
query88	3778	2248	2228	2228
query89	383	334	295	295
query90	1867	225	224	224
query91	166	167	135	135
query92	86	69	66	66
query93	1914	973	635	635
query94	714	456	333	333
query95	397	310	315	310
query96	485	579	285	285
query97	2895	2986	2879	2879
query98	231	224	224	224
query99	1667	1398	1288	1288
Total cold run time: 276318 ms
Total hot run time: 187121 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 410eb1a9d702e2d7b607d1547228fd017b47bbea, data reload: false

query1	0.06	0.05	0.05
query2	0.10	0.06	0.05
query3	0.25	0.08	0.08
query4	1.63	0.12	0.11
query5	0.28	0.26	0.25
query6	1.17	0.64	0.64
query7	0.03	0.03	0.02
query8	0.05	0.04	0.05
query9	0.57	0.53	0.52
query10	0.57	0.57	0.56
query11	0.16	0.11	0.11
query12	0.14	0.12	0.12
query13	0.62	0.60	0.59
query14	1.00	0.98	0.98
query15	0.85	0.81	0.83
query16	0.38	0.40	0.39
query17	1.04	1.04	1.01
query18	0.22	0.19	0.20
query19	1.88	1.78	1.80
query20	0.01	0.02	0.01
query21	15.45	0.20	0.13
query22	5.03	0.07	0.04
query23	15.67	0.26	0.09
query24	3.05	0.87	0.33
query25	0.08	0.05	0.06
query26	0.14	0.14	0.12
query27	0.06	0.05	0.05
query28	4.68	1.15	0.92
query29	12.59	3.91	3.24
query30	0.32	0.14	0.12
query31	2.82	0.58	0.38
query32	3.22	0.55	0.46
query33	3.07	3.01	3.07
query34	15.95	5.18	4.50
query35	4.60	4.56	4.59
query36	0.69	0.50	0.48
query37	0.11	0.07	0.07
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.14	0.13
query41	0.09	0.04	0.03
query42	0.04	0.04	0.04
query43	0.04	0.04	0.03
Total cold run time: 98.98 s
Total hot run time: 27.16 s

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 85.71% (6/7) 🎉
Increment coverage report
Complete coverage report

@seawinde seawinde force-pushed the fix_aggregate_source_repeat_is_not_equals_child branch from 410eb1a to 846b10d Compare November 13, 2025 02:22
@seawinde
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17680	5189	5068	5068
q2	2174	311	208	208
q3	10327	1283	712	712
q4	10288	922	363	363
q5	7522	2407	2336	2336
q6	180	171	138	138
q7	941	786	648	648
q8	9432	1321	1157	1157
q9	7175	5186	5168	5168
q10	7188	2229	1820	1820
q11	675	295	285	285
q12	658	383	240	240
q13	18530	3660	3067	3067
q14	229	251	219	219
q15	601	532	507	507
q16	995	1004	924	924
q17	583	859	362	362
q18	7559	7805	7691	7691
q19	1757	984	562	562
q20	354	343	234	234
q21	4267	3644	2488	2488
q22	1137	1146	1060	1060
Total cold run time: 110252 ms
Total hot run time: 35257 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5568	5531	5372	5372
q2	235	343	242	242
q3	2359	2810	2469	2469
q4	1445	1877	1437	1437
q5	4508	4473	4480	4473
q6	213	172	133	133
q7	2034	1899	1802	1802
q8	2620	2621	2538	2538
q9	7346	7465	7449	7449
q10	3012	3097	2674	2674
q11	554	497	500	497
q12	629	717	590	590
q13	3225	3595	3078	3078
q14	271	287	256	256
q15	538	501	491	491
q16	1011	1046	1000	1000
q17	1108	1482	1323	1323
q18	7227	7096	7016	7016
q19	769	749	859	749
q20	1902	1950	1787	1787
q21	4782	4439	4255	4255
q22	1059	1030	988	988
Total cold run time: 52415 ms
Total hot run time: 50619 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 187624 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 846b10d5c3ec6638c7a87b638337978a828aa083, data reload: false

query1	1480	392	387	387
query2	6661	1646	1731	1646
query3	6922	234	237	234
query4	25832	23322	23019	23019
query5	4672	616	479	479
query6	360	242	223	223
query7	4655	498	300	300
query8	320	264	245	245
query9	8705	2556	2543	2543
query10	488	323	292	292
query11	15280	15055	14755	14755
query12	172	124	114	114
query13	1686	574	445	445
query14	10825	9178	9145	9145
query15	196	193	178	178
query16	7749	705	528	528
query17	1270	769	650	650
query18	2080	433	336	336
query19	218	211	186	186
query20	135	125	129	125
query21	558	133	118	118
query22	4372	4270	4003	4003
query23	33925	32998	32943	32943
query24	8436	2432	2434	2432
query25	642	538	482	482
query26	1362	267	158	158
query27	2680	512	357	357
query28	4364	2201	2192	2192
query29	782	619	484	484
query30	381	228	199	199
query31	896	806	739	739
query32	90	72	74	72
query33	625	384	320	320
query34	802	843	522	522
query35	811	824	749	749
query36	958	971	871	871
query37	164	112	86	86
query38	3523	3523	3485	3485
query39	1500	1402	1454	1402
query40	257	127	119	119
query41	63	62	62	62
query42	126	111	109	109
query43	500	510	460	460
query44	1222	736	739	736
query45	190	176	172	172
query46	864	987	637	637
query47	1762	1805	1751	1751
query48	390	427	319	319
query49	869	512	461	461
query50	645	696	401	401
query51	3850	3872	3820	3820
query52	115	112	98	98
query53	235	275	197	197
query54	317	287	276	276
query55	87	86	88	86
query56	328	306	296	296
query57	1236	1196	1135	1135
query58	281	277	267	267
query59	2553	2668	2583	2583
query60	356	346	315	315
query61	167	160	156	156
query62	809	737	711	711
query63	233	193	197	193
query64	4378	1155	855	855
query65	4030	3964	3894	3894
query66	1092	470	335	335
query67	15393	15163	15347	15163
query68	8679	888	599	599
query69	496	327	283	283
query70	1349	1314	1242	1242
query71	470	339	303	303
query72	5631	4919	4818	4818
query73	691	573	367	367
query74	8780	9091	9033	9033
query75	3938	3367	2831	2831
query76	3692	1163	725	725
query77	912	413	304	304
query78	9460	9803	8916	8916
query79	2025	851	617	617
query80	764	576	512	512
query81	551	271	234	234
query82	422	162	134	134
query83	295	259	245	245
query84	343	116	93	93
query85	1057	479	430	430
query86	354	329	304	304
query87	3785	3780	3671	3671
query88	3149	2292	2248	2248
query89	392	329	290	290
query90	1985	217	211	211
query91	163	166	136	136
query92	79	70	63	63
query93	1152	1010	684	684
query94	703	447	343	343
query95	404	323	307	307
query96	483	572	283	283
query97	2915	2990	2836	2836
query98	236	210	210	210
query99	1464	1424	1301	1301
Total cold run time: 275744 ms
Total hot run time: 187624 ms

@doris-robot
Copy link

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

query1	0.06	0.04	0.05
query2	0.24	0.04	0.05
query3	0.37	0.08	0.08
query4	1.74	0.11	0.11
query5	0.26	0.24	0.24
query6	1.17	0.66	0.64
query7	0.04	0.02	0.03
query8	0.06	0.04	0.04
query9	0.66	0.53	0.51
query10	0.58	0.57	0.58
query11	0.31	0.12	0.11
query12	0.20	0.12	0.11
query13	0.62	0.60	0.59
query14	1.01	0.99	1.01
query15	0.86	0.83	0.83
query16	0.39	0.39	0.38
query17	1.00	1.03	1.05
query18	0.21	0.20	0.20
query19	2.02	1.77	1.79
query20	0.02	0.02	0.01
query21	15.67	0.17	0.13
query22	4.94	0.08	0.05
query23	15.78	0.25	0.11
query24	6.91	0.37	0.45
query25	0.08	0.06	0.06
query26	0.15	0.13	0.14
query27	0.06	0.05	0.06
query28	4.07	1.13	0.94
query29	12.71	3.84	3.18
query30	0.29	0.15	0.12
query31	2.82	0.61	0.38
query32	3.23	0.55	0.47
query33	3.10	3.01	3.07
query34	15.92	5.13	4.53
query35	4.57	4.54	4.57
query36	0.67	0.50	0.48
query37	0.16	0.07	0.07
query38	0.06	0.04	0.04
query39	0.05	0.03	0.03
query40	0.17	0.14	0.13
query41	0.13	0.04	0.03
query42	0.05	0.02	0.02
query43	0.04	0.04	0.03
Total cold run time: 103.45 s
Total hot run time: 27.21 s

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the deep copy logic for LogicalAggregate nodes that have a sourceRepeat reference. When CTEs containing GROUP SETS are inlined, the aggregate's sourceRepeat field needs to point to the newly copied repeat node rather than the original one. The fix ensures that after deep copying, the sourceRepeat reference is updated to point to the copied child repeat node.

Key Changes:

  • Updates LogicalPlanDeepCopier.visitLogicalAggregate() to re-establish the sourceRepeat reference after copying
  • Adds comprehensive test coverage for both cases (with and without sourceRepeat)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/copier/LogicalPlanDeepCopier.java Updates the deep copy logic to find and update the sourceRepeat reference to the copied repeat node after creating a deep copy of the aggregate
fe/fe-core/src/test/java/org/apache/doris/nereids/trees/copier/LogicalPlanDeepCopierTest.java Adds two new test cases to verify correct deep copying behavior for aggregates with and without sourceRepeat references

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Optional<LogicalRepeat<? extends Plan>> childRepeat =
copiedAggregate.collectFirst(LogicalRepeat.class::isInstance);
if (childRepeat.isPresent()) {
copiedAggregate = copiedAggregate.withSourceRepeat(childRepeat.get());
Copy link
Contributor

Choose a reason for hiding this comment

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

do not call withXXXX twice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

have fixed

@seawinde
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17668	5225	5069	5069
q2	2018	312	205	205
q3	10279	1271	694	694
q4	10235	878	358	358
q5	7513	2394	2326	2326
q6	182	175	142	142
q7	909	789	632	632
q8	9353	1396	1092	1092
q9	6914	5124	5206	5124
q10	6870	2227	1805	1805
q11	500	305	284	284
q12	331	360	227	227
q13	17804	3668	2999	2999
q14	236	249	216	216
q15	576	508	521	508
q16	1017	1005	935	935
q17	595	862	390	390
q18	7441	7465	7666	7465
q19	1598	997	569	569
q20	343	374	239	239
q21	3969	3410	2369	2369
q22	1108	1087	1072	1072
Total cold run time: 107459 ms
Total hot run time: 34720 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5340	5296	5433	5296
q2	281	342	228	228
q3	2292	3027	2521	2521
q4	1495	1845	1473	1473
q5	4770	4345	4371	4345
q6	227	159	125	125
q7	1978	1913	1766	1766
q8	2656	2526	2493	2493
q9	7298	7157	7472	7157
q10	2957	3147	2676	2676
q11	588	505	489	489
q12	620	710	594	594
q13	3265	3642	3081	3081
q14	266	280	251	251
q15	529	504	483	483
q16	1015	1048	996	996
q17	1116	1492	1335	1335
q18	7194	7189	6986	6986
q19	791	788	844	788
q20	1888	1951	1795	1795
q21	4686	4435	4249	4249
q22	1096	1033	1005	1005
Total cold run time: 52348 ms
Total hot run time: 50132 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 187803 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 9ae73f6bfedc56c1c97e2ce881e0111f6d0b463e, data reload: false

query1	1026	401	383	383
query2	6592	1708	1724	1708
query3	6756	237	226	226
query4	26228	23585	23513	23513
query5	4421	610	475	475
query6	330	239	223	223
query7	4643	496	292	292
query8	302	257	245	245
query9	8732	2576	2577	2576
query10	511	344	301	301
query11	15338	15040	14860	14860
query12	176	124	115	115
query13	1692	575	448	448
query14	10437	9177	9088	9088
query15	208	185	170	170
query16	7378	664	490	490
query17	1237	758	632	632
query18	1988	408	313	313
query19	209	202	174	174
query20	133	122	131	122
query21	213	128	112	112
query22	3910	4069	3892	3892
query23	33863	32893	32986	32893
query24	8524	2425	2409	2409
query25	628	547	475	475
query26	1245	278	164	164
query27	2761	496	359	359
query28	4384	2217	2205	2205
query29	868	656	515	515
query30	313	230	198	198
query31	910	821	750	750
query32	88	76	78	76
query33	624	406	339	339
query34	794	848	527	527
query35	805	853	755	755
query36	980	976	911	911
query37	128	109	91	91
query38	3620	3604	3452	3452
query39	1480	1444	1416	1416
query40	229	130	120	120
query41	67	63	63	63
query42	128	114	111	111
query43	503	516	479	479
query44	1242	750	752	750
query45	187	187	172	172
query46	889	1001	647	647
query47	1741	1807	1710	1710
query48	391	430	327	327
query49	802	515	461	461
query50	660	689	418	418
query51	3941	3946	3932	3932
query52	117	122	100	100
query53	244	278	195	195
query54	322	308	291	291
query55	88	91	86	86
query56	357	344	318	318
query57	1181	1201	1121	1121
query58	301	273	272	272
query59	2519	2688	2559	2559
query60	356	359	342	342
query61	216	152	157	152
query62	771	727	679	679
query63	228	188	197	188
query64	4561	1183	848	848
query65	4082	3980	3974	3974
query66	1173	437	347	347
query67	15179	14970	14779	14779
query68	8269	955	596	596
query69	492	338	281	281
query70	1353	1249	1296	1249
query71	483	345	310	310
query72	5842	4985	4914	4914
query73	679	580	365	365
query74	8967	9143	8786	8786
query75	3974	3263	2791	2791
query76	3733	1172	756	756
query77	821	413	317	317
query78	9514	9715	8934	8934
query79	2003	842	606	606
query80	671	574	507	507
query81	484	261	224	224
query82	426	161	132	132
query83	275	267	251	251
query84	246	117	103	103
query85	920	481	456	456
query86	345	311	310	310
query87	3712	3752	3605	3605
query88	3493	2276	2266	2266
query89	388	334	297	297
query90	1939	227	214	214
query91	167	169	142	142
query92	83	68	67	67
query93	1237	982	668	668
query94	723	460	342	342
query95	399	324	310	310
query96	488	568	305	305
query97	2917	2981	2860	2860
query98	254	211	211	211
query99	1664	1395	1294	1294
Total cold run time: 273911 ms
Total hot run time: 187803 ms

@doris-robot
Copy link

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

query1	0.05	0.05	0.05
query2	0.09	0.04	0.05
query3	0.25	0.08	0.08
query4	1.60	0.11	0.11
query5	0.26	0.25	0.27
query6	1.17	0.64	0.64
query7	0.03	0.02	0.02
query8	0.05	0.04	0.05
query9	0.57	0.51	0.52
query10	0.58	0.56	0.56
query11	0.15	0.11	0.11
query12	0.15	0.12	0.12
query13	0.62	0.61	0.60
query14	1.00	0.99	1.00
query15	0.85	0.82	0.84
query16	0.39	0.39	0.39
query17	1.06	1.04	1.02
query18	0.22	0.20	0.19
query19	1.85	1.79	1.80
query20	0.02	0.01	0.01
query21	15.76	0.19	0.13
query22	5.70	0.06	0.05
query23	15.67	0.26	0.10
query24	2.80	0.63	0.82
query25	0.07	0.07	0.06
query26	0.14	0.14	0.14
query27	0.06	0.05	0.05
query28	4.51	1.14	0.93
query29	12.56	3.91	3.18
query30	0.28	0.14	0.13
query31	2.81	0.58	0.38
query32	3.23	0.54	0.46
query33	3.00	3.03	3.07
query34	15.93	5.18	4.50
query35	4.65	4.59	4.56
query36	0.68	0.50	0.49
query37	0.10	0.07	0.06
query38	0.07	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.14	0.15
query41	0.10	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 99.37 s
Total hot run time: 27.52 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

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

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

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

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Nov 17, 2025
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@starocean999 starocean999 merged commit 893a1e9 into apache:master Nov 17, 2025
28 of 30 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 17, 2025
…hild repeat (#57840)

if cte def has group sets, after cte inline, the aggregate source repeat
output is different from child repeat
the pr fix this

such query as following
```sql
            with t as (
                select t1.l_partkey, t1.l_suppkey, o_orderdate,
                grouping(t1.l_suppkey),
                grouping(o_orderdate),
                grouping_id(t1.l_partkey, t1.l_suppkey),
                grouping_id(t1.l_partkey, t1.l_suppkey, o_orderdate),
                sum(o_totalprice),
                max(o_totalprice),
                min(o_totalprice),
                count(*),
                count(distinct case when o_shippriority > 1 and o_orderkey IN (1, 3) then o_custkey else null end)
                from (select * from lineitem where l_shipdate = '2023-12-11') t1
                left join orders on t1.l_orderkey = orders.o_orderkey and t1.l_shipdate = o_orderdate
                group by
                GROUPING SETS ((l_shipdate, o_orderdate, l_partkey), (l_partkey, l_suppkey), (l_suppkey), ())
            )
            select t1.l_suppkey, t2.o_orderdate
            from
            t t1
            inner join
            t t2 on t1.l_partkey = t2.l_partkey;
```
yiguolei pushed a commit that referenced this pull request Nov 18, 2025
…erent from child repeat #57840 (#58088)

Cherry-picked from #57840

Co-authored-by: seawinde <wusi@selectdb.com>
seawinde added a commit to seawinde/doris that referenced this pull request Nov 18, 2025
…hild repeat (apache#57840)

if cte def has group sets, after cte inline, the aggregate source repeat
output is different from child repeat
the pr fix this

such query as following
```sql
            with t as (
                select t1.l_partkey, t1.l_suppkey, o_orderdate,
                grouping(t1.l_suppkey),
                grouping(o_orderdate),
                grouping_id(t1.l_partkey, t1.l_suppkey),
                grouping_id(t1.l_partkey, t1.l_suppkey, o_orderdate),
                sum(o_totalprice),
                max(o_totalprice),
                min(o_totalprice),
                count(*),
                count(distinct case when o_shippriority > 1 and o_orderkey IN (1, 3) then o_custkey else null end)
                from (select * from lineitem where l_shipdate = '2023-12-11') t1
                left join orders on t1.l_orderkey = orders.o_orderkey and t1.l_shipdate = o_orderdate
                group by
                GROUPING SETS ((l_shipdate, o_orderdate, l_partkey), (l_partkey, l_suppkey), (l_suppkey), ())
            )
            select t1.l_suppkey, t2.o_orderdate
            from
            t t1
            inner join
            t t2 on t1.l_partkey = t2.l_partkey;
```
morrySnow pushed a commit that referenced this pull request Nov 25, 2025
morrySnow pushed a commit that referenced this pull request Dec 1, 2025
github-actions bot pushed a commit that referenced this pull request Dec 1, 2025
github-actions bot pushed a commit that referenced this pull request Dec 1, 2025
nagisa-kunhah pushed a commit to nagisa-kunhah/doris that referenced this pull request Dec 14, 2025
…hild repeat (apache#57840)

if cte def has group sets, after cte inline, the aggregate source repeat
output is different from child repeat
the pr fix this

such query as following
```sql
            with t as (
                select t1.l_partkey, t1.l_suppkey, o_orderdate,
                grouping(t1.l_suppkey),
                grouping(o_orderdate),
                grouping_id(t1.l_partkey, t1.l_suppkey),
                grouping_id(t1.l_partkey, t1.l_suppkey, o_orderdate),
                sum(o_totalprice),
                max(o_totalprice),
                min(o_totalprice),
                count(*),
                count(distinct case when o_shippriority > 1 and o_orderkey IN (1, 3) then o_custkey else null end)
                from (select * from lineitem where l_shipdate = '2023-12-11') t1
                left join orders on t1.l_orderkey = orders.o_orderkey and t1.l_shipdate = o_orderdate
                group by
                GROUPING SETS ((l_shipdate, o_orderdate, l_partkey), (l_partkey, l_suppkey), (l_suppkey), ())
            )
            select t1.l_suppkey, t2.o_orderdate
            from
            t t1
            inner join
            t t2 on t1.l_partkey = t2.l_partkey;
```
nagisa-kunhah pushed a commit to nagisa-kunhah/doris that referenced this pull request Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/3.1.4-merged dev/4.0.2-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants