← Back to Pull requests

Fix tiered projection for side-effecting AND/OR expressions #17239

Open
unknown opened this pull request with 328 lines diff across 4 files
View on GitHub
unknown unknown commented on Dec 02, 2026 03:55 UTC
Author

Fixes #16989.

Description


Repeated side-effecting expressions inside conditional GPU AND/OR operands could be moved into a whole-batch tiered projection. In ANSI mode, this evaluated guarded operations such as division by zero on rows that CPU short-circuiting skips, causing GPU queries to fail instead of matching CPU results.

Global CSE now traverses only actual left-spine prefixes from longest to shortest, preserving top-down traversal semantics without creating extra tiers or synthetic right-associated prefixes. Per-subtree expression profiles are reused, and the unused final safe-right profile is skipped, so long right-associated chains remain linear to plan. Scoped CSE analyzes guarded operands once in a forward pass, records first/last occurrence intervals, merges overlapping regions, and recursively scopes CSE inside generated tiers. This supports non-adjacent repeats, compound operands, interleaved regions, and nested mixed AND/OR expressions while preserving short-circuit evaluation.

There are no new configurations or other user-facing API changes.

Validation:

  • GpuEquivalentExpressionsSuite: 35/35 on Scala 2.12 and 35/35 on Scala 2.13, including 64-operand right-associated AND and OR chains.

  • Focused Spark 4.1 GPU integration tests: 12 passed.

  • Scala 2.12 and Scala 2.13 all-module Scalastyle checks passed.

  • Python syntax, IDE diagnostics, and whitespace checks passed.

  • Shim source-selection review passed across all 34 current profiles with no findings.

  • Cross-PR overlaps with #16041 and #17112 were inspected and are independent.

  • Spark 5-specific cases were not executed locally because the available GPU runtime is Spark 4.1.1.
  • Performance was measured on 4 billion synthetic rows across 32 partitions, with one warm-up and three measured iterations per case. Compared with the previously reviewed optimized implementation, all 11 benchmark medians changed by between -1.8% and +1.7%. The most expensive eight-repeat AND and OR cases completed in 4.14 and 4.25 seconds respectively, showing no material regression.

    AI assistance was used to implement, review, and validate this change.

    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

  • 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: 328 lines (+246 / -82) across 4 files Reviewer: thirtiseven Review duration: 4351m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.42) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 328 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    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.347
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #17239"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% 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: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    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: 43.0% · Lower = rushed or shallow review
    43.0%
    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: 24% · Safe to merge
    24%