Skip to content

[feature](group by)Support group by with order.#53037

Merged
Jibing-Li merged 1 commit intoapache:masterfrom
Jibing-Li:order
Jul 10, 2025
Merged

[feature](group by)Support group by with order.#53037
Jibing-Li merged 1 commit intoapache:masterfrom
Jibing-Li:order

Conversation

@Jibing-Li
Copy link
Contributor

@Jibing-Li Jibing-Li commented Jul 10, 2025

What problem does this PR solve?

Support MariaDB syntax:

select a, sum(b) from tbl group by a [ASC | DESC];

We have user using looker BI to connect Doris as Mariadb, the BI may generate SQLs like above, we should support his syntax to compatible with looker BI.

See:
https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by#with-rollup

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 Jul 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?

@Jibing-Li Jibing-Li force-pushed the order branch 3 times, most recently from 2f333e6 to 1f2018a Compare July 10, 2025 06:52
@Jibing-Li Jibing-Li marked this pull request as ready for review July 10, 2025 06:57
@Jibing-Li
Copy link
Contributor Author

run buildall

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 38.78% (19/49) 🎉
Increment coverage report
Complete coverage report

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17587	5265	5066	5066
q2	1924	299	177	177
q3	10360	1292	726	726
q4	10241	1022	531	531
q5	7714	2380	2437	2380
q6	181	160	129	129
q7	902	746	604	604
q8	9319	1341	1108	1108
q9	6802	5062	5081	5062
q10	6878	2389	1969	1969
q11	494	285	286	285
q12	351	361	212	212
q13	17770	3740	3062	3062
q14	236	227	210	210
q15	539	487	495	487
q16	417	420	379	379
q17	587	879	363	363
q18	7662	7303	7263	7263
q19	1248	940	539	539
q20	342	337	211	211
q21	3726	3190	2302	2302
q22	362	314	294	294
Total cold run time: 105642 ms
Total hot run time: 33359 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5095	5086	5074	5074
q2	243	330	222	222
q3	2150	2691	2261	2261
q4	1358	1768	1329	1329
q5	4221	4322	4583	4322
q6	213	166	129	129
q7	2065	1938	1809	1809
q8	2697	2637	2600	2600
q9	7263	7360	7254	7254
q10	3102	3560	2842	2842
q11	593	516	552	516
q12	638	726	677	677
q13	3592	3991	3366	3366
q14	289	320	275	275
q15	516	494	476	476
q16	466	489	441	441
q17	1208	1636	1333	1333
q18	8063	7822	7559	7559
q19	830	871	1093	871
q20	2023	2076	1980	1980
q21	5185	4595	4492	4492
q22	739	583	591	583
Total cold run time: 52549 ms
Total hot run time: 50411 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 186788 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 1f2018a1e7fe5a06d469ddf8d4a4e84d02c22cdf, data reload: false

query1	1007	385	400	385
query2	6521	1715	1732	1715
query3	6743	212	214	212
query4	26252	23477	23762	23477
query5	4359	598	436	436
query6	297	213	201	201
query7	4630	491	280	280
query8	271	222	206	206
query9	8599	2646	2627	2627
query10	446	322	261	261
query11	15451	15055	14801	14801
query12	152	110	115	110
query13	1648	533	427	427
query14	8624	5943	5923	5923
query15	210	202	173	173
query16	7419	443	272	272
query17	1312	739	602	602
query18	2002	407	320	320
query19	202	195	168	168
query20	131	122	114	114
query21	218	128	108	108
query22	4228	4355	4655	4355
query23	34956	33970	33608	33608
query24	8454	2394	2381	2381
query25	523	465	393	393
query26	1221	260	144	144
query27	2774	521	349	349
query28	4264	2114	2157	2114
query29	758	550	433	433
query30	281	214	190	190
query31	899	854	744	744
query32	72	61	59	59
query33	550	342	263	263
query34	826	847	509	509
query35	613	650	557	557
query36	961	984	900	900
query37	118	101	80	80
query38	4180	4084	4082	4082
query39	1450	1417	1426	1417
query40	205	116	105	105
query41	54	56	51	51
query42	124	106	108	106
query43	505	540	488	488
query44	1299	814	852	814
query45	171	174	164	164
query46	846	1027	627	627
query47	1727	1788	1705	1705
query48	386	411	308	308
query49	736	484	407	407
query50	639	694	418	418
query51	4158	4132	4162	4132
query52	106	103	95	95
query53	222	258	193	193
query54	575	566	497	497
query55	83	81	79	79
query56	282	291	290	290
query57	1182	1180	1107	1107
query58	264	253	260	253
query59	2642	2694	2595	2595
query60	318	313	312	312
query61	121	120	113	113
query62	802	696	649	649
query63	225	192	183	183
query64	4393	1187	815	815
query65	4243	4214	4244	4214
query66	1123	408	317	317
query67	15811	15750	15326	15326
query68	8910	915	519	519
query69	495	307	268	268
query70	1231	1083	1130	1083
query71	461	330	300	300
query72	5713	4804	5090	4804
query73	746	667	350	350
query74	8863	9366	8678	8678
query75	4144	3186	2683	2683
query76	3619	1188	770	770
query77	790	403	310	310
query78	10865	11154	10150	10150
query79	1601	868	602	602
query80	629	532	495	495
query81	457	255	225	225
query82	451	130	97	97
query83	284	257	231	231
query84	297	111	96	96
query85	788	359	314	314
query86	331	312	251	251
query87	4456	4395	4334	4334
query88	2941	2293	2299	2293
query89	392	320	297	297
query90	1905	268	215	215
query91	134	138	114	114
query92	68	59	56	56
query93	1124	974	590	590
query94	674	320	207	207
query95	383	288	286	286
query96	502	600	285	285
query97	2761	2753	2616	2616
query98	227	207	203	203
query99	1481	1390	1307	1307
Total cold run time: 274587 ms
Total hot run time: 186788 ms

@doris-robot
Copy link

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

query1	0.05	0.04	0.04
query2	0.08	0.04	0.04
query3	0.25	0.08	0.07
query4	1.61	0.11	0.11
query5	0.43	0.42	0.43
query6	1.18	0.65	0.68
query7	0.03	0.02	0.02
query8	0.05	0.03	0.04
query9	0.60	0.51	0.52
query10	0.58	0.57	0.57
query11	0.15	0.10	0.10
query12	0.15	0.11	0.12
query13	0.61	0.60	0.61
query14	0.80	0.84	0.81
query15	0.90	0.87	0.85
query16	0.39	0.40	0.40
query17	1.08	1.08	1.07
query18	0.22	0.21	0.21
query19	1.99	1.80	1.82
query20	0.01	0.02	0.01
query21	15.40	0.88	0.53
query22	0.75	1.30	0.65
query23	14.82	1.38	0.64
query24	8.21	1.31	0.50
query25	0.45	0.12	0.20
query26	0.77	0.16	0.14
query27	0.05	0.05	0.05
query28	8.79	0.89	0.45
query29	12.58	3.96	3.26
query30	0.25	0.10	0.07
query31	2.83	0.59	0.40
query32	3.23	0.56	0.47
query33	3.15	3.12	3.14
query34	16.21	5.37	4.76
query35	4.80	4.87	4.81
query36	0.70	0.51	0.49
query37	0.09	0.06	0.06
query38	0.05	0.04	0.03
query39	0.03	0.02	0.03
query40	0.18	0.15	0.14
query41	0.09	0.03	0.02
query42	0.03	0.03	0.02
query43	0.04	0.04	0.03
Total cold run time: 104.66 s
Total hot run time: 29.2 s

@Jibing-Li
Copy link
Contributor Author

run buildall

morrySnow
morrySnow previously approved these changes Jul 10, 2025
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Jul 10, 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.

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17579	5143	5011	5011
q2	1942	287	177	177
q3	10320	1257	719	719
q4	10271	1018	505	505
q5	8041	2398	2290	2290
q6	179	157	128	128
q7	897	764	602	602
q8	9319	1278	1018	1018
q9	6808	5091	5086	5086
q10	6874	2349	1966	1966
q11	480	290	278	278
q12	340	343	208	208
q13	17777	3682	3059	3059
q14	233	220	207	207
q15	569	478	479	478
q16	431	433	368	368
q17	591	860	342	342
q18	7416	7072	7137	7072
q19	1237	928	583	583
q20	333	335	217	217
q21	3665	3191	2336	2336
q22	348	319	303	303
Total cold run time: 105650 ms
Total hot run time: 32953 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5146	5067	5050	5050
q2	239	320	224	224
q3	2192	2708	2319	2319
q4	1384	1801	1321	1321
q5	4218	4152	4553	4152
q6	238	173	126	126
q7	2006	1939	1859	1859
q8	2679	2661	2534	2534
q9	7301	7226	7196	7196
q10	3145	3266	2795	2795
q11	571	526	523	523
q12	673	995	669	669
q13	3545	3964	3600	3600
q14	293	322	291	291
q15	528	494	477	477
q16	461	509	459	459
q17	1256	1622	1378	1378
q18	8186	7946	7697	7697
q19	834	905	908	905
q20	2041	2085	1867	1867
q21	4825	4480	4296	4296
q22	621	575	522	522
Total cold run time: 52382 ms
Total hot run time: 50260 ms

@Jibing-Li
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17600	5157	5033	5033
q2	1927	278	189	189
q3	10382	1277	703	703
q4	10289	1005	521	521
q5	8659	2266	2321	2266
q6	212	157	129	129
q7	910	754	599	599
q8	9317	1303	1001	1001
q9	7353	5013	5153	5013
q10	6928	2382	1962	1962
q11	474	289	281	281
q12	351	340	217	217
q13	17779	3766	3113	3113
q14	226	238	210	210
q15	553	476	481	476
q16	413	428	375	375
q17	596	865	365	365
q18	7584	7158	7153	7153
q19	1352	930	540	540
q20	342	348	218	218
q21	3647	2537	2356	2356
q22	341	315	299	299
Total cold run time: 107235 ms
Total hot run time: 33019 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5103	5057	5055	5055
q2	245	323	219	219
q3	2158	2701	2282	2282
q4	1363	1839	1358	1358
q5	4238	4224	4468	4224
q6	209	174	124	124
q7	2008	1975	1732	1732
q8	2666	2720	2499	2499
q9	7321	7461	7183	7183
q10	3121	3343	2902	2902
q11	586	549	498	498
q12	688	768	622	622
q13	3569	4165	3556	3556
q14	305	314	273	273
q15	526	476	493	476
q16	465	522	472	472
q17	1222	1602	1420	1420
q18	8262	7864	7860	7860
q19	822	839	840	839
q20	2036	1976	1829	1829
q21	4889	4344	4405	4344
q22	602	582	533	533
Total cold run time: 52404 ms
Total hot run time: 50300 ms

@doris-robot
Copy link

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

query1	984	391	408	391
query2	6531	1763	1735	1735
query3	6757	210	218	210
query4	26452	23923	23156	23156
query5	4328	572	443	443
query6	302	212	198	198
query7	4627	496	293	293
query8	287	227	214	214
query9	8613	2644	2664	2644
query10	479	313	262	262
query11	15865	15087	14975	14975
query12	154	103	99	99
query13	1655	509	389	389
query14	9463	6020	5935	5935
query15	208	191	170	170
query16	7594	455	248	248
query17	1309	719	558	558
query18	1999	393	300	300
query19	191	185	155	155
query20	119	118	119	118
query21	210	122	106	106
query22	3968	4074	3917	3917
query23	33852	33250	33124	33124
query24	8438	2353	2396	2353
query25	568	506	426	426
query26	1231	274	151	151
query27	2759	514	357	357
query28	4330	2116	2105	2105
query29	753	574	462	462
query30	285	225	189	189
query31	929	839	777	777
query32	73	71	66	66
query33	564	349	288	288
query34	793	855	526	526
query35	596	646	604	604
query36	937	970	896	896
query37	106	101	75	75
query38	4118	4212	4094	4094
query39	1479	1416	1457	1416
query40	211	112	109	109
query41	54	57	49	49
query42	121	106	109	106
query43	522	545	490	490
query44	1328	823	849	823
query45	171	174	167	167
query46	837	1021	620	620
query47	1734	1761	1730	1730
query48	386	416	306	306
query49	733	461	363	363
query50	649	706	411	411
query51	5522	5532	5422	5422
query52	106	106	99	99
query53	217	243	187	187
query54	571	573	504	504
query55	83	78	83	78
query56	314	291	294	291
query57	1187	1175	1120	1120
query58	271	251	263	251
query59	2690	2838	2726	2726
query60	332	318	296	296
query61	154	119	125	119
query62	802	713	690	690
query63	222	190	188	188
query64	4328	1197	810	810
query65	4249	4174	4173	4173
query66	1067	401	347	347
query67	15607	15734	15413	15413
query68	7952	880	530	530
query69	489	320	275	275
query70	1176	1113	1043	1043
query71	464	329	306	306
query72	5579	4738	2390	2390
query73	701	639	348	348
query74	9018	9294	9079	9079
query75	3823	3160	2657	2657
query76	3675	1138	731	731
query77	810	382	293	293
query78	10768	10924	10304	10304
query79	2531	809	589	589
query80	710	505	419	419
query81	478	255	221	221
query82	479	125	96	96
query83	293	267	227	227
query84	289	111	80	80
query85	820	363	310	310
query86	381	295	303	295
query87	4499	4463	4312	4312
query88	3575	2276	2303	2276
query89	377	319	296	296
query90	1888	211	203	203
query91	138	140	113	113
query92	81	60	54	54
query93	2106	943	588	588
query94	688	309	193	193
query95	376	296	282	282
query96	486	579	281	281
query97	2693	2763	2653	2653
query98	233	208	198	198
query99	1471	1454	1317	1317
Total cold run time: 277421 ms
Total hot run time: 185272 ms

@doris-robot
Copy link

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

query1	0.04	0.04	0.04
query2	0.08	0.04	0.04
query3	0.24	0.08	0.08
query4	1.61	0.11	0.11
query5	0.44	0.42	0.42
query6	1.17	0.67	0.66
query7	0.03	0.02	0.02
query8	0.05	0.03	0.03
query9	0.61	0.54	0.52
query10	0.57	0.56	0.57
query11	0.16	0.11	0.11
query12	0.15	0.12	0.11
query13	0.63	0.60	0.61
query14	0.81	0.80	0.81
query15	0.91	0.87	0.87
query16	0.39	0.39	0.39
query17	1.08	1.04	1.08
query18	0.22	0.21	0.21
query19	1.99	1.89	1.88
query20	0.01	0.02	0.01
query21	15.39	0.90	0.53
query22	0.77	1.34	0.64
query23	14.79	1.39	0.64
query24	7.02	1.27	0.59
query25	0.43	0.23	0.09
query26	0.56	0.17	0.14
query27	0.07	0.06	0.05
query28	9.38	0.90	0.45
query29	12.60	4.00	3.36
query30	0.25	0.09	0.07
query31	2.83	0.60	0.39
query32	3.24	0.56	0.47
query33	3.02	3.14	3.09
query34	15.99	5.37	4.74
query35	4.86	4.82	4.86
query36	0.67	0.49	0.50
query37	0.09	0.06	0.06
query38	0.06	0.05	0.04
query39	0.04	0.02	0.03
query40	0.17	0.14	0.13
query41	0.08	0.03	0.02
query42	0.04	0.03	0.02
query43	0.04	0.03	0.03
Total cold run time: 103.58 s
Total hot run time: 29.38 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 75.00% (30/40) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 75.00% (30/40) 🎉
Increment coverage report
Complete coverage report

@Jibing-Li
Copy link
Contributor Author

run vault_p0

@liujiwen-up
Copy link
Contributor

run p0

@liujiwen-up
Copy link
Contributor

run arm

@Jibing-Li
Copy link
Contributor Author

run NonConcurrent

@Jibing-Li Jibing-Li merged commit e36e6e6 into apache:master Jul 10, 2025
28 of 30 checks passed
@Jibing-Li Jibing-Li deleted the order branch July 10, 2025 15:15
Jibing-Li added a commit to Jibing-Li/incubator-doris that referenced this pull request Jul 24, 2025
Support MariaDB syntax:
```
select a, sum(b) from tbl group by a [ASC | DESC];
```

We have use using looker BI to connect Doris as Mariadb, the BI may
generate SQLs like above, we should support his syntax to compatible
with looker BI.

See:
https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by#with-rollup
Jibing-Li added a commit to Jibing-Li/incubator-doris that referenced this pull request Jul 24, 2025
Support MariaDB syntax:
```
select a, sum(b) from tbl group by a [ASC | DESC];
```

We have use using looker BI to connect Doris as Mariadb, the BI may
generate SQLs like above, we should support his syntax to compatible
with looker BI.

See:
https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by#with-rollup
Jibing-Li added a commit to Jibing-Li/incubator-doris that referenced this pull request Jul 24, 2025
Support MariaDB syntax:
```
select a, sum(b) from tbl group by a [ASC | DESC];
```

We have use using looker BI to connect Doris as Mariadb, the BI may
generate SQLs like above, we should support his syntax to compatible
with looker BI.

See:
https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by#with-rollup
Jibing-Li added a commit to Jibing-Li/incubator-doris that referenced this pull request Jul 24, 2025
Support MariaDB syntax:
```
select a, sum(b) from tbl group by a [ASC | DESC];
```

We have use using looker BI to connect Doris as Mariadb, the BI may
generate SQLs like above, we should support his syntax to compatible
with looker BI.

See:
https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/group-by#with-rollup
@gavinchou gavinchou mentioned this pull request Sep 1, 2025
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.

9 participants

Comments