Fix scalar subquery preparation in broadcast build projections [databricks] #16855
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 · 397 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.358
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #16855"
general
weight: 0.35
wjxiz1992
JaCoCo production line coverage: +5 lines (
sql-plugin +5, Spark 3.5.7 regression run)Fixes #16606.
Description
GPU broadcast joins can fail with
Subquery ... has not finishedwhen a build-side projection contains a scalar subquery. Spark prepares the build subtree before join execution. Wait for the extracted projections' scalar subqueries once on the driver before binding the per-task and cached projections.On Spark 3.5.7, 58 tests passed across five Scala suites. All four combinations of adaptive query execution (AQE) and hash-table reuse matched CPU results and confirmed the scalar subquery was in the broadcast build-side projection. The reuse-enabled cases also verify a successful cached hash-table build on the standard broadcast path.
We observed no clear startup performance regression in the initial local comparison. We measured driver startup on Spark 3.5.7 with an RTX 5880 Ada and a GPU broadcast join with a build-side projection and no scalar subquery over 262,144 stream rows and 4,096 build rows. The control used the same plugin package with the join class from upstream
effc9a9. Each configuration had 20 timed runs per version after warmup in two JVMs. All timed runs matched CPU results.| AQE | Hash-table reuse | Upstream p50 / p95 (ms) | Initial fix p50 / p95 (ms) |
| --- | --- | ---: | ---: |
| Off | Off | 76.1 / 129.6 | 74.4 / 92.8 |
| Off | On | 69.9 / 128.4 | 67.5 / 77.5 |
| On | Off | 223.8 / 250.5 | 210.2 / 233.3 |
| On | On | 229.4 / 276.4 | 209.3 / 286.8 |
Timing starts after physical planning and covers driver initialization through Spark's
QueryExecution.toRdd, including adaptive stage materialization when enabled. Startup p50 did not increase in this workload, and the AQE-and-reuse p95 was 10.4 ms higher.The original scalar-subquery query failed on the upstream control in all four configurations and matched CPU results after the initial fix.
The follow-up comparison used the same package with the join class from the previous PR head
967439669as the control. On the projected join and the original scalar-subquery query, we measured 20 timed runs per version and configuration after warmup across two JVMs. All 320 runs matched CPU results. Startup p50 changes ranged from −1.1 to +3.2 ms for the projected join and −6.9 to +2.0 ms for the scalar query. With AQE and reuse enabled, the projected-join p95 rose from 238.1 to 276.3 ms, with opposite changes across the two paired JVM comparisons. We observed no consistent startup regression in the follow-up runs.AI assistance: The change, tests, and description were prepared with Codex assistance.
Remaining validation
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance