perf: let a partial aggregate skip aggregation when it computes a dec… #7795
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.43) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 384 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #7795"
general
weight: 0.35
sunchao
…imal AVG
Which issue does this PR close?
Part of #7791 (item 3, decimal
AVGabove precision 11). The Float64AVGis #7543.Rationale for this change
With
spark.comet.exec.aggregate.skipPartial.enabled, a partial aggregate can stop aggregating and send rows to the shuffle as partial states, but only when every aggregate function is a single-argumentCOUNT. A decimalAVGwhose precision is above 11 is built asAvgDecimal, whoseconvert_to_statereturned "not implemented", so a high-cardinalityGROUP BYwith such anAVGnever skips.What changes are included in this PR?
AvgDecimalGroupsAccumulator::convert_to_stategives each row the state thatstate()emits for a group holding only that row: the value and a count of one, or a zero sum and a zero count for a null or filtered-out row (a null predicate excludes its row). A value outside the sum's precision gets a null sum and count, the overflow markerupdate_batchsets, whichmerge_batchkeeps andevaluatereports in ANSI mode. Spark's sum type is at least as wide as the input, so this does not happen for valid input; it keeps the two paths identical.configure_skip_partial_aggregationadmits anAVGwith an input and a decimal result type, which the planner always builds asAvgDecimal. Any otherAVGresult is Comet's Float64Avg, which still cannot convert rows, so it still keeps the plan from skipping.filter_to_nullsincollect.rsispub(super)soavg_decimal.rscan reuse it (#7543 makes the same change).CometConfdoc and the Adaptive Partial Aggregation section of the tuning guide list the admitted aggregates.Skipping stays opt-in.
How are these changes tested?
convert_to_state_matches_one_row_groups(Rust): converting a batch equalsupdate_batchwith one group per row followed bystate(), for input with and without nulls, with a filter that has false and null predicates, for sliced inputs and filters, and for a value past the sum's precision.skip_partial_eligibility_is_fail_closed:AVGwith a decimal result is admitted next toCOUNT;AVGwithout an input, without a result type, or with aDOUBLEresult is not.CometAggregateSuite"skip partial aggregation converts decimal AVG rows to partial states": high-cardinalityGROUP BYoveravgof aDECIMAL(20, 2)with nulls, with aFILTERclause and next tocount, and over aDECIMAL(38, 0)whose two-row groups overflow only after the shuffle. Each checks the answer against Spark and thatskipped_aggregation_rowsis above zero. In ANSI mode the overflow raisesARITHMETIC_OVERFLOWlike Spark.avg(CAST(d AS DOUBLE))still does not skip.The Rust test fails on
main(not implemented), and the suite test fails with the gate change reverted ("Expected skipping for avg(d)"). The other skip-partial tests inCometAggregateSuitestill pass, andcargo clippy --all-targets -- -D warningsis clean.This PR has no performance numbers on Spark. Measuring skipping with
AVGon Spark (item 1 of #7791) is still open.