Skip to content

[fix](be) Honor check_overflow_for_decimal for DecimalV3 SUM/AVG - #69595

Open
shiliang wants to merge 7 commits into
apache:masterfrom
shiliang:fix-decimal-sum-avg-overflow-precision
Open

shiliang wants to merge 7 commits into
apache:masterfrom
shiliang:fix-decimal-sum-avg-overflow-precision

Conversation

@shiliang

@shiliang shiliang commented Oct 26, 2026 •

Copy link
Copy Markdown

What problem does this PR solve?

Issue Number: close #68123

Related PR: None

Problem Summary:

With check_overflow_for_decimal=true (default), scalar Decimal arithmetic already reports [E-255] Arithmetic overflow, but query-side SUM / AVG still used unchecked += and could return a silently wrong value.

Reproduction (from #68123), two rows of DECIMAL(38,0) holding 10^38 - 1:

expression before this PR
a + a / a * 2 errors — Arithmetic overflow (correct)
SUM(a) returns a wrong wrapped / out-of-precision value, no error
AVG(a) returns a wrong average built from the wrapped total

There are two silent failure regimes for SUM:

  1. Exceed Decimal precision but still fit in int128 (e.g. total first exceeds 10^38 - 1): result can look positive and plausible (e.g. about one tenth of the truth), with nothing in the log saying it is wrong.
  2. Exceed int128 max: result wraps to a negative number.

Root cause in BE:

  • Query aggregation creates functions via AggFnEvaluator, but never injected RuntimeState::check_overflow_for_decimal().
  • AggregateFunctionSum / Avg accumulated with unchecked add; even after adding add_overflow, a value such as (10^38-1) + 1 still fits in int128 (~1.7e38) and was accepted unless we also check Decimal precision (get_max_digits_number(max_precision())), same as scalar binary_arithmetic.

How it was fixed:

  1. Add IAggregateFunction::set_check_overflow_for_decimal(); AggFnEvaluator::prepare sets it from RuntimeState. Wrapper aggregations (null / distinct / sort / foreach / map / agg_state combine|merge|union) forward the flag to the nested function.
  2. DecimalV3 SUM / AVG: on the checked path, use common::add_overflow / sub_overflow (and AVG finalize mul_overflow for sum * scale_multiplier), then reject results outside Decimal precision.
  3. Storage-created aggregations (sum_load / sum_reader for AGGREGATE KEY import / compaction / read merge) do not go through AggFnEvaluator and keep historical wraparound — changing that would alter persisted pre-aggregate semantics and is out of scope for this PR (same limitation called out in [Bug] SUM() over DECIMAL silently returns a wrong value on overflow, while check_overflow_for_decimal errors on the same overflow in binary arithmetic #68123 for on-disk AGGREGATE KEY).
  4. Tests: BE UT AggDecimalOverflowTest; regression test_decimalv3_sum_avg_overflow (plain / group by / window / distinct / nullable; enable_decimal256=true still succeeds for the same inputs).

Release note

When check_overflow_for_decimal is enabled (default), DecimalV3 query-side SUM / AVG (including window and SUM(DISTINCT) / AVG(DISTINCT)) now raise Arithmetic overflow instead of returning a wrapped or out-of-precision value. Set check_overflow_for_decimal=false to keep the old wraparound behavior. AGGREGATE KEY storage pre-aggregation (sum_load / sum_reader) is unchanged.

Check List (For Author)

  • Test

    • Regression test (regression-test/suites/datatype_p0/decimalv3/test_decimalv3_sum_avg_overflow.groovy)
    • Unit Test (be/test/exprs/aggregate/agg_decimal_overflow_test.cpp)
    • Covered: overflow on add/merge; AVG finalize scale multiply; precision overflow (10^38-1+1); check-off wrap; window / distinct / nullable; enable_decimal256=true path
  • Behavior changed:

    • Yes.
      • Before: Query SUM/AVG on overflowing DecimalV3 silently returned wrong values while a+a / a*2 already errored under the same session flag.
      • After: Query SUM/AVG honor check_overflow_for_decimal and error like scalar Decimal ops; flag false restores wraparound.
      • Impact: Default (true) makes overflowing aggregates fail fast instead of returning plausible wrong numbers. Workloads that relied on silent wrap must set check_overflow_for_decimal=false or use enable_decimal256=true for a wider intermediate type. Storage AGGREGATE KEY SUM columns still wrap on write as before.
  • Does this need documentation?

    • No

shiliang and others added 2 commits September 28, 2026 16:12
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: With check_overflow_for_decimal=true, scalar Decimal
addition raises Arithmetic overflow, but query-side SUM/AVG still used
unchecked += and silently wrapped. Inject RuntimeState overflow policy
into query aggregate functions and use checked add/sub/merge (and AVG
finalize scale multiply) for DecimalV3; storage sum_load/sum_reader keep
wraparound.

### Release note

DecimalV3 SUM/AVG now honor check_overflow_for_decimal and report
Arithmetic overflow instead of wrapping when the flag is enabled.

### Check List (For Author)

- Test: Unit Test / Regression test
 - BE UT AggDecimalOverflowTest; regression
   test_decimalv3_sum_avg_overflow
- Behavior changed: Yes — overflowing DecimalV3 SUM/AVG fail when
  check_overflow_for_decimal=true (default); set false to keep old wrap
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Query-side SUM only used int128 add_overflow. For Decimal(38,0), 10^38-1+1 still fits in int128 (~1.7e38) so no error was raised and a dirty out-of-precision value was returned. Align with scalar Decimal arithmetic by also rejecting results beyond get_max_digits_number(max_precision()) in SUM add/sub and AVG add/sub/finalize.

### Release note

DecimalV3 SUM/AVG with check_overflow_for_decimal=true now fail when the result exceeds Decimal precision, not only when native integer addition overflows.

### Check List (For Author)

- Test: Unit Test
 - AggDecimalOverflowTest already covers max+1 precision overflow for SUM
- Behavior changed: Yes — overflowing past Decimal precision now errors when check is on
- Does this need documentation: No

Co-authored-by: Cursor <cursoragent@cursor.com>
@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?

@shiliang shiliang changed the title [fix](be) Check DecimalV3 SUM/AVG overflow on query path [fix](be) Honor check_overflow_for_decimal for DecimalV3 SUM/AVG Oct 26, 2026
@shiliang

Copy link
Copy Markdown
Author

run buildall

### What problem does this PR solve?

Issue Number: close apache#68123

Related PR: apache#69595

Problem Summary: BE UT failed to compile because EXPECT_NE on Decimal128V3 is incompatible with C++20/gtest (operator== returns auto, not bool). Compare .value instead.

### Release note

None

### Check List (For Author)

- Test: No need to test (test compile fix only)
- Behavior changed: No
- Does this need documentation: No

Co-authored-by: Cursor <cursoragent@cursor.com>
@shiliang

Copy link
Copy Markdown
Author

run beut

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17644	5221	5054	5054
q2	2113	351	252	252
q3	10212	1386	835	835
q4	4678	470	347	347
q5	7437	800	548	548
q6	183	186	154	154
q7	758	810	601	601
q8	9252	1374	1088	1088
q9	5498	4216	4193	4193
q10	6822	1288	1046	1046
q11	421	248	233	233
q12	632	401	279	279
q13	18142	3663	3061	3061
q14	277	275	252	252
q15	q16	730	711	669	669
q17	1202	749	579	579
q18	7077	6272	6179	6179
q19	1133	955	608	608
q20	392	338	222	222
q21	5929	2391	2424	2391
q22	386	320	277	277
Total cold run time: 100918 ms
Total hot run time: 28868 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	6023	5967	6251	5967
q2	738	620	577	577
q3	5790	5933	5364	5364
q4	2016	2204	1549	1549
q5	5685	5783	5628	5628
q6	239	190	144	144
q7	2324	2007	1825	1825
q8	2995	2667	2645	2645
q9	7892	7531	7582	7531
q10	3630	3688	3182	3182
q11	582	420	378	378
q12	668	686	503	503
q13	3278	3628	3028	3028
q14	292	286	273	273
q15	q16	673	700	624	624
q17	8040	7233	7104	7104
q18	12976	12224	12959	12224
q19	898	771	793	771
q20	2152	2128	1911	1911
q21	5558	4592	4733	4592
q22	514	494	424	424
Total cold run time: 72963 ms
Total hot run time: 66244 ms

@hello-stephen

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

query5	4309	582	449	449
query6	430	205	185	185
query7	4793	447	220	220
query8	323	163	154	154
query9	8767	3158	3165	3158
query10	502	313	268	268
query11	6064	3859	3554	3554
query12	143	94	88	88
query13	1244	429	337	337
query14	6114	3947	3638	3638
query14_1	3362	3401	3398	3398
query15	208	202	182	182
query16	938	465	461	461
query17	867	666	544	544
query18	2431	434	317	317
query19	209	167	141	141
query20	87	90	82	82
query21	213	127	109	109
query22	12947	12942	12819	12819
query23	13463	12921	12593	12593
query23_1	12614	12613	12705	12613
query24	7358	819	464	464
query24_1	477	475	477	475
query25	538	424	363	363
query26	1254	263	140	140
query27	2762	441	274	274
query28	4624	1965	1981	1965
query29	1559	604	464	464
query30	302	220	188	188
query31	1018	926	817	817
query32	165	94	90	90
query33	525	308	251	251
query34	904	841	492	492
query35	737	770	641	641
query36	899	913	829	829
query37	118	101	86	86
query38	1781	1743	1649	1649
query39	788	795	742	742
query39_1	726	735	740	735
query40	224	117	97	97
query41	76	71	71	71
query42	88	84	85	84
query43	340	362	313	313
query44	1299	711	696	696
query45	179	192	172	172
query46	843	1002	567	567
query47	2788	2869	2763	2763
query48	291	300	213	213
query49	577	391	279	279
query50	661	271	201	201
query51	10597	10482	10622	10482
query52	78	78	71	71
query53	183	206	147	147
query54	251	185	178	178
query55	71	65	65	65
query56	242	216	211	211
query57	1618	1593	1561	1561
query58	273	265	245	245
query59	2272	2264	2149	2149
query60	285	253	224	224
query61	151	147	148	147
query62	390	329	280	280
query63	181	162	156	156
query64	2780	944	772	772
query65	3353	3285	3279	3279
query66	1790	425	296	296
query67	20122	20258	20111	20111
query68	2927	1007	613	613
query69	376	295	253	253
query70	923	868	810	810
query71	315	239	209	209
query72	2695	2587	2316	2316
query73	507	531	292	292
query74	4648	4524	4355	4355
query75	2350	2306	1917	1917
query76	2311	1009	609	609
query77	355	401	267	267
query78	9830	9753	9155	9155
query79	959	906	516	516
query80	748	411	332	332
query81	556	318	266	266
query82	679	142	104	104
query83	282	200	197	197
query84	305	127	99	99
query85	961	430	370	370
query86	358	246	244	244
query87	1991	1922	1791	1791
query88	3615	2682	2666	2666
query89	325	272	244	244
query90	1799	168	165	165
query91	164	155	135	135
query92	99	87	85	85
query93	992	1000	599	599
query94	509	294	261	261
query95	581	322	380	322
query96	669	480	231	231
query97	2449	2460	2365	2365
query98	152	150	146	146
query99	778	757	657	657
Total cold run time: 234521 ms
Total hot run time: 151737 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.10	0.05	0.05
query3	0.26	0.09	0.09
query4	1.61	0.09	0.10
query5	0.23	0.24	0.24
query6	1.18	0.68	0.68
query7	0.03	0.01	0.00
query8	0.05	0.04	0.04
query9	0.41	0.36	0.36
query10	0.57	0.57	0.59
query11	0.19	0.14	0.15
query12	0.18	0.14	0.14
query13	0.49	0.48	0.48
query14	1.04	1.02	1.01
query15	0.62	0.62	0.60
query16	0.34	0.34	0.36
query17	1.16	1.10	1.15
query18	0.19	0.18	0.19
query19	2.06	2.03	1.93
query20	0.02	0.01	0.01
query21	15.42	0.18	0.14
query22	4.99	0.06	0.05
query23	16.27	0.33	0.13
query24	3.11	0.66	0.36
query25	0.10	0.05	0.04
query26	0.83	0.22	0.16
query27	0.05	0.03	0.05
query28	3.01	0.73	0.37
query29	12.48	4.22	3.25
query30	0.28	0.13	0.10
query31	2.77	0.57	0.32
query32	3.22	0.60	0.50
query33	3.14	3.23	3.16
query34	15.22	4.00	3.38
query35	3.33	3.29	3.34
query36	0.59	0.49	0.41
query37	0.09	0.06	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.04
query40	0.18	0.15	0.14
query41	0.08	0.03	0.03
query42	0.04	0.04	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.07 s
Total hot run time: 24.11 s

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	be/src/exprs/aggregate/aggregate_function_avg.h
#	be/src/exprs/aggregate/aggregate_function_sum.h
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17614	5128	5205	5128
q2	2108	318	288	288
q3	10210	1352	837	837
q4	4671	473	345	345
q5	7440	815	534	534
q6	179	178	150	150
q7	755	803	598	598
q8	9287	1341	1084	1084
q9	5535	4218	4190	4190
q10	6804	1279	1005	1005
q11	423	247	222	222
q12	634	396	274	274
q13	18091	3601	3028	3028
q14	275	264	247	247
q15	q16	723	721	659	659
q17	1195	735	572	572
q18	7015	6229	6183	6183
q19	1096	963	618	618
q20	373	343	223	223
q21	5060	2413	2463	2413
q22	387	307	272	272
Total cold run time: 99875 ms
Total hot run time: 28870 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5975	5955	5951	5951
q2	723	588	587	587
q3	5622	5874	5556	5556
q4	2011	2191	1565	1565
q5	5789	5775	5644	5644
q6	240	186	147	147
q7	2228	2007	1739	1739
q8	2864	2513	2505	2505
q9	7604	7498	7496	7496
q10	3636	3573	3185	3185
q11	588	426	383	383
q12	666	681	512	512
q13	3396	3697	3083	3083
q14	285	285	275	275
q15	q16	682	677	606	606
q17	8055	7388	7096	7096
q18	13082	12323	12968	12323
q19	909	796	810	796
q20	2148	2141	1931	1931
q21	5725	4624	4739	4624
q22	511	461	394	394
Total cold run time: 72739 ms
Total hot run time: 66398 ms

### What problem does this PR solve?

Issue Number: close apache#68123

Related PR: apache#69595

Problem Summary: P0 failed with Missing outputFile for test_decimalv3_sum_avg_overflow because the suite uses qt_/order_qt_ tags without a committed .out.

### Release note

None

### Check List (For Author)

- Test: No need to test (add expected .out for existing suite)
- Behavior changed: No
- Does this need documentation: No

Co-authored-by: Cursor <cursoragent@cursor.com>
@shiliang

Copy link
Copy Markdown
Author

run p0

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17593	5084	5339	5084
q2	2097	324	270	270
q3	10242	1408	816	816
q4	4675	464	352	352
q5	7452	816	559	559
q6	185	184	152	152
q7	756	816	597	597
q8	9254	1392	1128	1128
q9	5608	4237	4234	4234
q10	6838	1281	1050	1050
q11	440	258	229	229
q12	641	399	303	303
q13	18088	3874	3052	3052
q14	288	273	257	257
q15	q16	719	725	643	643
q17	1192	753	570	570
q18	7032	6214	6179	6179
q19	1246	957	595	595
q20	379	333	226	226
q21	5896	2414	2475	2414
q22	391	344	278	278
Total cold run time: 101012 ms
Total hot run time: 28988 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	6228	5940	6207	5940
q2	695	600	562	562
q3	5661	5977	5429	5429
q4	2032	2183	1570	1570
q5	5950	5628	5754	5628
q6	235	185	144	144
q7	2256	1979	1779	1779
q8	3007	2638	2670	2638
q9	7636	7510	7541	7510
q10	3671	3581	3185	3185
q11	579	405	378	378
q12	661	685	511	511
q13	3326	3591	3036	3036
q14	296	302	268	268
q15	q16	659	681	634	634
q17	8024	7331	7106	7106
q18	13003	12233	12910	12233
q19	934	795	790	790
q20	2138	2156	1908	1908
q21	5717	4695	4714	4695
q22	492	444	398	398
Total cold run time: 73200 ms
Total hot run time: 66342 ms

@hello-stephen

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

query5	4313	575	459	459
query6	433	210	200	200
query7	4818	452	231	231
query8	323	164	163	163
query9	8808	3163	3150	3150
query10	476	326	269	269
query11	6003	3859	3583	3583
query12	164	95	88	88
query13	1268	497	325	325
query14	6076	3923	3628	3628
query14_1	3409	3378	3410	3378
query15	208	195	202	195
query16	934	435	388	388
query17	841	638	516	516
query18	2432	409	303	303
query19	191	168	133	133
query20	83	81	81	81
query21	206	125	105	105
query22	12926	13055	12801	12801
query23	13624	12892	12503	12503
query23_1	12604	12616	12679	12616
query24	7347	805	468	468
query24_1	480	465	473	465
query25	514	428	338	338
query26	1258	259	133	133
query27	2776	443	285	285
query28	4617	1982	1977	1977
query29	1521	579	424	424
query30	299	216	185	185
query31	1009	934	815	815
query32	152	94	95	94
query33	513	302	238	238
query34	905	849	507	507
query35	732	767	649	649
query36	918	923	902	902
query37	144	103	88	88
query38	1758	1724	1663	1663
query39	789	793	746	746
query39_1	749	732	732	732
query40	221	120	100	100
query41	74	70	69	69
query42	89	85	87	85
query43	352	366	313	313
query44	1292	699	698	698
query45	183	185	166	166
query46	845	968	561	561
query47	2745	3048	2754	2754
query48	322	318	233	233
query49	588	417	319	319
query50	684	290	210	210
query51	10657	10747	10522	10522
query52	80	82	72	72
query53	187	209	152	152
query54	252	204	211	204
query55	73	74	67	67
query56	247	226	230	226
query57	1667	1626	1542	1542
query58	300	275	272	272
query59	2254	2323	2129	2129
query60	302	273	239	239
query61	174	167	164	164
query62	403	338	283	283
query63	192	160	166	160
query64	2863	1070	771	771
query65	3348	3266	3306	3266
query66	1774	433	310	310
query67	20485	20301	20199	20199
query68	3353	1002	612	612
query69	407	301	249	249
query70	910	834	845	834
query71	300	250	205	205
query72	2883	2698	2311	2311
query73	528	521	302	302
query74	4637	4535	4358	4358
query75	2331	2273	1910	1910
query76	2424	1002	570	570
query77	351	377	261	261
query78	9634	9748	9210	9210
query79	964	832	533	533
query80	1291	429	349	349
query81	598	320	270	270
query82	755	141	118	118
query83	301	194	184	184
query84	317	122	98	98
query85	870	430	390	390
query86	392	250	238	238
query87	2016	1947	1826	1826
query88	3714	2693	2696	2693
query89	332	284	245	245
query90	1967	169	162	162
query91	163	160	137	137
query92	102	84	89	84
query93	1046	989	581	581
query94	645	302	261	261
query95	584	394	299	299
query96	668	493	239	239
query97	2432	2453	2296	2296
query98	156	157	148	148
query99	770	760	656	656
Total cold run time: 236921 ms
Total hot run time: 151914 ms

@hello-stephen

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

query1	0.00	0.01	0.01
query2	0.09	0.06	0.05
query3	0.27	0.09	0.09
query4	1.62	0.10	0.11
query5	0.23	0.24	0.24
query6	1.17	0.69	0.68
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.41	0.35	0.35
query10	0.57	0.58	0.58
query11	0.20	0.16	0.15
query12	0.20	0.14	0.15
query13	0.49	0.50	0.50
query14	1.06	1.05	1.01
query15	0.62	0.61	0.62
query16	0.35	0.34	0.35
query17	1.17	1.13	1.14
query18	0.20	0.21	0.20
query19	2.10	1.94	2.02
query20	0.02	0.02	0.01
query21	15.46	0.20	0.14
query22	4.80	0.06	0.05
query23	16.26	0.34	0.12
query24	2.81	0.54	0.37
query25	0.11	0.07	0.04
query26	0.84	0.21	0.16
query27	0.06	0.06	0.05
query28	4.10	0.88	0.40
query29	12.52	4.09	3.23
query30	0.30	0.14	0.12
query31	2.78	0.55	0.32
query32	3.23	0.60	0.50
query33	3.29	3.19	3.18
query34	15.49	3.99	3.42
query35	3.36	3.36	3.33
query36	0.55	0.45	0.45
query37	0.09	0.07	0.06
query38	0.06	0.04	0.04
query39	0.04	0.04	0.03
query40	0.17	0.15	0.14
query41	0.08	0.03	0.04
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 97.35 s
Total hot run time: 24.43 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 50.89% (86/169) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 66.99% (32299/48217)
Line Coverage 51.82% (341708/659391)
Region Coverage 47.22% (277321/587241)
Branch Coverage 48.93% (130822/267370)

### What problem does this PR solve?

Issue Number: close apache#68123

Related PR: apache#69595

Problem Summary: Formatting-only: fold add_sum/sub_sum args to clang-format-16 style; sort arena.h include; put max_int128 init on one line. No logic change.

### Release note

None

### Check List (For Author)

- Test: No need to test (format only)
- Behavior changed: No
- Does this need documentation: No

Co-authored-by: Cursor <cursoragent@cursor.com>
@shiliang

Copy link
Copy Markdown
Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17596	5214	5100	5100
q2	2140	363	248	248
q3	10578	1443	838	838
q4	4724	466	336	336
q5	7964	814	530	530
q6	225	186	155	155
q7	770	819	620	620
q8	10354	1360	1150	1150
q9	5684	4251	4213	4213
q10	6890	1301	1036	1036
q11	446	254	222	222
q12	698	400	290	290
q13	18212	3764	3059	3059
q14	287	274	245	245
q15	q16	767	716	668	668
q17	2838	765	585	585
q18	7099	6252	6162	6162
q19	1313	969	604	604
q20	397	357	233	233
q21	5830	2216	2337	2216
q22	353	302	259	259
Total cold run time: 105165 ms
Total hot run time: 28769 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5779	5680	5645	5645
q2	717	565	553	553
q3	5240	5530	5013	5013
q4	2011	2150	1592	1592
q5	5247	5190	5164	5164
q6	245	189	144	144
q7	2074	1865	1687	1687
q8	2959	2565	2577	2565
q9	7578	7505	7494	7494
q10	3656	3584	3156	3156
q11	603	458	396	396
q12	670	671	516	516
q13	3387	3649	3073	3073
q14	295	320	272	272
q15	q16	666	690	629	629
q17	8026	7397	7146	7146
q18	12986	12301	12937	12301
q19	908	828	818	818
q20	2148	2126	1937	1937
q21	5744	4686	4769	4686
q22	512	441	421	421
Total cold run time: 71451 ms
Total hot run time: 65208 ms

@hello-stephen

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

query5	4311	578	455	455
query6	429	206	193	193
query7	4791	453	231	231
query8	331	175	160	160
query9	8792	3313	3295	3295
query10	479	316	258	258
query11	6032	3863	3594	3594
query12	145	91	85	85
query13	1255	460	348	348
query14	6164	3977	3695	3695
query14_1	3445	3466	3445	3445
query15	213	199	178	178
query16	960	439	397	397
query17	862	677	544	544
query18	2438	436	313	313
query19	204	167	138	138
query20	87	87	85	85
query21	214	128	116	116
query22	12995	13192	12881	12881
query23	13641	12981	12557	12557
query23_1	12611	12650	12718	12650
query24	7347	823	493	493
query24_1	490	505	504	504
query25	549	427	375	375
query26	1272	261	148	148
query27	2764	451	282	282
query28	4626	2084	2078	2078
query29	1556	604	461	461
query30	300	224	195	195
query31	1022	940	817	817
query32	147	97	102	97
query33	561	312	255	255
query34	908	866	520	520
query35	737	747	665	665
query36	871	865	810	810
query37	121	101	91	91
query38	1775	1744	1661	1661
query39	795	788	745	745
query39_1	739	732	746	732
query40	225	131	100	100
query41	76	71	73	71
query42	91	86	86	86
query43	345	370	313	313
query44	1327	717	715	715
query45	196	188	170	170
query46	907	964	566	566
query47	2928	2960	2958	2958
query48	306	340	220	220
query49	569	394	292	292
query50	677	273	216	216
query51	10425	10249	10203	10203
query52	80	80	71	71
query53	196	205	152	152
query54	257	189	183	183
query55	73	67	64	64
query56	230	213	203	203
query57	1703	1626	1587	1587
query58	288	272	270	270
query59	2247	2256	2064	2064
query60	280	230	232	230
query61	151	148	151	148
query62	396	327	281	281
query63	189	158	159	158
query64	2728	943	787	787
query65	3334	3311	3288	3288
query66	1777	416	309	309
query67	20419	20263	20222	20222
query68	3222	1031	622	622
query69	391	288	260	260
query70	920	845	854	845
query71	306	247	223	223
query72	2904	2645	2320	2320
query73	528	534	299	299
query74	4702	4535	4380	4380
query75	2358	2270	1938	1938
query76	2412	1019	594	594
query77	385	383	275	275
query78	10018	9840	9232	9232
query79	1011	855	528	528
query80	1260	439	353	353
query81	597	335	274	274
query82	605	133	104	104
query83	319	203	183	183
query84	310	129	105	105
query85	878	418	368	368
query86	403	248	238	238
query87	1987	1948	1824	1824
query88	3832	2781	2731	2731
query89	335	283	246	246
query90	1922	178	176	176
query91	158	152	134	134
query92	104	89	93	89
query93	1023	1014	578	578
query94	645	322	284	284
query95	577	401	303	303
query96	673	490	242	242
query97	2444	2475	2291	2291
query98	163	153	151	151
query99	783	758	646	646
Total cold run time: 237365 ms
Total hot run time: 152756 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.10	0.06	0.06
query3	0.26	0.09	0.08
query4	1.60	0.10	0.10
query5	0.23	0.25	0.26
query6	1.16	0.68	0.68
query7	0.04	0.01	0.00
query8	0.05	0.04	0.04
query9	0.42	0.36	0.36
query10	0.60	0.62	0.61
query11	0.20	0.15	0.14
query12	0.18	0.15	0.15
query13	0.49	0.49	0.52
query14	1.03	1.01	1.01
query15	0.64	0.62	0.62
query16	0.35	0.37	0.36
query17	1.15	1.14	1.14
query18	0.20	0.19	0.20
query19	2.09	1.99	2.00
query20	0.02	0.01	0.02
query21	15.46	0.20	0.13
query22	4.83	0.06	0.05
query23	16.31	0.33	0.12
query24	2.94	0.50	0.40
query25	0.13	0.05	0.06
query26	0.99	0.22	0.15
query27	0.06	0.05	0.03
query28	3.48	0.84	0.39
query29	12.50	4.13	3.23
query30	0.28	0.13	0.10
query31	2.78	0.56	0.32
query32	3.22	0.60	0.51
query33	3.14	3.29	3.14
query34	15.22	4.01	3.40
query35	3.34	3.33	3.32
query36	0.56	0.50	0.43
query37	0.10	0.06	0.07
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.15
query41	0.09	0.03	0.03
query42	0.03	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 96.59 s
Total hot run time: 24.42 s

### What problem does this PR solve?

Issue Number: close apache#68123

Related PR: apache#69595

Problem Summary: P0 failed on sum_wrap because IS NOT NULL returns boolean true, not integer 1. Update the .out expectation.

### Release note

None

### Check List (For Author)

- Test: No need to test (.out expectation fix from CI)
- Behavior changed: No
- Does this need documentation: No

Co-authored-by: Cursor <cursoragent@cursor.com>
@shiliang

Copy link
Copy Markdown
Author

run p0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] SUM() over DECIMAL silently returns a wrong value on overflow, while check_overflow_for_decimal errors on the same overflow in binary arithmetic

2 participants