doris icon indicating copy to clipboard operation
doris copied to clipboard

[feature](Nereids) support qualify stmt

Open qzsee opened this issue 1 year ago • 19 comments

Proposed changes

like bigquery https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#qualify_clause

Examples


SELECT
  item,
  RANK() OVER (PARTITION BY category ORDER BY purchases DESC) as rank
FROM Produce
WHERE Produce.category = 'vegetable'
QUALIFY rank <= 3

/*---------+------*
 | item    | rank |
 +---------+------+
 | kale    | 1    |
 | lettuce | 2    |
 | cabbage | 3    |
 *---------+------*/

You don't have to include a window function in the SELECT list to use QUALIFY. The following query returns the most popular vegetables

SELECT item
FROM Produce
WHERE Produce.category = 'vegetable'
QUALIFY RANK() OVER (PARTITION BY category ORDER BY purchases DESC) <= 3

/*---------*
 | item    |
 +---------+
 | kale    |
 | lettuce |
 | cabbage |
 *---------*/

Issue Number: close #xxx

qzsee avatar Aug 28 '24 08:08 qzsee

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.

doris-robot avatar Aug 28 '24 08:08 doris-robot

should add cases like having, should test use window, agg, having and qualify togather

morrySnow avatar Aug 28 '24 08:08 morrySnow

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

github-actions[bot] avatar Aug 28 '24 09:08 github-actions[bot]

PR approved by anyone and no changes requested.

github-actions[bot] avatar Aug 28 '24 09:08 github-actions[bot]

run buildall

qzsee avatar Aug 28 '24 14:08 qzsee

run buildall

qzsee avatar Aug 29 '24 01:08 qzsee

run buildall

qzsee avatar Aug 29 '24 14:08 qzsee

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

------ Round 1 ----------------------------------
q1	17650	4940	4310	4310
q2	2032	174	181	174
q3	10516	1193	1052	1052
q4	10401	679	718	679
q5	8388	2877	2849	2849
q6	236	142	140	140
q7	987	620	608	608
q8	9768	2075	2094	2075
q9	7379	6569	6498	6498
q10	7013	2148	2125	2125
q11	466	243	241	241
q12	390	224	222	222
q13	17764	3057	3022	3022
q14	281	235	228	228
q15	518	493	490	490
q16	585	515	512	512
q17	965	680	737	680
q18	7398	6939	6865	6865
q19	1408	1086	1128	1086
q20	690	325	319	319
q21	4383	3034	2715	2715
q22	1099	1000	1004	1000
Total cold run time: 110317 ms
Total hot run time: 37890 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4359	4310	4282	4282
q2	373	277	276	276
q3	2919	2644	2657	2644
q4	1941	1696	1654	1654
q5	5409	5435	5428	5428
q6	225	131	129	129
q7	2086	1754	1721	1721
q8	3193	3351	3340	3340
q9	8349	8393	8429	8393
q10	3456	3187	3226	3187
q11	621	501	499	499
q12	789	596	600	596
q13	11180	3047	2997	2997
q14	308	289	281	281
q15	524	489	481	481
q16	625	570	539	539
q17	1799	1476	1466	1466
q18	7687	7533	7623	7533
q19	1674	1542	1515	1515
q20	2061	1800	1802	1800
q21	5511	5193	5095	5095
q22	1123	1044	1019	1019
Total cold run time: 66212 ms
Total hot run time: 54875 ms

doris-robot avatar Aug 29 '24 14:08 doris-robot

run buildall

qzsee avatar Aug 30 '24 01:08 qzsee

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

------ Round 1 ----------------------------------
q1	17600	4315	4228	4228
q2	2012	192	177	177
q3	11816	987	1084	987
q4	10524	807	661	661
q5	7743	2856	2804	2804
q6	224	134	135	134
q7	973	620	598	598
q8	9344	2083	2068	2068
q9	7363	6500	6523	6500
q10	7010	2162	2178	2162
q11	437	238	234	234
q12	398	220	236	220
q13	17955	3016	3065	3016
q14	288	230	236	230
q15	512	486	483	483
q16	570	509	497	497
q17	965	736	689	689
q18	7391	6821	6885	6821
q19	1391	1000	996	996
q20	703	341	332	332
q21	4015	3116	2896	2896
q22	1101	1012	1021	1012
Total cold run time: 110335 ms
Total hot run time: 37745 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4393	4296	4341	4296
q2	388	279	269	269
q3	2919	2730	2651	2651
q4	1996	1629	1670	1629
q5	5645	5780	5782	5780
q6	226	137	137	137
q7	2230	1879	1850	1850
q8	3335	3464	3459	3459
q9	8886	9173	8972	8972
q10	3664	3547	3405	3405
q11	611	535	536	535
q12	891	743	711	711
q13	13151	3310	3268	3268
q14	331	324	329	324
q15	553	510	493	493
q16	682	620	581	581
q17	1856	1577	1499	1499
q18	8322	7835	7753	7753
q19	2641	1720	1684	1684
q20	2112	1907	1945	1907
q21	5719	5595	5471	5471
q22	1137	1090	1084	1084
Total cold run time: 71688 ms
Total hot run time: 57758 ms

doris-robot avatar Aug 30 '24 02:08 doris-robot

TPC-DS: Total hot run time: 193039 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 3770885da18bd79a80f93d7855f574a884d778dc, data reload: false

query1	1245	873	852	852
query2	6318	2034	1938	1938
query3	10585	3940	3924	3924
query4	59450	25477	23394	23394
query5	5458	492	489	489
query6	408	162	165	162
query7	5884	289	293	289
query8	289	207	201	201
query9	8957	2498	2476	2476
query10	477	265	261	261
query11	18054	15174	15362	15174
query12	159	106	99	99
query13	1545	393	376	376
query14	11286	7270	7100	7100
query15	231	175	180	175
query16	7536	480	452	452
query17	1157	566	572	566
query18	2034	307	296	296
query19	299	147	138	138
query20	119	110	111	110
query21	219	103	109	103
query22	4841	4332	4611	4332
query23	34321	33287	33366	33287
query24	5889	2912	2870	2870
query25	559	377	384	377
query26	688	155	157	155
query27	1782	279	274	274
query28	3693	2116	2081	2081
query29	681	408	396	396
query30	235	157	157	157
query31	945	749	731	731
query32	90	54	56	54
query33	441	278	285	278
query34	856	484	481	481
query35	851	712	699	699
query36	1046	903	913	903
query37	147	97	86	86
query38	4063	3804	3886	3804
query39	1453	1369	1387	1369
query40	201	121	118	118
query41	48	47	46	46
query42	123	101	96	96
query43	508	478	489	478
query44	1109	751	770	751
query45	193	174	176	174
query46	1111	739	728	728
query47	1960	1837	1852	1837
query48	373	299	303	299
query49	786	436	447	436
query50	823	423	421	421
query51	7083	7047	7042	7042
query52	98	88	92	88
query53	254	182	183	182
query54	577	473	477	473
query55	78	80	80	80
query56	294	268	272	268
query57	1208	1093	1065	1065
query58	221	241	235	235
query59	3112	2951	2801	2801
query60	305	268	280	268
query61	122	120	117	117
query62	748	644	643	643
query63	223	182	194	182
query64	2943	755	746	746
query65	3194	3138	3153	3138
query66	707	351	350	350
query67	15297	15543	15415	15415
query68	3004	618	590	590
query69	408	295	284	284
query70	1193	1119	1117	1117
query71	369	281	279	279
query72	6390	4155	4246	4155
query73	745	331	334	331
query74	9150	8714	8833	8714
query75	3399	2683	2736	2683
query76	1405	915	973	915
query77	536	321	319	319
query78	9669	9041	9947	9041
query79	1443	525	527	525
query80	912	517	505	505
query81	565	232	236	232
query82	290	148	144	144
query83	225	146	148	146
query84	261	75	70	70
query85	892	313	275	275
query86	413	301	264	264
query87	4332	4336	4241	4241
query88	3059	2335	2327	2327
query89	396	291	281	281
query90	1924	195	188	188
query91	122	99	96	96
query92	64	53	55	53
query93	1400	539	539	539
query94	850	289	292	289
query95	359	261	254	254
query96	593	269	268	268
query97	3185	3054	3085	3054
query98	219	202	200	200
query99	1844	1279	1274	1274
Total cold run time: 307606 ms
Total hot run time: 193039 ms

doris-robot avatar Aug 30 '24 02:08 doris-robot

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

query1	0.05	0.04	0.04
query2	0.08	0.04	0.04
query3	0.22	0.05	0.05
query4	1.69	0.07	0.06
query5	0.52	0.50	0.49
query6	1.12	0.72	0.74
query7	0.01	0.01	0.01
query8	0.05	0.04	0.04
query9	0.55	0.46	0.49
query10	0.55	0.54	0.53
query11	0.15	0.11	0.12
query12	0.15	0.12	0.12
query13	0.60	0.58	0.59
query14	2.05	2.06	2.12
query15	0.90	0.80	0.81
query16	0.37	0.38	0.37
query17	1.06	1.06	1.01
query18	0.21	0.20	0.19
query19	1.93	1.76	1.70
query20	0.01	0.01	0.01
query21	15.39	0.68	0.67
query22	4.06	7.05	1.99
query23	18.20	1.41	1.27
query24	2.11	0.22	0.23
query25	0.15	0.09	0.08
query26	0.27	0.18	0.18
query27	0.08	0.07	0.07
query28	13.29	1.01	1.01
query29	12.60	3.34	3.33
query30	0.24	0.05	0.06
query31	2.88	0.40	0.39
query32	3.26	0.48	0.48
query33	2.98	2.96	3.04
query34	17.06	4.37	4.37
query35	4.44	4.45	4.47
query36	0.66	0.48	0.49
query37	0.19	0.16	0.16
query38	0.16	0.15	0.15
query39	0.05	0.04	0.04
query40	0.15	0.13	0.13
query41	0.10	0.05	0.05
query42	0.06	0.05	0.04
query43	0.04	0.05	0.04
Total cold run time: 110.69 s
Total hot run time: 32 s

doris-robot avatar Aug 30 '24 02:08 doris-robot

run buildall

qzsee avatar Aug 30 '24 03:08 qzsee

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

------ Round 1 ----------------------------------
q1	17626	4513	4298	4298
q2	2022	185	177	177
q3	11897	956	1173	956
q4	10526	674	826	674
q5	7767	2889	2860	2860
q6	233	144	144	144
q7	958	631	623	623
q8	9564	2081	2082	2081
q9	7805	6535	6542	6535
q10	7000	2243	2241	2241
q11	448	243	243	243
q12	391	225	230	225
q13	17756	3018	3058	3018
q14	279	251	234	234
q15	509	494	481	481
q16	593	513	510	510
q17	978	670	716	670
q18	7231	6835	6871	6835
q19	1395	1046	1028	1028
q20	673	337	335	335
q21	3860	3161	3232	3161
q22	1139	1015	1028	1015
Total cold run time: 110650 ms
Total hot run time: 38344 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4372	4303	4259	4259
q2	370	272	268	268
q3	2886	2690	2653	2653
q4	1957	1651	1698	1651
q5	5725	5713	5754	5713
q6	229	134	145	134
q7	2207	1902	1839	1839
q8	3266	3424	3478	3424
q9	8940	8866	8742	8742
q10	3633	3417	3357	3357
q11	612	502	504	502
q12	828	744	704	704
q13	13573	3248	3244	3244
q14	316	309	286	286
q15	513	482	496	482
q16	639	600	582	582
q17	1849	1547	1526	1526
q18	8023	7721	7848	7721
q19	1700	1619	1619	1619
q20	2176	1880	1903	1880
q21	5835	5441	5660	5441
q22	1139	1086	1002	1002
Total cold run time: 70788 ms
Total hot run time: 57029 ms

doris-robot avatar Aug 30 '24 04:08 doris-robot

TPC-DS: Total hot run time: 193351 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 6c1dabfedc155588fa36ac4ebe1b10f4830b1427, data reload: false

query1	1236	887	894	887
query2	6340	1986	1927	1927
query3	10698	4034	4077	4034
query4	59714	24636	23154	23154
query5	5435	519	510	510
query6	417	184	177	177
query7	5818	310	294	294
query8	286	214	213	213
query9	8813	2480	2471	2471
query10	498	272	258	258
query11	17441	14986	15312	14986
query12	155	101	104	101
query13	1561	396	374	374
query14	11068	7469	7242	7242
query15	244	179	185	179
query16	7209	455	490	455
query17	1138	568	582	568
query18	2008	329	301	301
query19	312	151	157	151
query20	117	113	127	113
query21	210	103	104	103
query22	4541	4407	4362	4362
query23	34116	33810	33719	33719
query24	5921	2885	2861	2861
query25	543	374	377	374
query26	693	161	159	159
query27	1765	272	275	272
query28	3786	2088	2054	2054
query29	658	401	412	401
query30	225	150	157	150
query31	913	777	768	768
query32	72	54	60	54
query33	403	279	283	279
query34	848	494	486	486
query35	846	717	720	717
query36	1094	950	956	950
query37	156	101	97	97
query38	4014	3920	4018	3920
query39	1440	1412	1385	1385
query40	196	120	118	118
query41	48	84	45	45
query42	112	95	95	95
query43	519	474	476	474
query44	1073	744	742	742
query45	197	169	164	164
query46	1087	763	793	763
query47	1866	1772	1790	1772
query48	360	287	308	287
query49	760	433	434	433
query50	824	414	415	414
query51	7209	7002	7062	7002
query52	100	88	89	88
query53	253	179	182	179
query54	557	450	449	449
query55	81	78	77	77
query56	281	251	256	251
query57	1216	1103	1096	1096
query58	215	226	226	226
query59	2910	2800	2835	2800
query60	288	270	283	270
query61	148	103	98	98
query62	752	647	680	647
query63	217	191	189	189
query64	2837	678	692	678
query65	3256	3121	3159	3121
query66	690	351	341	341
query67	15254	15123	15198	15123
query68	2988	576	576	576
query69	405	279	271	271
query70	1225	1079	1175	1079
query71	403	277	270	270
query72	5144	4024	4093	4024
query73	751	325	332	325
query74	9262	8893	8860	8860
query75	3358	2693	2709	2693
query76	1398	990	1100	990
query77	550	323	309	309
query78	9650	9658	9122	9122
query79	1036	544	527	527
query80	684	502	503	502
query81	463	234	235	234
query82	237	150	142	142
query83	166	148	150	148
query84	252	76	78	76
query85	669	290	284	284
query86	309	268	301	268
query87	4379	4326	4361	4326
query88	3079	2305	2300	2300
query89	380	292	289	289
query90	1917	201	200	200
query91	137	114	112	112
query92	61	54	55	54
query93	1058	538	535	535
query94	688	323	388	323
query95	324	264	267	264
query96	586	265	271	265
query97	3188	3104	3079	3079
query98	230	200	200	200
query99	1516	1315	1256	1256
Total cold run time: 302551 ms
Total hot run time: 193351 ms

doris-robot avatar Aug 30 '24 04:08 doris-robot

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

query1	0.05	0.04	0.04
query2	0.08	0.04	0.04
query3	0.23	0.06	0.05
query4	1.67	0.07	0.07
query5	0.50	0.50	0.50
query6	1.13	0.73	0.73
query7	0.02	0.01	0.02
query8	0.05	0.04	0.04
query9	0.55	0.49	0.49
query10	0.54	0.55	0.54
query11	0.15	0.12	0.12
query12	0.15	0.13	0.12
query13	0.61	0.58	0.58
query14	2.04	2.06	2.06
query15	0.88	0.82	0.81
query16	0.38	0.37	0.36
query17	1.02	1.02	0.99
query18	0.21	0.21	0.21
query19	1.88	1.67	1.67
query20	0.01	0.02	0.01
query21	15.39	0.69	0.67
query22	4.11	7.87	1.89
query23	18.24	1.40	1.28
query24	2.08	0.24	0.22
query25	0.16	0.08	0.08
query26	0.29	0.19	0.18
query27	0.08	0.07	0.07
query28	13.49	1.01	1.01
query29	12.56	3.28	3.29
query30	0.24	0.05	0.06
query31	2.88	0.41	0.40
query32	3.23	0.48	0.48
query33	2.95	2.95	2.97
query34	17.11	4.46	4.46
query35	4.46	4.44	4.54
query36	0.67	0.47	0.49
query37	0.19	0.17	0.16
query38	0.16	0.15	0.15
query39	0.06	0.04	0.04
query40	0.17	0.13	0.13
query41	0.09	0.06	0.05
query42	0.07	0.05	0.05
query43	0.04	0.04	0.04
Total cold run time: 110.87 s
Total hot run time: 31.99 s

doris-robot avatar Aug 30 '24 04:08 doris-robot

run buildall

qzsee avatar Sep 03 '24 11:09 qzsee

run buildall

qzsee avatar Oct 08 '24 02:10 qzsee

run p0

qzsee avatar Oct 30 '24 02:10 qzsee

run buildall

qzsee avatar Oct 30 '24 03:10 qzsee

run p0

qzsee avatar Oct 30 '24 06:10 qzsee

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

github-actions[bot] avatar Oct 30 '24 08:10 github-actions[bot]