Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix](nereids) fix NormalizeAgg, change the upper project projections rewrite logic #36161

Merged
merged 2 commits into from
Jun 20, 2024

Conversation

feiniaofeiafei
Copy link
Contributor

@feiniaofeiafei feiniaofeiafei commented Jun 12, 2024

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only output count(DISTINCT cast(NULL as SIGNED))#3, do not output cast(NULL as SIGNED)#2, but the upper project use cast(NULL as SIGNED)#2, so Doris report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] )
+--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)#2) AS `count(DISTINCT cast(NULL as SIGNED))`#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)#2 should not outputted by LogicalAggregate, cast(NULL as SIGNED) should be computed in LogicalProject.
This pr change the upper project projections rewrite logic: aggregateOutputs is rewritten and become the upper-level LogicalProject projections. During the rewriting process, the expressions inside the agg function can be rewritten with expressions in aggregate function arguments and group by expressions, but the ones outside the agg function can only be rewritten with group by expressions.

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17613	4317	4314	4314
q2	2021	190	190	190
q3	10475	1124	1112	1112
q4	10190	760	803	760
q5	7470	2691	2642	2642
q6	225	138	138	138
q7	957	601	591	591
q8	9217	2059	2033	2033
q9	9078	6446	6478	6446
q10	9010	3730	3764	3730
q11	450	237	231	231
q12	482	231	225	225
q13	18701	2942	2988	2942
q14	288	217	216	216
q15	517	475	484	475
q16	530	379	377	377
q17	951	627	627	627
q18	7999	7551	7465	7465
q19	6608	1391	1457	1391
q20	661	296	310	296
q21	4969	3227	3119	3119
q22	384	326	328	326
Total cold run time: 118796 ms
Total hot run time: 39646 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4427	4282	4285	4282
q2	364	260	271	260
q3	2980	2955	2911	2911
q4	1994	1716	1720	1716
q5	5590	5441	5468	5441
q6	233	129	130	129
q7	2225	1860	1903	1860
q8	3269	3441	3460	3441
q9	8691	8741	8754	8741
q10	4117	3798	3792	3792
q11	590	488	495	488
q12	784	649	668	649
q13	17311	3185	3149	3149
q14	305	288	269	269
q15	529	476	490	476
q16	484	456	434	434
q17	1798	1505	1526	1505
q18	8264	7831	7745	7745
q19	4469	1576	1549	1549
q20	3230	1864	1837	1837
q21	5056	4705	4929	4705
q22	616	543	530	530
Total cold run time: 77326 ms
Total hot run time: 55909 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 173941 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 146faadb9b8b18c69c5cae6e7905a8d6a2419562, data reload: false

query1	942	378	368	368
query2	6358	2432	2289	2289
query3	6648	214	212	212
query4	18928	17246	17260	17246
query5	3568	480	475	475
query6	240	164	159	159
query7	4594	303	295	295
query8	329	292	293	292
query9	8480	2352	2322	2322
query10	563	332	282	282
query11	10642	10026	10010	10010
query12	116	90	85	85
query13	1632	366	369	366
query14	8743	7892	7644	7644
query15	256	188	183	183
query16	8018	263	264	263
query17	1930	563	522	522
query18	2068	280	278	278
query19	219	152	155	152
query20	92	84	88	84
query21	206	128	130	128
query22	4304	4082	4070	4070
query23	33547	33424	33387	33387
query24	10990	2907	2962	2907
query25	619	376	382	376
query26	1153	163	155	155
query27	2674	337	339	337
query28	7674	2095	2068	2068
query29	866	660	691	660
query30	243	149	167	149
query31	940	779	747	747
query32	95	56	55	55
query33	757	290	292	290
query34	1076	510	478	478
query35	737	636	678	636
query36	1112	966	977	966
query37	168	73	74	73
query38	2912	2820	2820	2820
query39	896	855	832	832
query40	229	132	133	132
query41	59	60	54	54
query42	132	109	108	108
query43	608	537	544	537
query44	1231	739	754	739
query45	201	170	169	169
query46	1105	724	739	724
query47	1842	1787	1774	1774
query48	382	309	304	304
query49	884	413	432	413
query50	767	402	403	402
query51	6767	6678	6581	6581
query52	110	92	97	92
query53	357	298	307	298
query54	916	461	478	461
query55	75	76	75	75
query56	275	250	264	250
query57	1121	1059	1063	1059
query58	266	253	247	247
query59	3492	3349	3229	3229
query60	298	279	271	271
query61	94	88	88	88
query62	588	459	442	442
query63	324	292	301	292
query64	8869	2339	1720	1720
query65	3205	3113	3131	3113
query66	750	334	327	327
query67	15391	14872	14770	14770
query68	5693	550	558	550
query69	623	438	402	402
query70	1121	1105	1170	1105
query71	480	275	274	274
query72	7232	5661	5441	5441
query73	777	329	329	329
query74	5947	5532	5408	5408
query75	3768	2631	2696	2631
query76	3298	993	941	941
query77	631	300	303	300
query78	10436	9559	9770	9559
query79	2172	522	521	521
query80	1083	467	461	461
query81	598	219	219	219
query82	1438	108	102	102
query83	237	169	170	169
query84	235	86	87	86
query85	1459	283	275	275
query86	460	300	326	300
query87	3236	3092	3091	3091
query88	4167	2463	2442	2442
query89	490	383	387	383
query90	1708	191	193	191
query91	130	98	99	98
query92	58	49	50	49
query93	2203	505	515	505
query94	1033	189	188	188
query95	411	328	311	311
query96	593	278	269	269
query97	3171	3050	2994	2994
query98	237	196	195	195
query99	1198	820	821	820
Total cold run time: 271996 ms
Total hot run time: 173941 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.07	0.04	0.05
query3	0.23	0.05	0.05
query4	1.69	0.07	0.08
query5	0.51	0.49	0.50
query6	1.13	0.72	0.72
query7	0.02	0.01	0.02
query8	0.06	0.04	0.04
query9	0.54	0.49	0.49
query10	0.56	0.55	0.54
query11	0.15	0.12	0.12
query12	0.15	0.12	0.12
query13	0.60	0.59	0.60
query14	0.77	0.79	0.78
query15	0.83	0.80	0.81
query16	0.37	0.38	0.35
query17	1.03	1.00	0.96
query18	0.22	0.25	0.25
query19	1.76	1.71	1.77
query20	0.02	0.01	0.02
query21	15.43	0.67	0.66
query22	4.24	7.57	1.96
query23	18.27	1.38	1.23
query24	2.10	0.24	0.22
query25	0.17	0.08	0.08
query26	0.26	0.17	0.16
query27	0.08	0.09	0.07
query28	13.24	1.01	0.99
query29	12.56	3.33	3.28
query30	0.26	0.06	0.06
query31	2.87	0.39	0.39
query32	3.27	0.48	0.47
query33	2.91	2.86	2.89
query34	17.00	4.44	4.39
query35	4.48	4.45	4.45
query36	0.65	0.45	0.46
query37	0.19	0.15	0.14
query38	0.14	0.14	0.14
query39	0.05	0.03	0.04
query40	0.17	0.15	0.14
query41	0.09	0.05	0.05
query42	0.06	0.05	0.05
query43	0.04	0.04	0.04
Total cold run time: 109.28 s
Total hot run time: 30.48 s

@morrySnow morrySnow marked this pull request as draft June 12, 2024 06:05
@feiniaofeiafei
Copy link
Contributor Author

run p0

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	18075	4568	4421	4421
q2	2661	202	195	195
q3	11448	1095	1154	1095
q4	10446	881	727	727
q5	7874	2734	2641	2641
q6	227	142	139	139
q7	963	625	603	603
q8	9668	2099	2048	2048
q9	8795	6481	6465	6465
q10	8853	3696	3700	3696
q11	460	236	238	236
q12	430	228	219	219
q13	17756	2959	2979	2959
q14	263	213	224	213
q15	520	474	484	474
q16	523	372	379	372
q17	957	672	757	672
q18	7960	7477	7472	7472
q19	5380	1491	1553	1491
q20	699	317	331	317
q21	4924	3160	3861	3160
q22	391	336	348	336
Total cold run time: 119273 ms
Total hot run time: 39951 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4431	4265	4259	4259
q2	378	257	259	257
q3	2929	2685	2755	2685
q4	1842	1575	1608	1575
q5	5253	5235	5279	5235
q6	216	128	127	127
q7	2102	1683	1741	1683
q8	3187	3330	3287	3287
q9	8274	8275	8303	8275
q10	3863	3654	3647	3647
q11	575	473	477	473
q12	777	585	611	585
q13	16289	2929	2956	2929
q14	301	261	252	252
q15	518	469	477	469
q16	467	413	415	413
q17	1748	1491	1448	1448
q18	7662	7521	7340	7340
q19	1675	1573	1738	1573
q20	1991	1771	1793	1771
q21	4732	4767	4737	4737
q22	612	527	551	527
Total cold run time: 69822 ms
Total hot run time: 53547 ms

@doris-robot
Copy link

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

query1	936	367	377	367
query2	6441	2346	2318	2318
query3	6650	210	210	210
query4	21680	17345	17265	17265
query5	4170	464	449	449
query6	250	159	164	159
query7	4584	296	288	288
query8	312	301	292	292
query9	8533	2338	2325	2325
query10	615	296	277	277
query11	10540	9922	10069	9922
query12	135	83	89	83
query13	1627	365	362	362
query14	10129	6827	6999	6827
query15	244	186	185	185
query16	7673	273	263	263
query17	1499	536	550	536
query18	1620	283	278	278
query19	202	163	185	163
query20	95	83	79	79
query21	210	127	127	127
query22	4263	4338	4002	4002
query23	33615	33064	33001	33001
query24	12110	2809	2765	2765
query25	659	351	355	351
query26	1818	148	149	148
query27	2877	306	318	306
query28	7297	2007	2035	2007
query29	1090	631	594	594
query30	265	145	152	145
query31	959	717	737	717
query32	90	55	55	55
query33	764	287	272	272
query34	967	471	462	462
query35	737	608	621	608
query36	1101	932	936	932
query37	288	71	67	67
query38	2894	2762	2751	2751
query39	848	780	803	780
query40	278	122	122	122
query41	54	53	50	50
query42	116	99	101	99
query43	587	574	538	538
query44	1198	732	763	732
query45	193	178	165	165
query46	1086	707	731	707
query47	1834	1788	1796	1788
query48	361	292	291	291
query49	1183	403	394	394
query50	771	384	383	383
query51	6727	6824	6643	6643
query52	105	94	94	94
query53	367	297	285	285
query54	943	436	437	436
query55	74	72	72	72
query56	276	254	259	254
query57	1155	1059	1077	1059
query58	246	235	263	235
query59	3446	3105	3235	3105
query60	288	262	287	262
query61	142	89	90	89
query62	648	450	448	448
query63	315	290	280	280
query64	9845	2224	1728	1728
query65	3189	3125	3094	3094
query66	1309	332	387	332
query67	15565	14949	15019	14949
query68	5022	541	536	536
query69	560	431	393	393
query70	1132	1135	1147	1135
query71	448	268	264	264
query72	7236	5778	5612	5612
query73	778	325	325	325
query74	5896	5537	5505	5505
query75	3619	2652	2684	2652
query76	3495	952	951	951
query77	638	292	287	287
query78	10393	10034	9605	9605
query79	2714	516	513	513
query80	1235	462	449	449
query81	571	221	223	221
query82	709	100	99	99
query83	198	165	166	165
query84	270	91	83	83
query85	1482	301	377	301
query86	468	326	302	302
query87	3290	3112	3117	3112
query88	4270	2427	2430	2427
query89	470	388	386	386
query90	1848	188	185	185
query91	126	96	100	96
query92	66	48	48	48
query93	3393	513	503	503
query94	1195	186	181	181
query95	394	311	313	311
query96	592	287	269	269
query97	3226	3034	3003	3003
query98	221	199	196	196
query99	1303	837	834	834
Total cold run time: 280346 ms
Total hot run time: 172321 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.08	0.04	0.04
query3	0.23	0.05	0.05
query4	1.67	0.09	0.10
query5	0.50	0.49	0.50
query6	1.13	0.72	0.72
query7	0.02	0.02	0.01
query8	0.05	0.04	0.04
query9	0.53	0.48	0.49
query10	0.54	0.55	0.55
query11	0.15	0.10	0.11
query12	0.14	0.12	0.12
query13	0.58	0.58	0.59
query14	0.77	0.79	0.76
query15	0.82	0.81	0.82
query16	0.37	0.37	0.38
query17	1.03	1.03	1.01
query18	0.22	0.24	0.25
query19	1.90	1.81	1.73
query20	0.02	0.01	0.01
query21	15.41	0.66	0.64
query22	4.18	6.95	1.94
query23	18.32	1.34	1.20
query24	2.10	0.26	0.21
query25	0.14	0.08	0.08
query26	0.27	0.16	0.17
query27	0.08	0.08	0.08
query28	13.20	1.02	0.99
query29	12.63	3.32	3.27
query30	0.26	0.06	0.06
query31	2.84	0.38	0.38
query32	3.31	0.47	0.46
query33	2.86	2.89	2.92
query34	17.18	4.43	4.43
query35	4.44	4.46	4.47
query36	0.65	0.46	0.46
query37	0.19	0.15	0.15
query38	0.15	0.14	0.14
query39	0.05	0.04	0.03
query40	0.20	0.14	0.15
query41	0.09	0.05	0.04
query42	0.06	0.04	0.05
query43	0.04	0.04	0.04
Total cold run time: 109.44 s
Total hot run time: 30.52 s

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17951	4985	4249	4249
q2	2034	191	197	191
q3	10634	1113	1177	1113
q4	10431	843	797	797
q5	7524	2692	2592	2592
q6	227	141	140	140
q7	969	631	613	613
q8	9689	2091	2098	2091
q9	8898	6584	6563	6563
q10	9342	3697	3682	3682
q11	440	237	242	237
q12	450	233	228	228
q13	17990	2993	2953	2953
q14	273	222	221	221
q15	530	480	473	473
q16	526	387	375	375
q17	954	692	711	692
q18	8113	7471	7345	7345
q19	1977	1546	1433	1433
q20	645	322	329	322
q21	4987	3890	3329	3329
q22	398	338	335	335
Total cold run time: 114982 ms
Total hot run time: 39974 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4401	4271	4264	4264
q2	373	259	267	259
q3	2933	2716	2712	2712
q4	1880	1595	1629	1595
q5	5260	5233	5237	5233
q6	215	126	127	126
q7	2104	1718	1723	1718
q8	3183	3318	3274	3274
q9	8276	8353	8316	8316
q10	3904	3655	3675	3655
q11	578	483	493	483
q12	765	585	601	585
q13	17594	2984	2990	2984
q14	277	263	264	263
q15	522	468	464	464
q16	478	415	427	415
q17	1760	1497	1485	1485
q18	7691	7567	7308	7308
q19	1716	1657	1358	1358
q20	1958	1758	1776	1758
q21	4907	4614	4580	4580
q22	593	547	534	534
Total cold run time: 71368 ms
Total hot run time: 53369 ms

@doris-robot
Copy link

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

query1	938	372	384	372
query2	6456	2332	2347	2332
query3	6656	212	210	210
query4	19126	17338	17454	17338
query5	4136	485	457	457
query6	249	161	162	161
query7	4592	305	293	293
query8	332	306	299	299
query9	8455	2460	2445	2445
query10	598	291	284	284
query11	10536	10010	10071	10010
query12	136	86	89	86
query13	1630	380	358	358
query14	10042	7640	7723	7640
query15	245	195	189	189
query16	7943	284	283	283
query17	1852	587	542	542
query18	2006	277	275	275
query19	199	161	155	155
query20	93	87	81	81
query21	212	124	128	124
query22	4407	4143	4354	4143
query23	33638	33098	33154	33098
query24	11925	2848	2827	2827
query25	636	354	349	349
query26	1724	156	157	156
query27	3025	313	322	313
query28	7143	2086	2064	2064
query29	1033	623	611	611
query30	282	149	154	149
query31	938	713	756	713
query32	87	52	54	52
query33	766	284	299	284
query34	952	477	468	468
query35	740	610	621	610
query36	1115	1036	954	954
query37	158	68	72	68
query38	2870	2764	2746	2746
query39	841	797	800	797
query40	271	124	123	123
query41	56	53	53	53
query42	120	96	100	96
query43	581	537	572	537
query44	1189	729	727	727
query45	196	166	165	165
query46	1093	716	700	700
query47	1834	1807	1781	1781
query48	363	308	306	306
query49	1142	416	414	414
query50	767	391	394	391
query51	6799	6777	6641	6641
query52	100	97	91	91
query53	362	289	288	288
query54	847	449	449	449
query55	76	75	72	72
query56	314	245	258	245
query57	1140	1065	1042	1042
query58	248	231	259	231
query59	3495	3040	3151	3040
query60	292	276	271	271
query61	91	92	93	92
query62	649	447	442	442
query63	327	294	288	288
query64	9825	2277	1725	1725
query65	3173	3095	3132	3095
query66	1094	352	340	340
query67	15594	15049	14985	14985
query68	4602	546	540	540
query69	476	301	314	301
query70	1116	1123	1125	1123
query71	404	269	262	262
query72	7116	5779	5796	5779
query73	745	335	337	335
query74	5948	5579	5548	5548
query75	3535	2643	2689	2643
query76	2847	907	857	857
query77	438	301	293	293
query78	10313	9874	9705	9705
query79	2450	508	512	508
query80	1182	461	519	461
query81	575	215	219	215
query82	759	112	103	103
query83	228	168	163	163
query84	241	86	83	83
query85	1599	285	272	272
query86	470	323	316	316
query87	3245	3072	3072	3072
query88	4354	2451	2447	2447
query89	477	379	391	379
query90	1765	194	190	190
query91	129	100	99	99
query92	69	51	47	47
query93	1773	514	504	504
query94	1171	195	192	192
query95	406	312	315	312
query96	585	274	273	273
query97	3224	3002	3048	3002
query98	208	206	187	187
query99	1176	853	854	853
Total cold run time: 274376 ms
Total hot run time: 174030 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.08	0.04	0.04
query3	0.23	0.05	0.05
query4	1.68	0.07	0.08
query5	0.50	0.49	0.48
query6	1.13	0.73	0.72
query7	0.02	0.02	0.02
query8	0.06	0.04	0.04
query9	0.54	0.50	0.48
query10	0.55	0.55	0.55
query11	0.16	0.11	0.11
query12	0.15	0.12	0.11
query13	0.60	0.59	0.59
query14	0.78	0.77	0.80
query15	0.85	0.81	0.82
query16	0.38	0.38	0.34
query17	1.06	1.07	1.01
query18	0.23	0.25	0.26
query19	1.81	1.75	1.82
query20	0.01	0.01	0.01
query21	15.43	0.65	0.64
query22	3.95	8.12	1.49
query23	18.31	1.39	1.27
query24	2.13	0.22	0.21
query25	0.15	0.08	0.07
query26	0.26	0.18	0.18
query27	0.08	0.08	0.08
query28	13.24	1.02	0.99
query29	12.59	3.29	3.29
query30	0.26	0.06	0.06
query31	2.86	0.41	0.38
query32	3.25	0.47	0.47
query33	2.87	2.90	2.93
query34	17.13	4.38	4.41
query35	4.50	4.49	4.46
query36	0.66	0.46	0.47
query37	0.18	0.15	0.15
query38	0.15	0.15	0.14
query39	0.04	0.03	0.03
query40	0.17	0.16	0.15
query41	0.10	0.05	0.05
query42	0.06	0.04	0.05
query43	0.05	0.04	0.04
Total cold run time: 109.28 s
Total hot run time: 30.16 s

@feiniaofeiafei
Copy link
Contributor Author

run feut

2 similar comments
@feiniaofeiafei
Copy link
Contributor Author

run feut

@feiniaofeiafei
Copy link
Contributor Author

run feut

@feiniaofeiafei feiniaofeiafei marked this pull request as ready for review June 18, 2024 02:37
@feiniaofeiafei
Copy link
Contributor Author

run feut

@feiniaofeiafei
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	18139	4465	4396	4396
q2	2609	198	198	198
q3	11731	1098	1175	1098
q4	10961	782	782	782
q5	8313	2759	2688	2688
q6	223	137	136	136
q7	957	612	592	592
q8	9228	2119	2069	2069
q9	8985	6538	6515	6515
q10	8898	3730	3696	3696
q11	450	241	240	240
q12	416	235	219	219
q13	17775	2970	3001	2970
q14	259	216	216	216
q15	511	467	478	467
q16	523	390	379	379
q17	955	645	727	645
q18	8096	7414	7424	7414
q19	5253	1587	1408	1408
q20	657	316	338	316
q21	4917	3149	3850	3149
q22	392	350	343	343
Total cold run time: 120248 ms
Total hot run time: 39936 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4397	4240	4377	4240
q2	380	270	275	270
q3	2986	2742	2708	2708
q4	1889	1566	1563	1563
q5	5242	5274	5269	5269
q6	215	128	127	127
q7	2130	1760	1676	1676
q8	3182	3356	3320	3320
q9	8310	8324	8304	8304
q10	3858	3657	3694	3657
q11	576	477	513	477
q12	791	603	620	603
q13	16628	2963	2960	2960
q14	284	273	277	273
q15	524	477	477	477
q16	469	425	410	410
q17	1758	1484	1483	1483
q18	7808	7601	7338	7338
q19	1747	1656	1556	1556
q20	1993	1818	1784	1784
q21	4932	4673	4829	4673
q22	630	547	553	547
Total cold run time: 70729 ms
Total hot run time: 53715 ms

@doris-robot
Copy link

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

query1	922	387	362	362
query2	6457	2405	2485	2405
query3	6651	206	210	206
query4	19057	17330	17403	17330
query5	4185	477	488	477
query6	253	159	173	159
query7	4585	311	287	287
query8	320	298	291	291
query9	8535	2434	2401	2401
query10	617	307	289	289
query11	10487	10028	10081	10028
query12	139	89	85	85
query13	1641	379	356	356
query14	9404	6944	6058	6058
query15	228	188	185	185
query16	7363	274	264	264
query17	1414	544	533	533
query18	1885	270	269	269
query19	190	151	155	151
query20	89	82	83	82
query21	219	136	132	132
query22	4261	4058	4043	4043
query23	33761	33040	33170	33040
query24	12446	2818	2861	2818
query25	664	348	351	348
query26	1789	153	152	152
query27	3055	330	313	313
query28	7739	2049	2052	2049
query29	1201	615	620	615
query30	271	153	153	153
query31	979	733	752	733
query32	97	53	56	53
query33	770	277	294	277
query34	1017	481	465	465
query35	729	613	625	613
query36	1079	916	944	916
query37	300	69	71	69
query38	2863	2723	2766	2723
query39	847	786	798	786
query40	287	125	124	124
query41	55	57	51	51
query42	127	95	103	95
query43	572	531	548	531
query44	1145	721	728	721
query45	196	178	167	167
query46	1098	685	696	685
query47	1872	1796	1781	1781
query48	377	337	295	295
query49	1208	402	407	402
query50	764	397	388	388
query51	6778	6707	6685	6685
query52	104	92	93	92
query53	350	282	289	282
query54	1023	442	434	434
query55	76	74	73	73
query56	277	255	264	255
query57	1155	1046	1052	1046
query58	252	251	235	235
query59	3396	3403	3218	3218
query60	286	274	266	266
query61	126	88	97	88
query62	638	445	440	440
query63	319	293	292	292
query64	9986	2267	1762	1762
query65	3202	3115	3105	3105
query66	1423	338	348	338
query67	15403	14832	14936	14832
query68	4577	536	540	536
query69	451	314	316	314
query70	1189	1136	1136	1136
query71	411	279	278	278
query72	7303	5786	5561	5561
query73	754	325	322	322
query74	5887	5540	5519	5519
query75	3435	2646	2715	2646
query76	2688	1029	925	925
query77	481	292	286	286
query78	10508	9754	9807	9754
query79	2717	506	513	506
query80	2246	476	463	463
query81	574	217	227	217
query82	770	103	104	103
query83	268	173	172	172
query84	278	89	82	82
query85	2112	284	265	265
query86	495	338	326	326
query87	3278	3073	3041	3041
query88	3673	2341	2340	2340
query89	482	392	399	392
query90	1816	200	200	200
query91	128	102	97	97
query92	65	49	47	47
query93	2857	517	498	498
query94	1263	246	187	187
query95	404	312	316	312
query96	602	270	265	265
query97	3241	3077	3043	3043
query98	215	194	199	194
query99	1325	837	848	837
Total cold run time: 277497 ms
Total hot run time: 172063 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.08	0.04	0.04
query3	0.22	0.05	0.05
query4	1.67	0.07	0.07
query5	0.48	0.48	0.49
query6	1.11	0.72	0.72
query7	0.02	0.01	0.02
query8	0.05	0.04	0.05
query9	0.53	0.49	0.49
query10	0.53	0.56	0.56
query11	0.15	0.11	0.11
query12	0.15	0.13	0.12
query13	0.60	0.59	0.61
query14	0.78	0.79	0.77
query15	0.84	0.80	0.82
query16	0.37	0.34	0.37
query17	0.97	1.05	1.02
query18	0.21	0.25	0.26
query19	1.83	1.72	1.69
query20	0.02	0.01	0.01
query21	15.41	0.64	0.64
query22	3.99	6.89	2.41
query23	18.26	1.44	1.30
query24	2.16	0.23	0.22
query25	0.16	0.08	0.09
query26	0.28	0.18	0.18
query27	0.09	0.08	0.08
query28	13.14	1.02	1.01
query29	12.63	3.30	3.27
query30	0.25	0.06	0.05
query31	2.87	0.38	0.38
query32	3.29	0.48	0.47
query33	2.93	2.92	2.93
query34	17.19	4.44	4.40
query35	4.49	4.46	4.51
query36	0.65	0.48	0.46
query37	0.19	0.16	0.15
query38	0.15	0.14	0.14
query39	0.05	0.04	0.03
query40	0.17	0.14	0.13
query41	0.09	0.04	0.04
query42	0.05	0.05	0.05
query43	0.04	0.04	0.04
Total cold run time: 109.18 s
Total hot run time: 31.1 s

@feiniaofeiafei
Copy link
Contributor Author

run feut

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jun 20, 2024
Copy link
Contributor

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

Copy link
Contributor

PR approved by anyone and no changes requested.

@morrySnow morrySnow merged commit c60da1a into apache:master Jun 20, 2024
26 of 29 checks passed
feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Jun 20, 2024
… rewrite logic (apache#36161)

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only
output `count(DISTINCT cast(NULL as SIGNED))`apache#3, do not output cast(NULL
as SIGNED)apache#2, but the upper project use cast(NULL as SIGNED)apache#2, so Doris
report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] )
+--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)apache#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))apache#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`apache#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)apache#2) AS `count(DISTINCT cast(NULL as SIGNED))`apache#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`apache#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)apache#2 should not outputted by
LogicalAggregate, cast(NULL as SIGNED) should be computed in
LogicalProject.
This pr change the upper project projections rewrite logic:
aggregateOutputs is rewritten and become the upper-level LogicalProject
projections. During the rewriting process, the expressions inside the
agg function can be rewritten with expressions in aggregate function
arguments and group by expressions, but the ones outside the agg
function can only be rewritten with group by expressions.
feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Jun 20, 2024
… rewrite logic (apache#36161)

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only
output `count(DISTINCT cast(NULL as SIGNED))`apache#3, do not output cast(NULL
as SIGNED)apache#2, but the upper project use cast(NULL as SIGNED)apache#2, so Doris
report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] )
+--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)apache#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))apache#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`apache#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)apache#2) AS `count(DISTINCT cast(NULL as SIGNED))`apache#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`apache#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)apache#2 should not outputted by
LogicalAggregate, cast(NULL as SIGNED) should be computed in
LogicalProject.
This pr change the upper project projections rewrite logic:
aggregateOutputs is rewritten and become the upper-level LogicalProject
projections. During the rewriting process, the expressions inside the
agg function can be rewritten with expressions in aggregate function
arguments and group by expressions, but the ones outside the agg
function can only be rewritten with group by expressions.
feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Jun 20, 2024
feiniaofeiafei added a commit to feiniaofeiafei/doris that referenced this pull request Jun 21, 2024
iszhangpch pushed a commit to iszhangpch/doris-p that referenced this pull request Jun 21, 2024
… rewrite logic (apache#36161)

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only
output `count(DISTINCT cast(NULL as SIGNED))`apache#3, do not output cast(NULL
as SIGNED)apache#2, but the upper project use cast(NULL as SIGNED)apache#2, so Doris
report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] )
+--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)apache#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))apache#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`apache#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)apache#2) AS `count(DISTINCT cast(NULL as SIGNED))`apache#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`apache#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)apache#2 should not outputted by
LogicalAggregate, cast(NULL as SIGNED) should be computed in
LogicalProject.
This pr change the upper project projections rewrite logic:
aggregateOutputs is rewritten and become the upper-level LogicalProject
projections. During the rewriting process, the expressions inside the
agg function can be rewritten with expressions in aggregate function
arguments and group by expressions, but the ones outside the agg
function can only be rewritten with group by expressions.
dataroaring pushed a commit that referenced this pull request Jun 21, 2024
… rewrite logic (#36161)

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only
output `count(DISTINCT cast(NULL as SIGNED))`#3, do not output cast(NULL
as SIGNED)#2, but the upper project use cast(NULL as SIGNED)#2, so Doris
report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] )
+--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)#2) AS `count(DISTINCT cast(NULL as SIGNED))`#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)#2 should not outputted by
LogicalAggregate, cast(NULL as SIGNED) should be computed in
LogicalProject.
This pr change the upper project projections rewrite logic:
aggregateOutputs is rewritten and become the upper-level LogicalProject
projections. During the rewriting process, the expressions inside the
agg function can be rewritten with expressions in aggregate function
arguments and group by expressions, but the ones outside the agg
function can only be rewritten with group by expressions.
morrySnow pushed a commit that referenced this pull request Jun 27, 2024
… rewrite logic (#36161) (#36622)

cherry-pick #36161 to branch-2.1

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only
output `count(DISTINCT cast(NULL as SIGNED))`#3, do not output cast(NULL
as SIGNED)#2, but the upper project use cast(NULL as SIGNED)#2, so Doris
report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] ) +--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)#2) AS `count(DISTINCT cast(NULL as SIGNED))`#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)#2 should not outputted by
LogicalAggregate, cast(NULL as SIGNED) should be computed in
LogicalProject.
This pr change the upper project projections rewrite logic:
aggregateOutputs is rewritten and become the upper-level LogicalProject
projections. During the rewriting process, the expressions inside the
agg function can be rewritten with expressions in aggregate function
arguments and group by expressions, but the ones outside the agg
function can only be rewritten with group by expressions.

---------

Co-authored-by: moailing <[email protected]>
morrySnow pushed a commit that referenced this pull request Jun 27, 2024
… rewrite logic (#36623)

cherry-pick #36161 to branch-2.0

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only
output `count(DISTINCT cast(NULL as SIGNED))`#3, do not output cast(NULL
as SIGNED)#2, but the upper project use cast(NULL as SIGNED)#2, so Doris
report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] ) +--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)#2) AS `count(DISTINCT cast(NULL as SIGNED))`#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)#2 should not outputted by
LogicalAggregate, cast(NULL as SIGNED) should be computed in
LogicalProject.
This pr change the upper project projections rewrite logic:
aggregateOutputs is rewritten and become the upper-level LogicalProject
projections. During the rewriting process, the expressions inside the
agg function can be rewritten with expressions in aggregate function
arguments and group by expressions, but the ones outside the agg
function can only be rewritten with group by expressions.

---------

Co-authored-by: moailing <[email protected]>
mongo360 pushed a commit to mongo360/doris that referenced this pull request Aug 16, 2024
… rewrite logic (apache#36623)

cherry-pick apache#36161 to branch-2.0

NormalizeAggregate rewrite logic has a bug, for sql like this:

SELECT
	CASE
		1 WHEN CAST( NULL AS SIGNED ) THEN NULL
		WHEN COUNT( DISTINCT CAST( NULL AS SIGNED ) ) THEN NULL
		ELSE null
	END ;

This is the plan after NormalizeAggregate, the LogicalAggregate only
output `count(DISTINCT cast(NULL as SIGNED))`apache#3, do not output cast(NULL
as SIGNED)apache#2, but the upper project use cast(NULL as SIGNED)apache#2, so Doris
report error "cast(NULL as SIGNED) not in aggregate's output".

LogicalResultSink[29] ( outputExprs=[__case_when_0#1] ) +--LogicalProject[26] ( distinct=false, projects=[CASE WHEN (1 = cast(NULL as SIGNED)apache#2) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))apache#3) THEN NULL ELSE NULL END AS `CASE WHEN (1 = cast(NULL as SIGNED)) THEN NULL WHEN (1 = count(DISTINCT cast(NULL as SIGNED))) THEN NULL ELSE NULL END`apache#1], excepts=[] )
   +--LogicalAggregate[25] ( groupByExpr=[], outputExpr=[count(DISTINCT cast(NULL as SIGNED)apache#2) AS `count(DISTINCT cast(NULL as SIGNED))`apache#3], hasRepeat=false )
      +--LogicalProject[24] ( distinct=false, projects=[cast(NULL as SIGNED) AS `cast(NULL as SIGNED)`apache#2], excepts=[] )
         +--LogicalOneRowRelation ( projects=[0 AS `0`#0] )

The problem is that the cast(NULL as SIGNED)apache#2 should not outputted by
LogicalAggregate, cast(NULL as SIGNED) should be computed in
LogicalProject.
This pr change the upper project projections rewrite logic:
aggregateOutputs is rewritten and become the upper-level LogicalProject
projections. During the rewriting process, the expressions inside the
agg function can be rewritten with expressions in aggregate function
arguments and group by expressions, but the ones outside the agg
function can only be rewritten with group by expressions.

---------

Co-authored-by: moailing <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants