Skip to content

[fix](agg) Align complex aggregate null ordering - #67439

Merged
Mryange merged 3 commits into
apache:masterfrom
Mryange:fix-array-aggregate-ordering
Sep 15, 2026
Merged

Mryange merged 3 commits into
apache:masterfrom
Mryange:fix-array-aggregate-ordering

Conversation

@Mryange

@Mryange Mryange commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Problem Summary: Complex-type min, max, min_by, and max_by used a NULL ordering direction different from ordinary SQL array comparisons. This could select inconsistent results for arrays containing NULL elements. The aggregate comparison direction is aligned with SQL array ordering, and regression expectations are updated.

apache/doris-website#4121

Release note

Complex-type aggregate ordering now follows SQL array NULL ordering.

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
Copy Markdown
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?

@Mryange

Mryange commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I found two correctness issues in the current head. First, changing the shared complex comparator hint to +1 reverses nested NULL ordering for unary complex min/max (and merge/window paths), conflicting with Doris' documented ARRAY aggregate order; the unchanged plain min(arr) expectation already exposes the inconsistency. Please scope the policy or reconcile the aggregate contract and tests. Second, the id=5 max_by(arr, weight) expected row selects a NULL weight even though the nullable variadic wrapper skips rows with any NULL argument; it should remain [1, null, 3, 4]. The new coverage also does not exercise sliding-window/incremental complex min/max behavior.


bool change_if_less(const IColumn& column, size_t row_num, Arena& arena) {
if (!has() || column_data->compare_at(0, row_num, column, -1) == 1) {
if (!has() || column_data->compare_at(0, row_num, column, 1) == 1) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SingleValueDataComplexType is also the state for unary complex min/max, not just the *_by key. With this +1, nested ColumnNullable treats NULL as greatest, so [10,NULL] beats [10,5] for max(arr) and loses for min(arr). That conflicts with Doris' documented ARRAY aggregate order (NULL is smallest) and the unchanged maxmin_array_2 expectation. Please keep the aggregate comparator policy consistent with the documented contract (or scope a different hint to the intended *_by path) and add/update plain, merge, and window coverage.

3 [3, 1] [11, 22, 33, 44]
4 [3, 1] [10]
5 [1, null, 3, 4] [1, 2, 3, 4]
5 [11, null, null, 55] [1, 2, 3, 4]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

max_by(arr, weight) still uses the nullable weight column as an INT key. AggregateFunctionNullVariadicInline::add drops any row where an argument is NULL, so id=5's [11, null, null, 55] row (weight=NULL) cannot be selected; the maximum eligible weight is 5, yielding [1, null, 3, 4]. Please restore this expected value and retain the NULL-key case to verify it stays skipped.

@Mryange

Mryange commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@Mryange

Mryange commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: N/A

Problem Summary: Array NULL ordering changes also affect associated values selected by complex MIN_BY and MAX_BY regression queries. Update the remaining expected results to match the ordering keys exercised by each query.

### Release note

None

### Check List (For Author)

- Test: Regression test
    - test_aggregate_all_functions2
- Behavior changed: No
- Does this need documentation: No
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17619	3100	3115	3100
q2	2130	262	223	223
q3	10221	911	520	520
q4	4669	264	206	206
q5	7657	578	406	406
q6	138	117	95	95
q7	527	514	380	380
q8	9234	904	942	904
q9	3413	2411	2388	2388
q10	6519	852	719	719
q11	401	202	185	185
q12	615	259	202	202
q13	18140	1518	1166	1166
q14	159	156	138	138
q15	q16	451	401	369	369
q17	1342	871	823	823
q18	3047	2246	2233	2233
q19	1255	896	722	722
q20	385	291	203	203
q21	5625	1845	1922	1845
q22	324	262	228	228
Total cold run time: 93871 ms
Total hot run time: 17055 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3517	3429	3413	3413
q2	527	406	379	379
q3	2247	2303	2159	2159
q4	1202	1175	903	903
q5	2158	2086	2080	2080
q6	166	122	89	89
q7	1055	911	854	854
q8	1605	1416	1448	1416
q9	3136	3127	3115	3115
q10	1838	1777	1631	1631
q11	361	270	253	253
q12	455	425	353	353
q13	1466	1542	1159	1159
q14	179	168	165	165
q15	q16	397	394	368	368
q17	3577	3327	3175	3175
q18	4816	4485	4709	4485
q19	958	873	856	856
q20	1026	970	848	848
q21	3894	3247	3173	3173
q22	416	347	325	325
Total cold run time: 34996 ms
Total hot run time: 31199 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 82000 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 ca9b1f95b719d49c8cfe239385f63d1e7f3559ba, data reload: false

query5	4278	418	349	349
query6	394	131	134	131
query7	4924	399	229	229
query8	293	127	119	119
query9	8708	2908	2904	2904
query10	403	231	183	183
query11	5389	1051	911	911
query12	119	73	72	72
query13	1188	412	302	302
query14	6165	2203	2091	2091
query14_1	1988	2011	1967	1967
query15	178	123	115	115
query16	923	372	353	353
query17	802	452	368	368
query18	2336	320	235	235
query19	173	136	110	110
query20	74	72	71	71
query21	208	103	91	91
query22	5397	5396	5307	5307
query23	6808	6309	5992	5992
query23_1	6017	5992	6066	5992
query24	7281	1095	773	773
query24_1	755	792	801	792
query25	396	273	232	232
query26	1226	225	125	125
query27	2801	430	255	255
query28	4679	1495	1513	1495
query29	918	413	335	335
query30	253	153	129	129
query31	810	404	330	330
query32	125	68	72	68
query33	442	213	181	181
query34	995	838	503	503
query35	401	391	352	352
query36	574	551	534	534
query37	118	81	70	70
query38	1000	878	803	803
query39	472	496	477	477
query39_1	444	483	462	462
query40	196	90	79	79
query41	59	52	54	52
query42	73	74	72	72
query43	243	243	212	212
query44	1020	538	543	538
query45	119	107	101	101
query46	802	830	509	509
query47	752	770	709	709
query48	310	324	234	234
query49	524	234	186	186
query50	743	263	193	193
query51	8300	8227	8384	8227
query52	67	77	59	59
query53	191	197	146	146
query54	231	170	158	158
query55	83	59	55	55
query56	203	158	186	158
query57	686	673	720	673
query58	209	167	161	161
query59	1233	1262	1100	1100
query60	245	200	192	192
query61	120	134	117	117
query62	374	203	188	188
query63	175	143	146	143
query64	2941	793	639	639
query65	1631	1578	1565	1565
query66	1812	264	203	203
query67	9585	9551	9762	9551
query68	2750	1121	752	752
query69	337	226	201	201
query70	674	630	587	587
query71	240	176	167	167
query72	2263	1685	1496	1496
query73	625	618	345	345
query74	1571	1226	1137	1137
query75	1156	1095	958	958
query76	2291	753	535	535
query77	252	261	225	225
query78	3885	3668	3201	3201
query79	1828	841	588	588
query80	1203	324	269	269
query81	498	153	130	130
query82	627	121	93	93
query83	288	210	195	195
query84	287	114	91	91
query85	784	341	277	277
query86	384	181	177	177
query87	1010	975	893	893
query88	2773	2107	2105	2105
query89	278	198	175	175
query90	1953	135	129	129
query91	137	124	97	97
query92	82	62	69	62
query93	1393	1061	683	683
query94	635	268	224	224
query95	513	349	237	237
query96	792	536	272	272
query97	1049	1047	1028	1028
query98	146	134	132	132
query99	418	342	320	320
Total cold run time: 175911 ms
Total hot run time: 82000 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.08	0.04	0.03
query3	0.25	0.10	0.11
query4	1.60	0.10	0.11
query5	0.18	0.17	0.16
query6	1.23	0.69	0.69
query7	0.03	0.01	0.00
query8	0.05	0.03	0.03
query9	0.28	0.22	0.21
query10	0.34	0.35	0.34
query11	0.17	0.12	0.11
query12	0.14	0.12	0.12
query13	0.32	0.31	0.31
query14	0.45	0.44	0.44
query15	0.37	0.35	0.36
query16	0.23	0.23	0.21
query17	0.71	0.67	0.72
query18	0.18	0.17	0.16
query19	1.15	1.15	1.09
query20	0.02	0.01	0.01
query21	15.45	0.16	0.11
query22	5.06	0.05	0.04
query23	16.22	0.25	0.10
query24	3.01	0.31	0.24
query25	0.10	0.04	0.04
query26	0.74	0.17	0.11
query27	0.03	0.04	0.02
query28	3.62	0.60	0.28
query29	12.45	3.14	2.55
query30	0.25	0.13	0.12
query31	2.75	0.37	0.17
query32	3.52	0.31	0.24
query33	1.50	1.48	1.57
query34	15.36	2.23	1.77
query35	1.75	1.72	1.72
query36	0.45	0.30	0.27
query37	0.05	0.03	0.04
query38	0.05	0.03	0.03
query39	0.03	0.02	0.02
query40	0.11	0.08	0.07
query41	0.08	0.03	0.03
query42	0.03	0.02	0.03
query43	0.03	0.03	0.02
Total cold run time: 90.43 s
Total hot run time: 14.62 s

@Mryange

Mryange commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17650	3138	3089	3089
q2	2108	252	234	234
q3	10228	882	503	503
q4	4671	249	207	207
q5	7673	570	384	384
q6	140	113	91	91
q7	533	520	391	391
q8	9236	902	893	893
q9	3439	2390	2378	2378
q10	6500	832	722	722
q11	402	195	179	179
q12	620	261	198	198
q13	18122	1530	1159	1159
q14	158	151	139	139
q15	q16	425	394	365	365
q17	1395	921	864	864
q18	3069	2270	2229	2229
q19	1272	892	718	718
q20	379	279	202	202
q21	5619	1576	1846	1576
q22	326	269	229	229
Total cold run time: 93965 ms
Total hot run time: 16750 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3479	3454	3413	3413
q2	490	397	376	376
q3	2283	2271	2208	2208
q4	1194	1172	889	889
q5	2145	2085	2094	2085
q6	164	116	85	85
q7	1046	908	879	879
q8	1599	1414	1411	1411
q9	3102	3104	3100	3100
q10	1852	1781	1639	1639
q11	357	272	252	252
q12	448	426	348	348
q13	1496	1546	1158	1158
q14	176	180	162	162
q15	q16	400	403	355	355
q17	3583	3277	3174	3174
q18	4804	4376	4710	4376
q19	873	890	879	879
q20	988	962	843	843
q21	3868	3138	3266	3138
q22	398	344	328	328
Total cold run time: 34745 ms
Total hot run time: 31098 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81398 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 b46c17aad34cac4b4f5043127cbf7c9151854e3d, data reload: false

query5	4249	395	341	341
query6	380	129	129	129
query7	4967	408	229	229
query8	285	124	119	119
query9	8707	2876	2867	2867
query10	409	231	181	181
query11	5372	1033	907	907
query12	112	71	70	70
query13	1188	420	340	340
query14	6145	2188	2076	2076
query14_1	1967	1958	1948	1948
query15	176	122	113	113
query16	922	367	364	364
query17	780	427	337	337
query18	2336	324	228	228
query19	160	141	102	102
query20	68	71	70	70
query21	206	98	83	83
query22	5307	5226	5255	5226
query23	6838	6192	5901	5901
query23_1	5987	5974	5975	5974
query24	7345	1079	773	773
query24_1	761	752	777	752
query25	409	269	224	224
query26	1237	225	121	121
query27	2796	426	259	259
query28	4689	1475	1462	1462
query29	916	416	329	329
query30	249	157	132	132
query31	822	391	322	322
query32	121	95	72	72
query33	451	198	165	165
query34	1004	821	479	479
query35	407	388	343	343
query36	562	529	525	525
query37	115	78	67	67
query38	1007	838	842	838
query39	473	490	474	474
query39_1	451	460	449	449
query40	198	87	77	77
query41	54	51	49	49
query42	72	70	68	68
query43	234	242	212	212
query44	1026	540	541	540
query45	106	102	97	97
query46	804	845	532	532
query47	747	757	710	710
query48	313	312	236	236
query49	524	224	189	189
query50	759	263	190	190
query51	8179	8205	8067	8067
query52	67	66	58	58
query53	203	201	148	148
query54	220	160	150	150
query55	73	61	58	58
query56	193	200	162	162
query57	658	662	658	658
query58	217	182	277	182
query59	1196	1224	1107	1107
query60	256	188	164	164
query61	127	133	124	124
query62	353	208	176	176
query63	172	145	142	142
query64	2805	775	655	655
query65	1604	1576	1618	1576
query66	1900	258	222	222
query67	9832	9790	9659	9659
query68	2997	1238	749	749
query69	349	222	206	206
query70	674	633	610	610
query71	257	177	164	164
query72	2260	1705	1467	1467
query73	668	592	337	337
query74	1981	1230	1115	1115
query75	1187	1094	948	948
query76	2379	727	534	534
query77	256	248	214	214
query78	3970	3692	3219	3219
query79	2922	789	567	567
query80	1548	331	297	297
query81	526	158	144	144
query82	635	135	95	95
query83	300	217	189	189
query84	300	108	91	91
query85	803	332	282	282
query86	482	173	172	172
query87	1017	971	894	894
query88	3907	2126	2106	2106
query89	274	196	176	176
query90	2170	132	130	130
query91	130	115	98	98
query92	98	73	67	67
query93	3257	1151	672	672
query94	654	255	180	180
query95	544	349	221	221
query96	830	567	284	284
query97	1049	1085	969	969
query98	200	140	132	132
query99	418	351	308	308
Total cold run time: 181758 ms
Total hot run time: 81398 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.08	0.04	0.04
query3	0.24	0.11	0.12
query4	1.61	0.10	0.09
query5	0.17	0.16	0.15
query6	1.28	0.68	0.70
query7	0.04	0.00	0.01
query8	0.05	0.04	0.03
query9	0.30	0.23	0.21
query10	0.35	0.35	0.35
query11	0.17	0.12	0.12
query12	0.14	0.12	0.12
query13	0.31	0.31	0.31
query14	0.45	0.46	0.47
query15	0.36	0.34	0.35
query16	0.22	0.21	0.23
query17	0.68	0.68	0.71
query18	0.19	0.16	0.17
query19	1.23	1.22	1.14
query20	0.02	0.01	0.01
query21	15.45	0.17	0.12
query22	5.05	0.05	0.04
query23	16.19	0.26	0.10
query24	3.04	0.31	0.25
query25	0.10	0.05	0.03
query26	0.79	0.16	0.14
query27	0.04	0.03	0.03
query28	3.61	0.59	0.29
query29	12.42	3.20	2.62
query30	0.25	0.11	0.11
query31	2.76	0.37	0.16
query32	3.52	0.33	0.22
query33	1.39	1.55	1.48
query34	15.42	2.16	1.74
query35	1.78	1.71	1.68
query36	0.46	0.30	0.29
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.03	0.02	0.03
query40	0.12	0.07	0.08
query41	0.08	0.02	0.02
query42	0.03	0.02	0.03
query43	0.03	0.03	0.03
Total cold run time: 90.56 s
Total hot run time: 14.74 s

@Mryange

Mryange commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.40% (29875/47118)
Line Coverage 48.44% (313620/647491)
Region Coverage 43.93% (252660/575098)
Branch Coverage 45.55% (117885/258799)

@Mryange

Mryange commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 80.00% (4/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.42% (34880/45641)
Line Coverage 61.48% (393565/640190)
Region Coverage 57.58% (329886/572944)
Branch Coverage 58.45% (150859/258096)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17563	3082	3089	3082
q2	2084	261	221	221
q3	10245	852	519	519
q4	4664	247	208	208
q5	7673	541	382	382
q6	136	110	90	90
q7	510	523	383	383
q8	9235	874	885	874
q9	3439	2375	2360	2360
q10	6519	843	714	714
q11	405	198	179	179
q12	622	262	193	193
q13	18141	1522	1141	1141
q14	153	149	141	141
q15	q16	424	394	377	377
q17	1351	864	835	835
q18	3076	2241	2240	2240
q19	1297	869	771	771
q20	382	289	200	200
q21	5556	1659	1843	1659
q22	338	263	228	228
Total cold run time: 93813 ms
Total hot run time: 16797 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3448	3405	3396	3396
q2	504	392	380	380
q3	2198	2288	2120	2120
q4	1189	1164	892	892
q5	2140	2087	2081	2081
q6	168	119	86	86
q7	994	884	847	847
q8	1579	1395	1387	1387
q9	3099	3092	3067	3067
q10	1858	1791	1627	1627
q11	350	268	248	248
q12	454	424	337	337
q13	1445	1516	1146	1146
q14	175	164	161	161
q15	q16	389	389	354	354
q17	3605	3352	3183	3183
q18	4781	4341	4687	4341
q19	852	814	891	814
q20	1050	1009	829	829
q21	3856	3167	3293	3167
q22	384	341	335	335
Total cold run time: 34518 ms
Total hot run time: 30798 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 80938 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 b46c17aad34cac4b4f5043127cbf7c9151854e3d, data reload: false

query5	4234	426	341	341
query6	376	137	128	128
query7	4939	426	223	223
query8	304	123	133	123
query9	8676	2866	2902	2866
query10	397	221	177	177
query11	5386	1059	915	915
query12	122	75	71	71
query13	1204	436	308	308
query14	5994	2172	2067	2067
query14_1	1968	1954	1940	1940
query15	178	118	110	110
query16	930	360	344	344
query17	806	455	357	357
query18	2349	322	231	231
query19	166	140	109	109
query20	98	66	67	66
query21	192	97	83	83
query22	5382	5276	5349	5276
query23	6667	6224	5911	5911
query23_1	5932	5960	5943	5943
query24	7270	1077	750	750
query24_1	766	785	772	772
query25	404	273	236	236
query26	1225	225	127	127
query27	2794	424	241	241
query28	4701	1496	1474	1474
query29	908	409	331	331
query30	247	149	131	131
query31	825	409	330	330
query32	124	70	70	70
query33	449	204	178	178
query34	978	840	481	481
query35	394	405	331	331
query36	546	556	530	530
query37	115	78	68	68
query38	999	843	816	816
query39	514	496	454	454
query39_1	447	480	462	462
query40	199	86	82	82
query41	52	51	50	50
query42	76	71	71	71
query43	237	241	213	213
query44	1009	519	529	519
query45	105	104	96	96
query46	762	860	507	507
query47	765	764	707	707
query48	301	306	219	219
query49	546	245	182	182
query50	744	252	190	190
query51	8030	7819	7830	7819
query52	72	74	61	61
query53	185	194	149	149
query54	214	152	146	146
query55	71	57	52	52
query56	181	181	152	152
query57	687	654	621	621
query58	182	163	162	162
query59	1223	1321	1101	1101
query60	234	182	177	177
query61	118	116	125	116
query62	354	202	177	177
query63	167	141	139	139
query64	2750	780	625	625
query65	1584	1535	1625	1535
query66	1895	267	203	203
query67	9923	9778	9596	9596
query68	3002	1155	717	717
query69	350	225	202	202
query70	655	645	628	628
query71	258	179	159	159
query72	2315	1671	1482	1482
query73	642	590	338	338
query74	2006	1202	1123	1123
query75	1177	1093	939	939
query76	2383	711	503	503
query77	264	258	207	207
query78	3760	3661	3283	3283
query79	1436	817	574	574
query80	1186	352	261	261
query81	491	156	133	133
query82	625	127	93	93
query83	284	219	200	200
query84	297	114	90	90
query85	772	345	279	279
query86	388	175	175	175
query87	1023	973	891	891
query88	2773	2106	2107	2106
query89	291	197	179	179
query90	1971	132	125	125
query91	130	117	99	99
query92	79	73	63	63
query93	1353	1158	712	712
query94	625	251	224	224
query95	511	312	222	222
query96	771	612	291	291
query97	1052	1059	1006	1006
query98	142	134	135	134
query99	431	349	309	309
Total cold run time: 175516 ms
Total hot run time: 80938 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.08	0.04	0.04
query3	0.25	0.11	0.11
query4	1.61	0.09	0.09
query5	0.16	0.15	0.16
query6	1.29	0.67	0.69
query7	0.03	0.00	0.01
query8	0.05	0.03	0.03
query9	0.28	0.22	0.21
query10	0.35	0.35	0.33
query11	0.16	0.12	0.12
query12	0.15	0.12	0.12
query13	0.31	0.31	0.32
query14	0.45	0.44	0.44
query15	0.36	0.34	0.34
query16	0.23	0.24	0.23
query17	0.68	0.67	0.72
query18	0.18	0.18	0.16
query19	1.16	1.16	1.14
query20	0.01	0.01	0.01
query21	15.44	0.17	0.12
query22	5.04	0.05	0.04
query23	16.20	0.27	0.10
query24	3.07	0.33	0.26
query25	0.12	0.04	0.03
query26	0.72	0.16	0.12
query27	0.03	0.04	0.04
query28	3.65	0.56	0.28
query29	12.45	3.15	2.59
query30	0.26	0.11	0.12
query31	2.76	0.37	0.17
query32	3.54	0.31	0.23
query33	1.37	1.42	1.53
query34	15.39	2.20	1.76
query35	1.78	1.72	1.71
query36	0.46	0.30	0.26
query37	0.06	0.04	0.04
query38	0.04	0.03	0.02
query39	0.04	0.02	0.02
query40	0.11	0.08	0.08
query41	0.07	0.02	0.02
query42	0.03	0.02	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.47 s
Total hot run time: 14.64 s

@Mryange

Mryange commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17618	3003	3005	3003
q2	2061	256	261	256
q3	10223	882	500	500
q4	4659	242	205	205
q5	7684	541	387	387
q6	132	113	93	93
q7	514	492	406	406
q8	9228	865	924	865
q9	3420	2404	2368	2368
q10	6498	864	683	683
q11	387	200	177	177
q12	610	253	200	200
q13	18132	1532	1166	1166
q14	154	155	136	136
q15	q16	433	390	366	366
q17	1378	839	788	788
q18	3132	2217	2243	2217
q19	1262	911	705	705
q20	364	280	197	197
q21	5609	1771	1823	1771
q22	333	268	221	221
Total cold run time: 93831 ms
Total hot run time: 16710 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3362	3269	3283	3269
q2	494	380	362	362
q3	2199	2357	2218	2218
q4	1170	1146	873	873
q5	2149	2060	2066	2060
q6	167	118	85	85
q7	988	919	864	864
q8	1582	1373	1369	1369
q9	3081	3043	3022	3022
q10	1832	1794	1623	1623
q11	347	268	253	253
q12	449	424	332	332
q13	1447	1538	1134	1134
q14	166	164	161	161
q15	q16	387	396	354	354
q17	3499	3248	3266	3248
q18	4754	4400	4676	4400
q19	877	779	793	779
q20	1092	937	844	844
q21	3704	2995	3211	2995
q22	386	329	317	317
Total cold run time: 34132 ms
Total hot run time: 30562 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81379 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 b46c17aad34cac4b4f5043127cbf7c9151854e3d, data reload: false

query5	4249	409	333	333
query6	378	135	117	117
query7	4977	431	220	220
query8	286	120	118	118
query9	8690	2871	2838	2838
query10	378	215	180	180
query11	5380	1044	894	894
query12	109	70	67	67
query13	1180	439	312	312
query14	6083	2194	2088	2088
query14_1	1975	1930	1952	1930
query15	172	123	109	109
query16	927	370	333	333
query17	793	461	345	345
query18	2332	319	227	227
query19	162	133	112	112
query20	71	70	71	70
query21	204	100	88	88
query22	5265	5398	5196	5196
query23	6439	6198	6187	6187
query23_1	6084	6145	6109	6109
query24	7288	1083	758	758
query24_1	758	784	795	784
query25	427	292	248	248
query26	1228	230	128	128
query27	2793	435	258	258
query28	4662	1497	1501	1497
query29	926	441	351	351
query30	252	150	123	123
query31	806	397	327	327
query32	126	79	81	79
query33	463	219	171	171
query34	993	826	485	485
query35	400	391	345	345
query36	567	556	517	517
query37	118	83	72	72
query38	999	836	819	819
query39	486	494	475	475
query39_1	490	441	448	441
query40	204	92	83	83
query41	59	56	53	53
query42	74	73	71	71
query43	236	241	210	210
query44	980	531	537	531
query45	112	106	102	102
query46	829	793	542	542
query47	740	781	710	710
query48	307	323	218	218
query49	536	243	187	187
query50	762	276	202	202
query51	8036	7976	7897	7897
query52	65	72	58	58
query53	189	191	150	150
query54	205	157	143	143
query55	72	60	54	54
query56	189	160	170	160
query57	722	663	660	660
query58	285	162	161	161
query59	1184	1203	1087	1087
query60	222	174	173	173
query61	117	110	105	105
query62	367	213	174	174
query63	168	140	140	140
query64	2719	706	594	594
query65	1622	1581	1612	1581
query66	1855	278	208	208
query67	9788	9707	9664	9664
query68	2756	1157	700	700
query69	342	221	191	191
query70	659	614	636	614
query71	244	176	165	165
query72	2225	1620	1470	1470
query73	620	550	323	323
query74	1566	1204	1133	1133
query75	1162	1083	940	940
query76	2308	709	514	514
query77	245	250	208	208
query78	3814	3668	3206	3206
query79	2484	818	578	578
query80	1584	318	278	278
query81	488	150	130	130
query82	622	127	98	98
query83	275	202	186	186
query84	290	109	86	86
query85	765	327	277	277
query86	387	183	171	171
query87	989	955	874	874
query88	2758	2089	2092	2089
query89	299	187	171	171
query90	1982	122	130	122
query91	129	121	98	98
query92	79	63	71	63
query93	1376	1075	723	723
query94	627	264	205	205
query95	530	255	221	221
query96	790	562	270	270
query97	1017	1044	1040	1040
query98	153	130	138	130
query99	415	328	302	302
Total cold run time: 175967 ms
Total hot run time: 81379 ms

@hello-stephen

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

query1	0.00	0.01	0.00
query2	0.07	0.04	0.03
query3	0.25	0.11	0.11
query4	1.61	0.10	0.08
query5	0.18	0.16	0.16
query6	1.28	0.68	0.70
query7	0.04	0.01	0.01
query8	0.04	0.03	0.03
query9	0.29	0.21	0.22
query10	0.35	0.34	0.35
query11	0.15	0.12	0.11
query12	0.15	0.12	0.12
query13	0.32	0.30	0.30
query14	0.46	0.44	0.45
query15	0.37	0.35	0.34
query16	0.22	0.23	0.22
query17	0.69	0.69	0.66
query18	0.18	0.17	0.16
query19	1.22	1.23	1.10
query20	0.01	0.01	0.01
query21	15.42	0.16	0.11
query22	5.09	0.04	0.04
query23	16.17	0.24	0.11
query24	3.04	0.31	0.30
query25	0.10	0.04	0.03
query26	0.85	0.16	0.13
query27	0.04	0.03	0.02
query28	3.69	0.53	0.26
query29	12.53	3.18	2.58
query30	0.25	0.11	0.13
query31	2.76	0.38	0.17
query32	3.51	0.32	0.24
query33	1.36	1.38	1.39
query34	15.36	2.17	1.74
query35	1.76	1.72	1.71
query36	0.45	0.29	0.29
query37	0.06	0.04	0.03
query38	0.05	0.03	0.03
query39	0.04	0.02	0.02
query40	0.12	0.08	0.07
query41	0.08	0.03	0.02
query42	0.03	0.02	0.03
query43	0.03	0.03	0.03
Total cold run time: 90.67 s
Total hot run time: 14.55 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 63.26% (29626/46831)
Line Coverage 48.19% (309640/642474)
Region Coverage 43.72% (249247/570154)
Branch Coverage 45.31% (116040/256087)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 80.00% (4/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.31% (34615/45359)
Line Coverage 61.27% (389133/635141)
Region Coverage 57.40% (325977/567909)
Branch Coverage 58.28% (148807/255339)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 80.00% (4/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.39% (34649/45361)
Line Coverage 61.32% (389511/635186)
Region Coverage 57.47% (326379/567953)
Branch Coverage 58.33% (148950/255351)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 80.00% (4/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.39% (34650/45361)
Line Coverage 61.30% (389400/635186)
Region Coverage 57.46% (326318/567953)
Branch Coverage 58.32% (148931/255351)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 80.00% (4/5) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.39% (34650/45361)
Line Coverage 61.31% (389414/635186)
Region Coverage 57.49% (326513/567953)
Branch Coverage 58.33% (148948/255351)

@Mryange

Mryange commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes: the homogeneous exact-head behavior is internally consistent, but the ordering change silently accepts semantically incompatible old partial and persisted aggregate states. I left one inline P1 comment with a concrete information-loss scenario.

Review status: complete for b46c17aad34cac4b4f5043127cbf7c9151854e3d after two rounds. Both normal Round 2 reviewers and the dedicated risk reviewer returned NO_NEW_VALUABLE_FINDINGS; every candidate was accepted, deduplicated, or dismissed.

Critical checkpoint conclusions:

  • Goal and correctness: hint 1 makes homogeneous complex min/max and ARRAY-key min_by/max_by use the same nested-NULL-greatest policy as generic complex comparison operators. The direct, batch, merge, and window paths agree within one build, but the PR does not fully accomplish the goal across old partial/persisted states because both old and new builds identify the policy as execution version 13.
  • Scope and clarity: the source change is small and focused. The missing compatibility boundary is the only accepted code issue.
  • Concurrency: no shared mutable state, locks, atomics, or new thread entry points are introduced. Distributed partial aggregation is relevant to the compatibility issue, not to thread safety.
  • Lifecycle and persistence: ownership/reset/serialization layout of the one-value complex state is unchanged. Persisted *_state values retain only the old winner, and the absent function-version mapping causes them to be admitted under the new policy; this is the blocking issue.
  • Configuration and FE/BE propagation: no configuration or transmitted variable is added. The existing FE-supplied BE execution version remains 13 in both base and head, so it cannot select a consistent old/new policy during rolling operation.
  • Parallel and special paths: unary ARRAY/MAP/STRUCT min/max, ARRAY-key *_by, add, optimized batch, merge, serialization, and incremental-window equality were traced. Outer NULL arguments are correctly skipped by the nullable wrapper; NULL elements inside a non-NULL array are correctly compared. Numeric NaN ordering is unchanged.
  • Error, memory, and compatibility handling: no ignored status, new exception boundary, allocation, COW mutation, or memory-accounting issue was found. Compatibility handling is insufficient as described inline.
  • Tests and results: every changed exact-head expected result was independently derived and is deterministic, including id=5 max_by(arr, weight) = [1, null, 3, 4]. P0 regression, BE UT, FE UT, formatter, and other relevant checks are green CI evidence. Per the review prompt, I ran no build or test, so this review is static plus CI evidence; mixed-version/persisted-state coverage is still required for the accepted issue.
  • Observability, transactions, and data writes: no new logging/metrics need was identified and ordinary transaction visibility is untouched. The only persistence impact is aggregate-state semantic compatibility.
  • Performance: the comparator constant does not add copies, scans, allocations, or lock work; no new performance issue was found.
  • Repository standards: the PR title is conforming and code-format checks are green. The intermediate upd case commit and unchecked PR checklist should be cleaned up before merge, but they are process metadata rather than an additional source defect.

Existing review context and user focus: no additional user focus was provided. The exact head resolves the historical NULL-key expected-output thread. The earlier line-619 contract concern was not duplicated: the code and linked documentation update both define nested ARRAY NULL elements as greater, while the new compatibility finding is a distinct mixed-version/persisted-state failure at the state-merge boundary.


bool change_if_less(const Self& to, Arena& arena) {
if (to.has() && (!has() || column_data->compare_at(0, 0, *to.column_data, -1) == 1)) {
if (to.has() && (!has() || column_data->compare_at(0, 0, *to.column_data, 1) == 1)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P1] Version the semantic change before merging old aggregate states

This overload merges an already-reduced complex state, but the PR reverses the order used to choose that sole state without creating a compatibility boundary. Both the base and head still advertise BE exec version 13. For example, an old v13 worker computing max over [1, NULL] and [1, 5] serializes only [1, 5]; under this PR v13 max should return [1, NULL], and a new BE merging the old state cannot recover the discarded row. Stored max_state/min_state values (and ARRAY-key *_by states) are likewise accepted because these functions have no compatibility-map entry. Please version/select the old policy for old states, or reject and require rebuilding them, and cover mixed/persisted merges.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

这个过去就是错的,fix不考虑兼容了

@Mryange
Mryange dismissed github-actions[bot]’s stale review September 15, 2026 07:00

fix就不考虑兼容了。

@Mryange
Mryange merged commit 96d0ac6 into apache:master Sep 15, 2026
38 checks passed
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

github-actions Bot pushed a commit that referenced this pull request Sep 23, 2026
Problem Summary: Complex-type `min`, `max`, `min_by`, and `max_by` used
a NULL ordering direction different from ordinary SQL array comparisons.
This could select inconsistent results for arrays containing NULL
elements. The aggregate comparison direction is aligned with SQL array
ordering, and regression expectations are updated.


apache/doris-website#4121

### Release note

Complex-type aggregate ordering now follows SQL array NULL ordering.

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [ ] 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 <!-- Add your reason?  -->

- Behavior changed:
    - [ ] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
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/4.1.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants