Skip to content

Conversation

@924060929
Copy link
Contributor

@924060929 924060929 commented Aug 18, 2025

What problem does this PR solve?

close #54577

optimize normalize window, only push down the expression's used slots to bottom projects, which the expression not contains WindowFunction, so we can push down more filter through window.

for this sql:

  select
    SUBSTR(orderdate,1,10) AS dt,
    ROW_NUMBER() OVER(PARTITION BY orderdate ORDER BY orderid DESC) AS rn
  from lineorders
  having dt = '2025-01-01'

we not push down the dt slot under LogicalWindow, but push down [orderdate, orderid]
to the bottom projects, because if we push down dt, the plan tree will be:

            LogicalFilter(substr(dt#3, 1, 10) = '2025-01-01')
                                    |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                                    |
  LogicalProject(orderid#1, orderdate#2, substr(orderdate#1, 1, 10) as dt#3)

and can not push down filter by PushDownFilterThroughWindow, causing inefficiency,
because dt#3 in LogicalFilter not contains in the partition key in LogicalWindow: [orderdate#2].

so we only push down orderdate in the LogicalFilter, not push down dt:

     LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')
                              |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)

and then, PushDownFilterThroughWindow found the LogicalFilter's orderdate#2 contains
in the LogicalWindow's partition key: [orderdate#2], and can push down filter to:

  LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)
                             |
    LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')

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?

@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17649	5291	5216	5216
q2	1905	276	188	188
q3	10316	1275	709	709
q4	10212	1002	516	516
q5	7489	2364	2289	2289
q6	178	158	128	128
q7	885	747	607	607
q8	9295	1270	1057	1057
q9	6780	5025	5123	5025
q10	6930	2353	1963	1963
q11	491	294	276	276
q12	350	342	215	215
q13	17790	3634	3054	3054
q14	220	240	214	214
q15	556	482	489	482
q16	413	416	376	376
q17	590	852	353	353
q18	7498	7060	6966	6966
q19	1156	925	552	552
q20	345	336	219	219
q21	3713	2544	2342	2342
q22	1072	1024	984	984
Total cold run time: 105833 ms
Total hot run time: 33731 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5153	5106	5087	5087
q2	245	323	219	219
q3	2138	2694	2263	2263
q4	1373	1791	1361	1361
q5	4192	4297	4504	4297
q6	211	172	133	133
q7	2038	1939	1821	1821
q8	2679	2632	2557	2557
q9	7296	7327	7271	7271
q10	3047	3266	2829	2829
q11	703	553	515	515
q12	683	773	623	623
q13	3458	4040	3381	3381
q14	282	292	308	292
q15	528	470	479	470
q16	451	493	468	468
q17	1165	1528	1403	1403
q18	8050	7525	7385	7385
q19	825	834	972	834
q20	2056	2088	1826	1826
q21	4881	4292	4366	4292
q22	1050	1053	992	992
Total cold run time: 52504 ms
Total hot run time: 50319 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 184467 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 445beae6e3284ca91a4b9855332043975c850da7, data reload: false

query1	992	381	406	381
query2	6535	1768	1739	1739
query3	6740	227	218	218
query4	26306	23605	23028	23028
query5	4293	616	481	481
query6	296	209	195	195
query7	4621	509	301	301
query8	277	239	219	219
query9	8573	2874	2820	2820
query10	477	332	277	277
query11	15754	14926	14798	14798
query12	162	114	128	114
query13	1649	555	411	411
query14	8746	5667	5689	5667
query15	205	186	171	171
query16	7303	669	480	480
query17	1209	728	622	622
query18	2010	427	329	329
query19	190	189	163	163
query20	127	132	119	119
query21	219	127	109	109
query22	3989	4222	4044	4044
query23	34177	33369	33865	33369
query24	8133	2365	2374	2365
query25	533	467	401	401
query26	1232	261	155	155
query27	2755	499	332	332
query28	4334	2215	2189	2189
query29	818	556	435	435
query30	283	214	194	194
query31	872	786	746	746
query32	82	73	71	71
query33	558	389	347	347
query34	797	836	497	497
query35	787	811	739	739
query36	960	1017	925	925
query37	122	102	88	88
query38	4078	3995	3952	3952
query39	1518	1428	1402	1402
query40	217	124	111	111
query41	59	61	56	56
query42	118	107	116	107
query43	529	500	473	473
query44	1324	848	855	848
query45	177	167	167	167
query46	846	1002	638	638
query47	1769	1807	1732	1732
query48	378	407	308	308
query49	736	481	379	379
query50	621	681	391	391
query51	4088	4180	4059	4059
query52	118	113	103	103
query53	236	259	193	193
query54	585	589	515	515
query55	89	84	91	84
query56	309	300	300	300
query57	1192	1198	1144	1144
query58	279	267	268	267
query59	2716	2741	2694	2694
query60	336	332	315	315
query61	127	121	127	121
query62	813	726	675	675
query63	220	186	191	186
query64	4389	997	684	684
query65	4288	4184	4208	4184
query66	1169	417	333	333
query67	15351	15190	15009	15009
query68	8834	906	572	572
query69	469	322	277	277
query70	1258	1072	1159	1072
query71	469	335	328	328
query72	5664	4700	4601	4601
query73	707	552	345	345
query74	8830	9084	8766	8766
query75	3993	3048	2560	2560
query76	3641	1134	725	725
query77	783	406	320	320
query78	9508	9545	8883	8883
query79	6514	802	572	572
query80	653	601	470	470
query81	482	251	222	222
query82	746	137	105	105
query83	282	258	242	242
query84	300	112	97	97
query85	785	368	334	334
query86	355	364	295	295
query87	4189	4253	4205	4205
query88	3394	2240	2231	2231
query89	458	318	296	296
query90	1941	236	229	229
query91	140	153	125	125
query92	83	69	69	69
query93	3153	961	630	630
query94	682	411	300	300
query95	402	310	317	310
query96	477	586	275	275
query97	2597	2674	2551	2551
query98	258	213	211	211
query99	1429	1405	1280	1280
Total cold run time: 279267 ms
Total hot run time: 184467 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.03
query2	0.08	0.04	0.04
query3	0.24	0.07	0.07
query4	1.63	0.11	0.11
query5	0.42	0.43	0.41
query6	1.18	0.64	0.67
query7	0.02	0.02	0.02
query8	0.05	0.04	0.04
query9	0.60	0.50	0.51
query10	0.56	0.58	0.57
query11	0.16	0.11	0.11
query12	0.15	0.11	0.12
query13	0.63	0.61	0.61
query14	0.81	0.82	0.83
query15	0.85	0.85	0.86
query16	0.38	0.39	0.38
query17	1.07	1.05	1.07
query18	0.21	0.20	0.19
query19	1.88	1.84	1.87
query20	0.01	0.01	0.01
query21	15.42	0.99	0.58
query22	0.78	1.02	0.83
query23	14.84	1.39	0.62
query24	6.85	1.03	0.60
query25	0.50	0.18	0.10
query26	0.71	0.18	0.12
query27	0.06	0.05	0.05
query28	9.01	0.94	0.43
query29	12.62	3.84	3.25
query30	3.07	3.03	3.01
query31	2.83	0.57	0.39
query32	3.25	0.56	0.48
query33	3.04	3.15	3.09
query34	16.09	5.50	4.83
query35	4.86	4.88	4.91
query36	0.70	0.51	0.49
query37	0.10	0.07	0.07
query38	0.06	0.05	0.04
query39	0.03	0.03	0.02
query40	0.18	0.14	0.14
query41	0.08	0.03	0.02
query42	0.03	0.02	0.03
query43	0.04	0.03	0.03
Total cold run time: 106.12 s
Total hot run time: 32.49 s

@924060929 924060929 force-pushed the opt-notmalize-window branch from 445beae to 575f7e7 Compare August 18, 2025 12:52
@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17594	5213	5074	5074
q2	1918	292	189	189
q3	10287	1283	716	716
q4	10223	1002	498	498
q5	7527	2371	2332	2332
q6	182	161	129	129
q7	908	769	600	600
q8	9303	1276	1094	1094
q9	6894	5191	5122	5122
q10	6931	2373	1936	1936
q11	452	292	275	275
q12	342	354	225	225
q13	17814	3619	2957	2957
q14	240	248	209	209
q15	561	499	478	478
q16	418	418	380	380
q17	591	848	354	354
q18	7545	7080	6983	6983
q19	1296	947	566	566
q20	334	322	213	213
q21	3613	2532	2296	2296
q22	1058	1034	997	997
Total cold run time: 106031 ms
Total hot run time: 33623 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5194	5141	5155	5141
q2	257	327	217	217
q3	2175	2679	2310	2310
q4	1339	1810	1361	1361
q5	4200	4309	4513	4309
q6	208	181	130	130
q7	2033	1971	1804	1804
q8	2689	2690	2568	2568
q9	7280	7344	7368	7344
q10	3154	3281	2844	2844
q11	589	515	516	515
q12	658	785	608	608
q13	3412	3960	3234	3234
q14	307	324	275	275
q15	514	473	469	469
q16	436	489	440	440
q17	1200	1592	1367	1367
q18	7721	7842	7612	7612
q19	793	898	1054	898
q20	2009	2316	1885	1885
q21	4846	4419	4231	4231
q22	1115	1048	1016	1016
Total cold run time: 52129 ms
Total hot run time: 50578 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 184724 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 575f7e7fd7dcc7f37aba7b65996380606e2f1847, data reload: false

query1	981	392	410	392
query2	6530	1710	1709	1709
query3	6737	227	219	219
query4	26206	23502	22782	22782
query5	4405	641	508	508
query6	306	213	211	211
query7	4631	505	291	291
query8	285	229	222	222
query9	8570	2888	2831	2831
query10	500	330	291	291
query11	15790	14917	15157	14917
query12	167	114	112	112
query13	1658	538	438	438
query14	9444	5679	5614	5614
query15	219	193	164	164
query16	7647	622	481	481
query17	1209	721	612	612
query18	2086	403	307	307
query19	195	182	157	157
query20	163	118	117	117
query21	207	119	110	110
query22	4206	4466	4215	4215
query23	34230	33272	33698	33272
query24	8158	2367	2347	2347
query25	526	492	408	408
query26	1226	264	156	156
query27	2735	520	342	342
query28	4397	2210	2176	2176
query29	725	569	463	463
query30	282	214	187	187
query31	888	815	736	736
query32	82	72	72	72
query33	557	413	331	331
query34	786	830	492	492
query35	795	830	740	740
query36	956	1010	923	923
query37	116	103	83	83
query38	4006	3989	3996	3989
query39	1475	1418	1393	1393
query40	214	124	114	114
query41	66	55	52	52
query42	121	113	113	113
query43	508	490	475	475
query44	1352	846	855	846
query45	199	170	166	166
query46	889	999	637	637
query47	1741	1824	1717	1717
query48	376	408	330	330
query49	744	502	373	373
query50	630	684	388	388
query51	4116	4133	4131	4131
query52	119	113	103	103
query53	234	260	205	205
query54	583	588	521	521
query55	89	84	91	84
query56	327	310	299	299
query57	1165	1200	1138	1138
query58	280	287	262	262
query59	2629	2744	2657	2657
query60	342	338	328	328
query61	127	122	128	122
query62	805	714	678	678
query63	231	194	183	183
query64	4230	1001	763	763
query65	4298	4188	4194	4188
query66	1085	419	312	312
query67	15479	15358	15101	15101
query68	8748	914	575	575
query69	474	322	293	293
query70	1264	1148	1090	1090
query71	471	318	301	301
query72	5647	4750	4803	4750
query73	749	617	340	340
query74	9285	9025	8807	8807
query75	4052	3065	2547	2547
query76	3744	1130	727	727
query77	810	412	338	338
query78	9608	9645	8886	8886
query79	1780	833	580	580
query80	588	537	466	466
query81	471	261	224	224
query82	431	137	113	113
query83	256	247	238	238
query84	253	98	93	93
query85	855	370	331	331
query86	337	303	288	288
query87	4199	4316	4188	4188
query88	2829	2227	2184	2184
query89	393	318	272	272
query90	1931	220	217	217
query91	149	143	109	109
query92	81	74	66	66
query93	1095	984	651	651
query94	692	396	317	317
query95	392	309	302	302
query96	481	588	271	271
query97	2640	2691	2576	2576
query98	239	208	215	208
query99	1447	1421	1280	1280
Total cold run time: 273452 ms
Total hot run time: 184724 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.08	0.04	0.04
query3	0.24	0.07	0.07
query4	1.61	0.11	0.12
query5	0.43	0.41	0.40
query6	1.16	0.63	0.65
query7	0.03	0.02	0.02
query8	0.05	0.04	0.03
query9	0.58	0.53	0.51
query10	0.57	0.57	0.57
query11	0.15	0.10	0.11
query12	0.15	0.11	0.12
query13	0.62	0.61	0.60
query14	0.79	0.84	0.83
query15	0.87	0.87	0.85
query16	0.39	0.40	0.38
query17	1.05	1.03	1.03
query18	0.22	0.20	0.20
query19	1.88	1.80	1.82
query20	0.02	0.01	0.01
query21	15.40	0.97	0.58
query22	0.78	1.18	0.76
query23	14.87	1.35	0.63
query24	6.59	0.71	2.09
query25	0.51	0.24	0.13
query26	0.60	0.15	0.13
query27	0.06	0.05	0.04
query28	9.91	0.89	0.43
query29	12.55	3.92	3.24
query30	3.08	3.06	2.95
query31	2.82	0.56	0.37
query32	3.24	0.58	0.46
query33	3.05	3.17	3.16
query34	16.18	5.45	4.86
query35	4.89	4.92	4.93
query36	0.68	0.52	0.49
query37	0.10	0.06	0.06
query38	0.06	0.04	0.04
query39	0.03	0.02	0.02
query40	0.18	0.16	0.15
query41	0.09	0.03	0.03
query42	0.03	0.03	0.02
query43	0.04	0.03	0.03
Total cold run time: 106.67 s
Total hot run time: 32.53 s

@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	6134	5056	5087	5056
q2	522	289	187	187
q3	870	1241	713	713
q4	722	1022	527	527
q5	2075	2225	2308	2225
q6	180	164	131	131
q7	862	764	603	603
q8	8636	1337	1154	1154
q9	7033	5151	5074	5074
q10	6978	2421	1980	1980
q11	481	283	281	281
q12	356	343	216	216
q13	17779	3645	3065	3065
q14	225	244	210	210
q15	546	488	485	485
q16	417	421	371	371
q17	610	868	358	358
q18	7553	7169	7091	7091
q19	1210	948	558	558
q20	345	349	236	236
q21	4036	3168	2376	2376
q22	1054	1030	1023	1023
Total cold run time: 68624 ms
Total hot run time: 33920 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5556	5085	5138	5085
q2	243	330	224	224
q3	2164	2702	2283	2283
q4	1366	1765	1363	1363
q5	4231	4096	4100	4096
q6	207	161	125	125
q7	2042	1808	1686	1686
q8	2491	2550	2464	2464
q9	6797	6740	6765	6740
q10	2943	3127	2729	2729
q11	574	506	478	478
q12	649	731	613	613
q13	3260	3628	3025	3025
q14	278	284	262	262
q15	501	469	458	458
q16	424	462	436	436
q17	1135	1531	1313	1313
q18	7184	7058	7028	7028
q19	835	774	815	774
q20	1900	1973	1855	1855
q21	4902	4335	4445	4335
q22	1078	1046	992	992
Total cold run time: 50760 ms
Total hot run time: 48364 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 184990 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 575f7e7fd7dcc7f37aba7b65996380606e2f1847, data reload: false

query1	991	382	401	382
query2	6533	1717	1741	1717
query3	6736	222	235	222
query4	26373	23231	23661	23231
query5	4986	642	485	485
query6	320	221	219	219
query7	4638	502	293	293
query8	306	215	212	212
query9	8580	2910	2868	2868
query10	502	319	273	273
query11	16026	15123	14880	14880
query12	168	113	110	110
query13	1639	548	405	405
query14	9948	5742	5774	5742
query15	200	188	169	169
query16	7652	639	458	458
query17	1310	726	594	594
query18	2037	416	324	324
query19	198	185	168	168
query20	125	125	118	118
query21	217	124	110	110
query22	4293	4282	3996	3996
query23	34284	33442	33214	33214
query24	8008	2354	2371	2354
query25	599	474	414	414
query26	1235	275	154	154
query27	2710	507	344	344
query28	4332	2291	2258	2258
query29	737	572	445	445
query30	290	223	186	186
query31	910	816	727	727
query32	166	72	75	72
query33	556	373	347	347
query34	798	839	511	511
query35	790	799	735	735
query36	958	1042	928	928
query37	119	107	83	83
query38	4050	4060	3973	3973
query39	1465	1446	1447	1446
query40	218	129	119	119
query41	65	56	56	56
query42	120	108	113	108
query43	506	503	459	459
query44	1350	860	859	859
query45	175	169	163	163
query46	849	1029	636	636
query47	1774	1795	1730	1730
query48	379	417	334	334
query49	727	499	404	404
query50	639	679	402	402
query51	4076	4130	4102	4102
query52	118	120	98	98
query53	236	258	198	198
query54	599	586	523	523
query55	91	86	90	86
query56	335	311	294	294
query57	1216	1179	1139	1139
query58	277	271	272	271
query59	2604	2708	2600	2600
query60	353	334	338	334
query61	129	124	121	121
query62	813	714	648	648
query63	227	192	190	190
query64	4331	1037	686	686
query65	4292	4197	4209	4197
query66	1085	417	321	321
query67	15758	15360	15084	15084
query68	8493	942	573	573
query69	480	315	288	288
query70	1235	1148	1146	1146
query71	471	330	292	292
query72	5761	4810	4733	4733
query73	764	642	358	358
query74	9178	9268	8810	8810
query75	3860	3077	2633	2633
query76	3761	1178	740	740
query77	803	403	320	320
query78	9461	9646	8795	8795
query79	5510	817	569	569
query80	675	540	466	466
query81	469	257	221	221
query82	613	134	108	108
query83	279	257	235	235
query84	290	97	84	84
query85	783	376	338	338
query86	339	307	314	307
query87	4282	4232	4278	4232
query88	3462	2201	2177	2177
query89	443	312	290	290
query90	2002	225	220	220
query91	142	137	111	111
query92	87	69	69	69
query93	3157	975	634	634
query94	691	406	304	304
query95	392	311	311	311
query96	484	579	273	273
query97	2701	2712	2553	2553
query98	239	211	211	211
query99	1456	1386	1260	1260
Total cold run time: 281890 ms
Total hot run time: 184990 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.04
query2	0.09	0.04	0.04
query3	0.25	0.07	0.07
query4	1.63	0.11	0.11
query5	0.42	0.44	0.39
query6	1.17	0.65	0.66
query7	0.02	0.02	0.02
query8	0.04	0.04	0.03
query9	0.61	0.52	0.52
query10	0.59	0.58	0.58
query11	0.16	0.11	0.11
query12	0.15	0.12	0.12
query13	0.62	0.60	0.62
query14	0.79	0.82	0.84
query15	0.85	0.87	0.84
query16	0.37	0.39	0.39
query17	1.05	1.03	1.02
query18	0.21	0.20	0.19
query19	1.92	1.81	1.80
query20	0.01	0.01	0.02
query21	15.41	0.94	0.59
query22	0.79	1.21	0.76
query23	14.77	1.41	0.62
query24	6.74	1.28	0.95
query25	0.51	0.21	0.14
query26	0.64	0.15	0.14
query27	0.05	0.06	0.05
query28	9.68	0.93	0.43
query29	12.64	3.90	3.21
query30	3.05	3.03	2.99
query31	2.82	0.56	0.37
query32	3.23	0.54	0.47
query33	2.97	3.06	3.05
query34	15.98	5.46	4.84
query35	4.92	4.96	4.91
query36	0.69	0.51	0.49
query37	0.09	0.06	0.07
query38	0.05	0.04	0.04
query39	0.03	0.03	0.02
query40	0.17	0.14	0.14
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 106.37 s
Total hot run time: 32.7 s

@924060929 924060929 force-pushed the opt-notmalize-window branch from 575f7e7 to 255aabb Compare August 19, 2025 02:16
@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17580	5249	5105	5105
q2	1920	284	184	184
q3	10304	1275	708	708
q4	10226	1004	556	556
q5	7504	2433	2336	2336
q6	185	165	131	131
q7	917	748	634	634
q8	9306	1324	1173	1173
q9	6732	5096	5125	5096
q10	6975	2404	1971	1971
q11	483	292	263	263
q12	348	349	222	222
q13	17774	3700	3041	3041
q14	243	241	211	211
q15	557	482	481	481
q16	428	425	363	363
q17	593	850	361	361
q18	7362	7113	7013	7013
q19	1093	940	583	583
q20	340	343	215	215
q21	4036	3254	2334	2334
q22	1084	1002	971	971
Total cold run time: 105990 ms
Total hot run time: 33952 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5216	5153	5133	5133
q2	247	329	222	222
q3	2138	2729	2261	2261
q4	1361	1864	1313	1313
q5	4204	4497	4433	4433
q6	227	170	132	132
q7	2052	2005	1791	1791
q8	2640	2668	2600	2600
q9	7300	7302	7196	7196
q10	3174	3274	2861	2861
q11	583	517	521	517
q12	726	778	660	660
q13	3564	3927	3335	3335
q14	280	313	277	277
q15	531	475	457	457
q16	420	496	465	465
q17	1248	1657	1376	1376
q18	7724	7828	7475	7475
q19	889	897	986	897
q20	2052	2023	1940	1940
q21	4946	4310	4264	4264
q22	1040	1022	975	975
Total cold run time: 52562 ms
Total hot run time: 50580 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 184292 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 255aabbae380dcc0c1cc434aad69195289d76779, data reload: false

query1	1004	390	419	390
query2	6518	1725	1747	1725
query3	6739	220	221	220
query4	26705	23677	22851	22851
query5	4354	622	477	477
query6	321	219	207	207
query7	4637	515	297	297
query8	278	230	223	223
query9	8594	2878	2823	2823
query10	475	348	282	282
query11	15982	14902	14746	14746
query12	160	113	114	113
query13	1664	541	424	424
query14	8984	5744	5738	5738
query15	206	191	172	172
query16	7249	646	472	472
query17	1204	717	601	601
query18	1987	404	327	327
query19	196	186	168	168
query20	138	126	118	118
query21	213	123	111	111
query22	4018	4220	4003	4003
query23	34097	33200	33355	33200
query24	8057	2386	2368	2368
query25	553	456	415	415
query26	1236	269	167	167
query27	2726	512	340	340
query28	4387	2222	2199	2199
query29	765	570	450	450
query30	286	217	193	193
query31	900	807	704	704
query32	82	76	74	74
query33	548	365	339	339
query34	805	837	518	518
query35	791	833	745	745
query36	984	1011	945	945
query37	123	105	86	86
query38	4092	4127	4010	4010
query39	1498	1428	1424	1424
query40	220	122	112	112
query41	59	58	55	55
query42	120	109	125	109
query43	503	519	472	472
query44	1376	868	848	848
query45	175	166	161	161
query46	889	999	654	654
query47	1742	1793	1716	1716
query48	386	430	321	321
query49	710	469	386	386
query50	666	739	396	396
query51	4074	4122	4097	4097
query52	123	112	102	102
query53	241	270	193	193
query54	586	583	520	520
query55	86	86	87	86
query56	329	344	291	291
query57	1187	1187	1119	1119
query58	271	267	265	265
query59	2664	2701	2556	2556
query60	352	332	317	317
query61	127	123	120	120
query62	797	740	653	653
query63	225	197	195	195
query64	4368	989	741	741
query65	4271	4232	4211	4211
query66	1164	471	331	331
query67	15444	15193	14953	14953
query68	8662	904	574	574
query69	486	338	279	279
query70	1260	1113	1168	1113
query71	444	321	316	316
query72	5580	4764	4931	4764
query73	767	689	346	346
query74	8971	9022	8847	8847
query75	3984	3039	2651	2651
query76	3614	1137	723	723
query77	807	402	323	323
query78	9609	9685	8773	8773
query79	1786	817	595	595
query80	712	549	464	464
query81	465	254	226	226
query82	429	150	109	109
query83	279	254	310	254
query84	293	119	85	85
query85	782	369	351	351
query86	352	321	294	294
query87	4313	4286	4177	4177
query88	2737	2193	2178	2178
query89	386	317	277	277
query90	1915	211	214	211
query91	149	141	115	115
query92	86	71	153	71
query93	1125	976	637	637
query94	682	398	291	291
query95	394	302	297	297
query96	480	579	278	278
query97	2643	2637	2539	2539
query98	235	228	210	210
query99	1469	1399	1279	1279
Total cold run time: 272607 ms
Total hot run time: 184292 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.04
query2	0.08	0.04	0.04
query3	0.24	0.07	0.08
query4	1.63	0.11	0.11
query5	0.44	0.42	0.42
query6	1.17	0.65	0.64
query7	0.03	0.02	0.02
query8	0.05	0.03	0.03
query9	0.59	0.53	0.51
query10	0.58	0.57	0.58
query11	0.16	0.11	0.11
query12	0.15	0.11	0.11
query13	0.62	0.61	0.61
query14	0.84	0.79	0.84
query15	0.89	0.83	0.86
query16	0.38	0.40	0.38
query17	1.03	1.06	1.04
query18	0.20	0.20	0.20
query19	1.91	1.91	1.88
query20	0.01	0.00	0.00
query21	15.39	0.95	0.59
query22	0.77	1.26	0.74
query23	14.79	1.36	0.65
query24	6.75	1.50	0.81
query25	0.51	0.13	0.15
query26	0.67	0.16	0.14
query27	0.06	0.05	0.05
query28	9.73	0.96	0.43
query29	12.54	3.95	3.24
query30	3.03	3.01	2.94
query31	2.83	0.61	0.39
query32	3.23	0.57	0.48
query33	3.12	3.09	3.08
query34	15.98	5.45	4.86
query35	4.89	4.97	4.91
query36	0.69	0.52	0.50
query37	0.10	0.07	0.07
query38	0.05	0.05	0.04
query39	0.03	0.02	0.03
query40	0.19	0.15	0.14
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 106.54 s
Total hot run time: 32.68 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

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

@924060929 924060929 added usercase Important user case type label dev/2.1.x dev/3.0.x dev/3.1.x labels Aug 19, 2025
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Aug 19, 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.

@924060929 924060929 merged commit 0e669b9 into apache:master Aug 20, 2025
31 of 33 checks passed
924060929 added a commit to 924060929/incubator-doris that referenced this pull request Aug 20, 2025
close apache#54577

optimize normalize window, only push down the expression's used slots to
bottom projects, which the expression not contains WindowFunction, so we
can push down more filter through window.

for this sql:
```sql
  select
    SUBSTR(orderdate,1,10) AS dt,
    ROW_NUMBER() OVER(PARTITION BY orderdate ORDER BY orderid DESC) AS rn
  from lineorders
  having dt = '2025-01-01'
```
we not push down the `dt` slot under LogicalWindow, but push down
[orderdate, orderid]
to the bottom projects, because if we push down `dt`, the plan tree will
be:
```
            LogicalFilter(substr(dt#3, 1, 10) = '2025-01-01')
                                    |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                                    |
  LogicalProject(orderid#1, orderdate#2, substr(orderdate#1, 1, 10) as dt#3)
```

and can not push down filter by `PushDownFilterThroughWindow`, causing
inefficiency,
because dt#3 in LogicalFilter not contains in the partition key in
LogicalWindow: [orderdate#2].

so we only push down orderdate in the LogicalFilter, not push down `dt`:

```
     LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')
                              |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)
```

and then, `PushDownFilterThroughWindow` found the LogicalFilter's
`orderdate#2` contains
in the LogicalWindow's partition key: [orderdate#2], and can push down
filter to:

```
  LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)
                             |
    LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')
```

(cherry picked from commit 0e669b9)
924060929 added a commit to 924060929/incubator-doris that referenced this pull request Aug 20, 2025
close apache#54577

optimize normalize window, only push down the expression's used slots to
bottom projects, which the expression not contains WindowFunction, so we
can push down more filter through window.

for this sql:
```sql
  select
    SUBSTR(orderdate,1,10) AS dt,
    ROW_NUMBER() OVER(PARTITION BY orderdate ORDER BY orderid DESC) AS rn
  from lineorders
  having dt = '2025-01-01'
```
we not push down the `dt` slot under LogicalWindow, but push down
[orderdate, orderid]
to the bottom projects, because if we push down `dt`, the plan tree will
be:
```
            LogicalFilter(substr(dt#3, 1, 10) = '2025-01-01')
                                    |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                                    |
  LogicalProject(orderid#1, orderdate#2, substr(orderdate#1, 1, 10) as dt#3)
```

and can not push down filter by `PushDownFilterThroughWindow`, causing
inefficiency,
because dt#3 in LogicalFilter not contains in the partition key in
LogicalWindow: [orderdate#2].

so we only push down orderdate in the LogicalFilter, not push down `dt`:

```
     LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')
                              |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)
```

and then, `PushDownFilterThroughWindow` found the LogicalFilter's
`orderdate#2` contains
in the LogicalWindow's partition key: [orderdate#2], and can push down
filter to:

```
  LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)
                             |
    LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')
```

(cherry picked from commit 0e669b9)
924060929 added a commit to 924060929/incubator-doris that referenced this pull request Aug 20, 2025
close apache#54577

optimize normalize window, only push down the expression's used slots to
bottom projects, which the expression not contains WindowFunction, so we
can push down more filter through window.

for this sql:
```sql
  select
    SUBSTR(orderdate,1,10) AS dt,
    ROW_NUMBER() OVER(PARTITION BY orderdate ORDER BY orderid DESC) AS rn
  from lineorders
  having dt = '2025-01-01'
```
we not push down the `dt` slot under LogicalWindow, but push down
[orderdate, orderid]
to the bottom projects, because if we push down `dt`, the plan tree will
be:
```
            LogicalFilter(substr(dt#3, 1, 10) = '2025-01-01')
                                    |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                                    |
  LogicalProject(orderid#1, orderdate#2, substr(orderdate#1, 1, 10) as dt#3)
```

and can not push down filter by `PushDownFilterThroughWindow`, causing
inefficiency,
because dt#3 in LogicalFilter not contains in the partition key in
LogicalWindow: [orderdate#2].

so we only push down orderdate in the LogicalFilter, not push down `dt`:

```
     LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')
                              |
     LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)
```

and then, `PushDownFilterThroughWindow` found the LogicalFilter's
`orderdate#2` contains
in the LogicalWindow's partition key: [orderdate#2], and can push down
filter to:

```
  LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1))
                              |
            LogicalProject(orderid#1, orderdate#2)
                             |
    LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01')
```

(cherry picked from commit 0e669b9)
yiguolei pushed a commit that referenced this pull request Aug 22, 2025
@924060929 924060929 deleted the opt-notmalize-window branch August 27, 2025 07:00
dataroaring pushed a commit that referenced this pull request Sep 3, 2025
morrySnow pushed a commit that referenced this pull request Sep 4, 2025
@morrySnow morrySnow mentioned this pull request Sep 22, 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/2.1.12-merged dev/3.0.9-merged dev/3.1.1-merged reviewed usercase Important user case type label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Filter not pushdown to ScanNode

7 participants