Preserve accumulator cast semantics in array aggregate [databricks] #17012
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 374 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.355
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #17012"
general
weight: 0.35
wjxiz1992
Fixes #16918.
Description
Dropping a narrowing accumulator cast in an array
aggregatecould return the wrong value or suppress an ANSI overflow. For non-ANSI integer sums of the formcast(acc as narrower_integer) + xor its reverse, wherexhas the accumulator type, the GPU now narrows the prefix sum and adds the last element at the original width. For a zero initial value and a cast throughTINYINT, this gives128for[127, 1]and-128for[127, 1, 0]. Other value-changing casts (including those ingreatest,try_cast, and ANSI sums) as well asTRYor ANSI-retainedSUM/PRODUCTmerge operations fall back to Spark. Exact casts still run on GPU.This also moves the user-facing
ArrayAggregatesupport and CPU-fallback explanation out ofdocs/compatibility.mdintoGpuCollectionExpressionOverrides(regeneratingdocs/supported_ops.mdanddocs/additional-functionality/advanced_configs.md). Unsupported lambda shapes fall back to CPU with Spark-compatible results rather than introducing compatibility differences: the only GPU/CPU divergence (variableFloatAggon floating-pointSUM/PRODUCT) remains documented underFloating Pointindocs/compatibility.md, supported shapes and fallback reasons live indocs/supported_ops.mdanddocs/additional-functionality/advanced_configs.md, andspark.rapids.sql.explainreports the exact fallback reason per query.Validation:
ArrayAggregateDecomposerSuiteandGpuArrayHofFusionSuiteon Spark 3.5.2 (58Scala tests passed),higher_order_functions_test.py(80integration tests passed, including wide-sum wraparound cancellation andtry_cast/try_add/try_multiplyfallbacks), andtoolsdocgen on Spark 3.3.0.libcudf.sowithzstd-jnion the classpath.Median end-to-end times reported on an RTX 5880 Ada over 10 warm runs per case (measured on
aa4d2f9dprior to mergingmainand follow-up test/guard updates). Each run checked all 524,288 results for arrays of 32 in-range integers.| Accumulator cast | Original GPU | Published draft | Updated GPU |
| --- | ---: | ---: | ---: |
| INT → TINYINT → INT | 235.5 ms | 886 ms (CPU fallback) | 270.5 ms |
| INT → BIGINT → INT | 235 ms | 234.5 ms (GPU) | 232 ms |
AI assistance was used to implement and validate this change.
Checklists
Documentation
Testing
Performance