Skip to content

[fix](eager-agg) Disable bilateral eager aggregation for decimal SUM - #69093

Merged
morrySnow merged 2 commits into
apache:masterfrom
feiniaofeiafei:codex/fix-eager-agg-decimal-scale
Nov 7, 2026
Merged

morrySnow merged 2 commits into
apache:masterfrom
feiniaofeiafei:codex/fix-eager-agg-decimal-scale

Conversation

@feiniaofeiafei

@feiniaofeiafei feiniaofeiafei commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #63690

Problem Summary:

Bilateral eager aggregation can change the result type and scale of a decimal SUM because its compensation uses ordinary decimal multiplication. This can cause an output type mismatch or silently lose precision; for example, a valid result of 0.0000000004 can become 0.000000.

This PR disables bilateral eager aggregation when any aggregate is a DecimalV3 SUM. Single-sided decimal SUM pushdown remains supported.

This causes either:

  • An output type mismatch when an upper projection still expects the original SUM type.
  • Silent precision loss when the reduced-scale result reaches the query output.
    For example, a valid SUM of 0.0000000004 could become 0.000000.

This Pr fix this problem:

  • Introduce an internal decimal multiplication expression that preserves the SUM result type.
  • Cast the compensation input to the original SUM type when necessary.
  • Preserve multiplication statistics estimation and prevent arithmetic simplification or FE constant folding from reverting to ordinary decimal multiplication semantics.
  • Reuse the existing BE multiplication and overflow checks. No BE changes are required.

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

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

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17616	5687	5555	5555
q2	2076	307	261	261
q3	10260	1434	860	860
q4	4684	483	349	349
q5	7441	808	534	534
q6	189	186	161	161
q7	768	809	604	604
q8	9246	1378	1087	1087
q9	5490	4340	4275	4275
q10	6824	1307	1013	1013
q11	444	266	243	243
q12	638	402	281	281
q13	18119	3645	3059	3059
q14	275	276	244	244
q15	q16	741	729	679	679
q17	1214	754	575	575
q18	7182	6271	6203	6203
q19	1250	964	633	633
q20	389	357	234	234
q21	5258	2286	2418	2286
q22	377	316	270	270
Total cold run time: 100481 ms
Total hot run time: 29406 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	6190	6154	6162	6154
q2	697	587	573	573
q3	5254	5721	4936	4936
q4	2040	2168	1601	1601
q5	5290	5568	5986	5568
q6	263	202	162	162
q7	2398	2146	1897	1897
q8	3373	2985	2835	2835
q9	8126	8092	8142	8092
q10	3780	3718	3368	3368
q11	688	465	406	406
q12	678	711	513	513
q13	3600	3944	3276	3276
q14	317	323	295	295
q15	q16	748	719	651	651
q17	8393	7628	7427	7427
q18	13140	12387	13114	12387
q19	923	797	802	797
q20	2188	2151	1947	1947
q21	5971	4766	4982	4766
q22	503	460	394	394
Total cold run time: 74560 ms
Total hot run time: 68045 ms

@hello-stephen

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

query5	4294	599	441	441
query6	424	203	203	203
query7	4806	447	235	235
query8	321	167	153	153
query9	8776	4042	4023	4023
query10	457	331	266	266
query11	5918	3774	3513	3513
query12	146	91	88	88
query13	1251	458	327	327
query14	6180	4069	3886	3886
query14_1	3559	3549	3585	3549
query15	215	195	182	182
query16	939	440	421	421
query17	862	662	547	547
query18	2426	418	321	321
query19	195	172	138	138
query20	90	84	83	83
query21	209	136	121	121
query22	12993	13108	12868	12868
query23	13540	12879	12797	12797
query23_1	12523	12679	12678	12678
query24	7125	817	488	488
query24_1	476	488	474	474
query25	544	424	366	366
query26	1275	262	147	147
query27	2771	441	273	273
query28	4617	1960	1963	1960
query29	1589	594	452	452
query30	297	224	191	191
query31	1016	928	831	831
query32	152	107	93	93
query33	518	308	243	243
query34	911	838	523	523
query35	755	798	646	646
query36	812	824	737	737
query37	131	97	92	92
query38	1801	1742	1701	1701
query39	795	813	751	751
query39_1	757	738	740	738
query40	213	113	97	97
query41	65	64	66	64
query42	86	86	84	84
query43	365	393	336	336
query44	1331	705	696	696
query45	185	180	160	160
query46	841	948	575	575
query47	2996	2984	2952	2952
query48	310	303	211	211
query49	577	398	316	316
query50	687	272	208	208
query51	10705	10441	10480	10441
query52	78	79	69	69
query53	189	205	150	150
query54	250	200	204	200
query55	77	68	74	68
query56	227	241	208	208
query57	1603	1581	1563	1563
query58	292	267	287	267
query59	2093	2168	1967	1967
query60	281	239	221	221
query61	147	141	136	136
query62	394	337	292	292
query63	206	163	167	163
query64	2745	920	791	791
query65	3321	3264	3250	3250
query66	1775	425	345	345
query67	20646	20178	19795	19795
query68	2971	1003	619	619
query69	385	307	253	253
query70	867	800	754	754
query71	288	233	201	201
query72	2793	2622	2354	2354
query73	504	534	303	303
query74	4597	4431	4302	4302
query75	2334	2321	1944	1944
query76	2287	1025	613	613
query77	355	402	280	280
query78	9943	9728	9211	9211
query79	1023	840	520	520
query80	535	432	336	336
query81	544	318	275	275
query82	576	137	113	113
query83	296	199	185	185
query84	315	124	101	101
query85	821	427	377	377
query86	320	247	231	231
query87	2017	1951	1806	1806
query88	3619	2716	2676	2676
query89	350	300	267	267
query90	1908	179	183	179
query91	162	149	126	126
query92	99	87	86	86
query93	1024	1006	587	587
query94	462	291	305	291
query95	618	361	391	361
query96	671	513	234	234
query97	2455	2450	2315	2315
query98	165	153	146	146
query99	773	765	645	645
Total cold run time: 235027 ms
Total hot run time: 153196 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.10	0.04	0.04
query3	0.27	0.12	0.12
query4	1.61	0.13	0.12
query5	0.28	0.24	0.24
query6	1.19	0.68	0.68
query7	0.03	0.01	0.01
query8	0.05	0.04	0.04
query9	0.40	0.35	0.34
query10	0.57	0.58	0.55
query11	0.20	0.14	0.14
query12	0.18	0.14	0.14
query13	0.49	0.51	0.50
query14	1.01	1.03	1.01
query15	0.64	0.59	0.60
query16	0.35	0.35	0.34
query17	1.14	1.15	1.15
query18	0.22	0.20	0.18
query19	2.17	2.00	2.02
query20	0.02	0.01	0.01
query21	15.46	0.25	0.14
query22	4.52	0.06	0.05
query23	16.30	0.32	0.12
query24	3.23	0.62	0.39
query25	0.11	0.06	0.06
query26	1.11	0.25	0.15
query27	0.04	0.03	0.03
query28	1.91	0.60	0.41
query29	12.50	4.14	3.33
query30	0.28	0.14	0.13
query31	2.77	0.56	0.33
query32	3.22	0.62	0.52
query33	3.20	3.15	3.26
query34	15.34	4.02	3.39
query35	3.37	3.34	3.37
query36	0.54	0.45	0.43
query37	0.10	0.07	0.07
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.17	0.14	0.15
query41	0.08	0.03	0.03
query42	0.03	0.02	0.02
query43	0.04	0.03	0.04
Total cold run time: 95.34 s
Total hot run time: 24.52 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 78.57% (11/14) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 66.67% (12/18) 🎉
Increment coverage report
Complete coverage report

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator 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.

Reviewed PR 69093 at exact head 2066895 against base 0027350. The changed eager-aggregation path introduces DecimalMultiplyForSum to preserve a decimal SUM's type while restoring join multiplicity. I traced the FE coercion path, DecimalV3 width/scale behavior, ArithmeticExpr translation, BE decimal multiply dispatch and overflow handling, expression visitor/rewrite consumers, and eager-aggregation count propagation across inner/cross/outer/semi/anti/nested/union paths. I found no concrete correctness defect and therefore have no new inline findings. The Nereids expression legality checkpoint is satisfied because this change adds no checkLegalityBeforeTypeCoercion overload; the FE locking, RPC exception, and visible-version checkpoints are not applicable to these files. There were no user-provided focus points. Live review and inline-comment refresh found no existing P0/P1 inline findings to carry forward. This was a static review only; no builds or tests were run by this invocation. The review is delivered with converged=false because all assigned delegated passes terminated with the same temporary model-capacity error before returning NO_NEW_VALUABLE_FINDINGS; the main-agent changed-file and risk sweep is complete, but delegated unanimity could not be established.

Review did not converge after 3 rounds. This automated review cannot pass the review check.

Three required delegated review passes were launched and recovery attempts were made, but every child process terminated with a model-capacity error before returning a result. The main-agent review and final changed-file/risk sweep are complete with no verified findings, but the contract's all-subagents NO_NEW_VALUABLE_FINDINGS convergence condition is unproven.

englefly
englefly previously approved these changes Nov 2, 2026

@924060929 924060929 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.

Eager aggregation restores join multiplicity by multiplying partial SUM values by opposite-side counts. This PR introduces an internal multiplication expression to preserve the decimal SUM type and avoid scale reduction.

I independently reviewed all six changed files, FE coercion and rewrite consumers, statistics, translation, and the necessary BE multiply/SUM boundary at head 2066895. One blocking P2 remains: enforcing the final SUM range on each compensation product rejects valid queries whose positive and negative contributions cancel in the final aggregate. The added tests do not cover cancellation across distinct join keys. Please preserve the required intermediate range or safely decline that rewrite.

The supplied snapshot records successful P0 Regression, FE UT and compilation, and an approval by englefly on this head. The earlier AI review reported no findings but failed its convergence requirement. These records do not resolve the confirmed functional issue. Review scope is FE plus the relevant FE/BE contract; no builds or tests were run.

Automated FE-focused static review (gpt-6.1-sol, xhigh). No build or tests were run.

@Override
public DecimalV3Type getDataTypeForDecimalV3(DecimalV3Type sumType, DecimalV3Type countType) {
Preconditions.checkArgument(countType.getScale() == 0);
return sumType;

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.

[P2] Preserve intermediate range until the final SUM

With eager_aggregation_mode=1, enable_decimal256=false, check_overflow_for_decimal=true and decimal_overflow_scale=6, consider l(g,k,v DECIMAL(38,18)) containing (G,a,+60000000000000000000) and (G,b,-60000000000000000000), and r(k,w) containing two rows with w=1 for each key. SELECT l.g,SUM(l.v),SUM(r.w) FROM l JOIN [shuffle] r ON l.k=r.k GROUP BY l.g should sum to zero. Returning sumType makes each compensation product ±120000000000000000000 undergo the DECIMAL(38,18) range check in BE multiply.cpp:487, throwing before cancellation in the final aggregate. The products still fit Int128; the merge-base multiplication rescales to DECIMAL(38,6) and this case can complete. Preserve sufficient intermediate range through aggregation, or decline the rewrite when that cannot be guaranteed, and add a cancellation regression. This is a static finding; no tests were run.

morrySnow
morrySnow previously approved these changes Nov 3, 2026
924060929
924060929 previously approved these changes Nov 5, 2026
@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

/review

### What problem does this PR solve?

Related PR: apache#69093

Problem Summary: Bilateral eager aggregation restores join multiplicity with
partial SUM times the opposite-side count. Ordinary decimal multiplication can
reduce scale, while forcing the SUM type can reject intermediate products that
would cancel in the final aggregate. Reject bilateral candidates containing a
DecimalV3 SUM before changing child plans. Keep single-side decimal pushdown and
integer bilateral pushdown, and remove the special decimal multiply expression.

### Release note

Avoid decimal SUM precision loss and premature compensation overflow by skipping
bilateral eager aggregation for DecimalV3 SUM.

### Check List (For Author)

- Test: FE Checkstyle (0 violations); remote build.sh --fe; EagerAggRewriterTest (32 tests passed); decimal_sum_multiplicity and bilateral_eager_agg regression suites passed on the updated dev FE. Regression expectations were generated by the test script using the eager-aggregation-disabled baseline.
- Behavior changed: Yes; decimal SUM no longer supports bilateral eager aggregation
- Does this need documentation: No
@feiniaofeiafei
feiniaofeiafei dismissed stale reviews from 924060929, morrySnow, and englefly via 7c2bc12 November 5, 2026 08:37
@feiniaofeiafei
feiniaofeiafei force-pushed the codex/fix-eager-agg-decimal-scale branch from 2066895 to 7c2bc12 Compare November 5, 2026 08:37
@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator 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.

Reviewed head 7c2bc12dedb2846fc6ca3fc6225d36ac528a18d7. No new actionable findings. The static review converged in round 1: both complete-review agents and the separate decimal-risk agent returned NO_NEW_VALUABLE_FINDINGS; all candidates and risk focuses have evidence-backed dispositions.

The current implementation declines bilateral eager aggregation when a decimal SUM is present. For Aggregate(g; SUM(l.v), SUM(r.w)) -> Inner/CrossJoin(L, R), decideJoinPushSide returns before child contexts, partial aggregates or compensation products are constructed. One-side decimal SUM remains eligible because the untouched opposite branch has no compensation count in the fresh per-aggregate state.

Critical checkpoint conclusions:

  • Goal and correctness: the guard avoids scale reduction and premature range checks from decimal compensation. Added plan assertions and functional cases target both failures; inspected, not executed.
  • Scope and reuse: the production change is one import and a focused guard using the existing conservative exit and SUM type machinery.
  • Concurrency and locks: no new shared state, threads or locks; rewrite state remains local to each aggregate invocation.
  • Lifecycle and initialization: no new resource ownership, cleanup obligations or static initialization dependencies.
  • Configuration: no new options; tests exercise existing eager, decimal256 and decimal-overflow controls.
  • Compatibility: no changed function symbols, storage formats or wire contracts; existing BE aggregate/expression handling is retained.
  • Thrift/protobuf: no definitions changed; cross-branch field-ID checks are inapplicable.
  • Parallel paths: reviewed one-side/bilateral, nested joins, projects, filters, UNION ALL, IF decomposition, DISTINCT, COUNT/MIN/MAX, constants, hints and the broadcast shortcut. Existing outer/semi/anti/mark/asof protections remain. Legacy eager exploration classes are not registered in the production rule set. No bypass substantiated.
  • Conditional checks: the comment explains both scale loss and cancellation overflow. The guard runs before state mutation and cannot be overridden by push hints or statistics.
  • Test coverage: unit cases cover INNER/CROSS joins, aggregate order, swapped sides, COUNT, expression grouping and decimal128/256 types, with positive one-side pushdown controls. Regression cases cover aliases, unaliased output, INSERT OVERWRITE, tiny/negative/NULL values, overflow settings and cancellation.
  • Expected results: all 28 golden blocks and tags checked against exact decimal arithmetic and SQL multiplicity; no incorrect result found. Ordering, pre-drops, table naming and session cleanup follow the existing harness conventions.
  • Observability: the change only declines an optimization; existing explain plans and error reporting suffice.
  • Transactions and persistence: no EditLog, replay, failover or transaction implementation changes.
  • Data writes and atomicity: engine write paths are unchanged; INSERT/OVERWRITE appears only in the regression test.
  • FE-BE variable passing: no new variables or serialization paths; allowed aggregate type/intermediate semantics remain unchanged.
  • Performance: adds a linear aggregate-function check during planning. Bilateral decimal SUM optimization is deliberately disabled for correctness; no separate performance defect established.
  • Other optimizer invariants: rule registration/stage order, ExprIds, nullability, mark-join semantics and physical property derivation are unchanged; the new exit creates no rewrite loop.

Existing thread: P2 comment 4439965509 is addressed at this head. The earlier DecimalMultiplyForSum approach is absent and the unsafe cancellation rewrite is declined; a cancellation regression is included. No duplicate inline comment is needed, and no existing P0/P1 finding remains to carry forward.

User focus: none was supplied; the entire four-file PR was reviewed. No unresolved code candidates or uncovered assigned scope remain. Limits: static inspection only; no builds, tests or runtime validation were run, and actual golden-file generation provenance was not verified.

Review converged after 1 round(s).

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17593	5167	5060	5060
q2	2115	294	246	246
q3	10287	1384	825	825
q4	4673	469	339	339
q5	7437	800	530	530
q6	188	195	156	156
q7	750	796	593	593
q8	9259	1329	1095	1095
q9	5742	4218	4205	4205
q10	6821	1294	1011	1011
q11	424	243	225	225
q12	637	408	282	282
q13	18084	3570	3057	3057
q14	272	277	252	252
q15	q16	700	706	653	653
q17	1179	754	583	583
q18	6967	6175	6121	6121
q19	1116	949	595	595
q20	390	337	225	225
q21	4997	2126	2296	2126
q22	354	302	251	251
Total cold run time: 99985 ms
Total hot run time: 28430 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5619	5628	5626	5626
q2	666	574	523	523
q3	5176	5376	4964	4964
q4	2011	2188	1549	1549
q5	5264	5163	5704	5163
q6	266	213	162	162
q7	2374	2065	1826	1826
q8	3075	2739	2692	2692
q9	8149	8057	7945	7945
q10	3771	3963	3235	3235
q11	618	449	401	401
q12	704	706	528	528
q13	3635	3873	3226	3226
q14	331	322	304	304
q15	q16	697	727	638	638
q17	8354	7153	6861	6861
q18	13040	12252	12954	12252
q19	937	801	778	778
q20	2148	2136	1920	1920
q21	5676	4611	4785	4611
q22	520	463	397	397
Total cold run time: 73031 ms
Total hot run time: 65601 ms

@hello-stephen

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

query5	4345	576	460	460
query6	450	239	188	188
query7	4803	434	255	255
query8	321	165	162	162
query9	8827	3253	3231	3231
query10	483	311	256	256
query11	5999	3867	3589	3589
query12	142	90	87	87
query13	1248	439	329	329
query14	6126	3963	3761	3761
query14_1	3520	3465	3478	3465
query15	214	208	182	182
query16	952	435	420	420
query17	874	635	514	514
query18	2414	412	299	299
query19	192	162	136	136
query20	86	93	82	82
query21	213	133	108	108
query22	13029	13057	12896	12896
query23	13467	12895	12442	12442
query23_1	12535	12581	12515	12515
query24	7210	820	459	459
query24_1	471	480	482	480
query25	507	405	342	342
query26	1001	257	137	137
query27	2750	437	278	278
query28	4604	2021	2011	2011
query29	1395	597	446	446
query30	301	222	185	185
query31	1014	943	825	825
query32	142	93	92	92
query33	516	310	234	234
query34	885	858	500	500
query35	740	766	665	665
query36	816	800	738	738
query37	131	98	82	82
query38	1808	1738	1701	1701
query39	788	785	742	742
query39_1	736	735	743	735
query40	222	122	98	98
query41	73	68	68	68
query42	91	83	86	83
query43	352	361	316	316
query44	1322	714	712	712
query45	179	181	168	168
query46	858	985	576	576
query47	2801	2838	2786	2786
query48	304	313	233	233
query49	566	411	303	303
query50	712	287	229	229
query51	10727	10755	10443	10443
query52	85	81	73	73
query53	196	213	155	155
query54	248	208	197	197
query55	72	71	66	66
query56	260	226	217	217
query57	1654	1679	1582	1582
query58	295	285	260	260
query59	2166	2166	1966	1966
query60	296	259	237	237
query61	174	169	170	169
query62	390	338	286	286
query63	195	165	164	164
query64	2435	1066	866	866
query65	3330	3268	3288	3268
query66	1760	436	299	299
query67	22588	22628	22591	22591
query68	2955	1010	630	630
query69	384	295	254	254
query70	862	800	783	783
query71	297	242	198	198
query72	2721	2605	2209	2209
query73	528	529	309	309
query74	4671	4566	4352	4352
query75	2372	2300	1932	1932
query76	2315	1011	597	597
query77	349	377	281	281
query78	9796	9759	9135	9135
query79	991	915	549	549
query80	766	443	359	359
query81	571	311	263	263
query82	590	140	111	111
query83	288	198	190	190
query84	317	118	103	103
query85	935	442	387	387
query86	365	247	227	227
query87	1999	1943	1806	1806
query88	3825	2787	2781	2781
query89	337	284	243	243
query90	1700	177	175	175
query91	167	161	130	130
query92	102	92	92	92
query93	1003	1007	571	571
query94	504	299	279	279
query95	581	337	324	324
query96	682	515	240	240
query97	2435	2455	2332	2332
query98	163	161	148	148
query99	778	769	664	664
Total cold run time: 236489 ms
Total hot run time: 154499 ms

@hello-stephen

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

query1	0.01	0.00	0.00
query2	0.10	0.04	0.05
query3	0.27	0.09	0.09
query4	1.61	0.11	0.10
query5	0.24	0.25	0.24
query6	1.17	0.68	0.68
query7	0.04	0.01	0.01
query8	0.05	0.04	0.03
query9	0.41	0.35	0.34
query10	0.58	0.58	0.61
query11	0.21	0.14	0.14
query12	0.19	0.14	0.14
query13	0.50	0.49	0.49
query14	1.04	1.02	1.02
query15	0.63	0.60	0.63
query16	0.32	0.36	0.36
query17	1.18	1.20	1.13
query18	0.21	0.19	0.20
query19	2.17	2.08	1.98
query20	0.01	0.01	0.02
query21	15.48	0.20	0.13
query22	4.84	0.05	0.06
query23	16.30	0.33	0.13
query24	2.91	0.48	0.39
query25	0.11	0.06	0.05
query26	1.43	0.22	0.16
query27	0.04	0.03	0.04
query28	3.45	0.78	0.38
query29	12.47	4.17	3.26
query30	0.29	0.13	0.10
query31	2.77	0.56	0.34
query32	3.22	0.60	0.51
query33	3.18	3.22	3.24
query34	15.48	4.05	3.41
query35	3.36	3.37	3.34
query36	0.56	0.45	0.44
query37	0.10	0.07	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.04
query40	0.18	0.16	0.14
query41	0.09	0.03	0.02
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 97.38 s
Total hot run time: 24.48 s

### What problem does this PR solve?

Related PR: apache#69093

Problem Summary: Disabling bilateral eager aggregation for DecimalV3 SUM removes
pre-aggregation from the a, sum_min_max and count_sum_mixed shape plans. Refresh
the expected plans with the regression runner. All query result tags are unchanged.

### Release note

None

### Check List (For Author)

- Test: Regression test; run load, generate eager_agg expectations with -forceGenOut, then rerun eager_agg without generation on dev
- Behavior changed: No; test expectations reflect the existing decimal SUM restriction
- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

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

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17631	5119	5045	5045
q2	2159	307	249	249
q3	10243	1376	820	820
q4	4676	460	336	336
q5	7433	792	529	529
q6	179	181	155	155
q7	746	795	591	591
q8	9235	1333	1043	1043
q9	5415	4188	4138	4138
q10	6806	1294	1012	1012
q11	437	241	222	222
q12	641	400	273	273
q13	18095	3619	2994	2994
q14	268	273	238	238
q15	q16	744	733	663	663
q17	1200	756	570	570
q18	6969	6171	6125	6125
q19	1256	966	601	601
q20	392	329	216	216
q21	5611	2503	2396	2396
q22	371	335	268	268
Total cold run time: 100507 ms
Total hot run time: 28484 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5931	5947	6075	5947
q2	745	680	607	607
q3	5628	5925	5269	5269
q4	2007	2130	1533	1533
q5	5696	5751	5732	5732
q6	239	185	141	141
q7	2188	2032	1881	1881
q8	3002	2607	2628	2607
q9	8083	7695	7497	7497
q10	3635	3541	3114	3114
q11	575	404	374	374
q12	652	676	507	507
q13	3287	3582	3052	3052
q14	279	291	263	263
q15	q16	663	680	616	616
q17	7721	7022	6830	6830
q18	12947	12153	12906	12153
q19	921	764	764	764
q20	2132	2159	1922	1922
q21	5569	4642	4657	4642
q22	485	445	398	398
Total cold run time: 72385 ms
Total hot run time: 65849 ms

@hello-stephen

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

query5	4318	587	445	445
query6	436	206	184	184
query7	4804	450	249	249
query8	351	168	149	149
query9	8749	3166	3167	3166
query10	473	308	258	258
query11	5952	3860	3581	3581
query12	152	91	93	91
query13	1280	416	332	332
query14	6100	3912	3666	3666
query14_1	3472	3406	3381	3381
query15	211	199	179	179
query16	947	440	407	407
query17	855	660	517	517
query18	2426	406	304	304
query19	188	152	131	131
query20	85	82	84	82
query21	213	126	103	103
query22	13019	12986	12844	12844
query23	13408	12815	12314	12314
query23_1	12362	12548	12511	12511
query24	7368	817	467	467
query24_1	480	499	493	493
query25	536	415	370	370
query26	1256	263	143	143
query27	2787	439	274	274
query28	4626	2029	2026	2026
query29	1577	598	452	452
query30	296	217	180	180
query31	1031	945	818	818
query32	158	98	94	94
query33	529	305	242	242
query34	893	843	496	496
query35	731	766	657	657
query36	826	820	749	749
query37	133	103	87	87
query38	1799	1738	1659	1659
query39	810	795	741	741
query39_1	724	751	743	743
query40	225	116	97	97
query41	71	69	69	69
query42	89	82	82	82
query43	346	365	314	314
query44	1311	700	709	700
query45	181	191	166	166
query46	856	956	565	565
query47	2856	3039	2885	2885
query48	306	314	236	236
query49	578	401	298	298
query50	718	280	230	230
query51	10472	10561	10598	10561
query52	80	81	72	72
query53	192	225	155	155
query54	236	220	206	206
query55	79	75	65	65
query56	238	241	233	233
query57	1662	1621	1573	1573
query58	303	278	265	265
query59	2102	2122	1967	1967
query60	295	256	237	237
query61	175	168	170	168
query62	394	335	291	291
query63	191	164	160	160
query64	2936	970	765	765
query65	3331	3274	3292	3274
query66	1804	431	305	305
query67	22683	22669	22480	22480
query68	3261	1005	611	611
query69	399	310	258	258
query70	827	772	707	707
query71	299	233	209	209
query72	2892	2601	2372	2372
query73	528	541	298	298
query74	4627	4509	4380	4380
query75	2342	2278	1909	1909
query76	2392	1012	596	596
query77	346	362	273	273
query78	9868	9800	9209	9209
query79	981	856	537	537
query80	1024	429	340	340
query81	582	321	271	271
query82	571	141	105	105
query83	309	199	188	188
query84	310	129	96	96
query85	1125	437	379	379
query86	361	243	237	237
query87	2014	1954	1814	1814
query88	3747	2762	2753	2753
query89	325	275	240	240
query90	1782	172	162	162
query91	164	158	127	127
query92	93	89	91	89
query93	988	975	583	583
query94	540	322	292	292
query95	566	384	292	292
query96	672	484	239	239
query97	2495	2424	2353	2353
query98	161	153	150	150
query99	773	760	657	657
Total cold run time: 238219 ms
Total hot run time: 154039 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.10	0.06	0.05
query3	0.27	0.10	0.09
query4	1.61	0.10	0.09
query5	0.24	0.25	0.25
query6	1.17	0.67	0.68
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.40	0.34	0.35
query10	0.57	0.62	0.58
query11	0.21	0.16	0.15
query12	0.19	0.15	0.15
query13	0.49	0.50	0.51
query14	1.03	1.01	1.02
query15	0.63	0.60	0.60
query16	0.34	0.37	0.35
query17	1.15	1.13	1.17
query18	0.22	0.19	0.20
query19	2.05	1.91	2.02
query20	0.02	0.02	0.01
query21	15.48	0.18	0.14
query22	4.92	0.06	0.06
query23	16.36	0.31	0.12
query24	2.97	0.56	0.41
query25	0.13	0.06	0.06
query26	1.54	0.22	0.16
query27	0.06	0.03	0.04
query28	3.32	0.81	0.39
query29	12.49	4.12	3.21
query30	0.28	0.13	0.10
query31	2.77	0.56	0.33
query32	3.22	0.60	0.52
query33	3.15	3.19	3.23
query34	15.48	3.96	3.41
query35	3.34	3.32	3.32
query36	0.57	0.45	0.42
query37	0.10	0.06	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.14
query41	0.08	0.02	0.02
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 97.4 s
Total hot run time: 24.34 s

@feiniaofeiafei

Copy link
Copy Markdown
Collaborator Author

run cloud_p0

@feiniaofeiafei feiniaofeiafei changed the title [fix](eager-agg) Preserve decimal scale in eager SUM compensation [fix](eager-agg) Disable bilateral eager aggregation for decimal SUM Nov 6, 2026
@morrySnow

Copy link
Copy Markdown
Contributor

/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.

Static review of PR #69093 at head 1249469 converged in round 1. The DecimalV3 SUM guard in EagerAggRewriter runs before child-context and canonical-project construction, so bilateral eager aggregation is skipped for every admitted decimal Sum while one-sided pushdown remains. I traced DecimalV2/DecimalV3 resolution, decomposed SUM(IF(...)), project/union propagation, distinct/Sum0 exclusions, and nested BilateralState count slots; no correctness issue was found. Existing P2 inline comment 4439965509 is addressed by the current head's removed DecimalMultiplyForSum path and is not reposted. The changed FE and regression tests and generated plan outputs were inspected and cover the guarded two-sided cases, one-sided preservation, Decimal256 and overflow settings, aliases, nulls, multiplicity, and cancellation. No user-provided focus points were supplied. Nereids review checkpoints found no new rule-registration, property-derivation, locking, exception, or RPC path. No builds or tests were executed because the review contract is static-only; validation is inspected evidence. The final sweep found only a non-actionable trailing blank line in a generated .out file. No new inline findings.

Review converged after 1 round(s).

@morrySnow
morrySnow merged commit 41cd2b4 into apache:master Nov 7, 2026
59 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants