← Back to Pull requests

Fix scalar subquery preparation in broadcast build projections [databricks] #16855

Closed
unknown closed this pull request without merging on Nov 23, 2026 06:23 UTC
View on GitHub
unknown unknown commented on Nov 12, 2026 07:51 UTC
Author

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 finished when 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 967439669 as 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

  • Complete premerge CI, including Databricks.
  • Checklists

    Documentation

  • Updated for new or modified user-facing features or behaviors

  • No user-facing change
  • Testing

  • Added or modified tests to cover new code paths

  • Covered by existing tests

  • (Please provide the names of the existing tests in the PR description.)
  • Not required
  • Performance

  • Tests ran and results are added in the PR description

  • Issue filed with a link in the PR description

  • Not required
  • Diff: 397 lines (+297 / -100) across 4 files Reviewer: wjxiz1992 Review duration: 15751m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.1% · Safe to merge
    17.1%