← Back to Pull requests

Accelerate Delta GenerateIdentityValues on Databricks 17.3/18.3 [databricks] #17103

Closed
unknown closed this pull request without merging on Nov 24, 2026 01:20 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 18:18 UTC
Author

Fixes #16865.

Description

Problem. MERGE INTO a Delta table with an identity column on Databricks 17.3+ plans GenerateIdentityValues inside the MERGE output projection. It had no GPU rule, so the whole projection fell back to the CPU.

Change.

  • Adds GpuGenerateIdentityValues and its rule for the 400db173 and 410db183 shims. Partition p starts at base + p step and advances by numPartitions step per row, where base is start or the high water mark plus step. It is retryable (checkpoint/restore), so a batch retried after an OOM gets the same values.

  • Separate fix: GpuIdentityColumn now tracks the identity high water mark by physical column name when column mapping is on (matching the delta-io variant). Before, it used the logical name. It applies to all DBR versions that share this source.
  • Behavior differences from the CPU.

  • The GPU generates a value for every row of a batch, not only for inserted rows, because evaluating it only on the CASE WHEN branch rows filtered the whole wide batch just to count rows. Identity values stay unique and increasing but are not consecutive. A MERGE that rewrites N rows consumes about N x numPartitions x step of the Long range.

  • To avoid an overflow the CPU wouldn't hit, the expression falls back to the CPU when the start or high water mark is beyond Long.MaxValue/2 or Long.MinValue/2, or when |step| > 2^20.
  • Scope. Databricks only (400db173, 410db183). OSS Delta support is deferred: I prototyped it but the quarter seeded merge was slower on spark2a (cause not found), so it isn't part of this PR.

    Testing

  • test_delta_merge_identity_column: start/step, column mapping, partitions and low-shuffle merge on/off. The tests assert GPU commands, no GenerateIdentityValues fallback and the high water mark ordering.

  • test_delta_merge_identity_column_overflow_guard: both sides of each guard boundary, asserting whether the GPU expression was used.

  • test_delta_write_identity_columns_column_mapping_sql for the column mapping fix.

  • GpuGenerateIdentityValuesSuite: 7 unit tests (continuity, zero-row batch, checkpoint/restore, checkpoint before first evaluation, overflow, partition offset, guard boundaries).

  • Existing test_delta_write_identity_columns_sql and the multiple-identity-column test pass on 17.3.

  • The full delta_lake_merge_test passed on DBR 17.3 (299 passed, 25 skipped, 0 failed).
  • Performance

    The same plugin jar on both arms, both on the GPU. The arms differ only in spark.rapids.sql.expression.GenerateIdentityValues: off makes the expression fall back to the CPU (and with it the whole MERGE output projection, as on main), on runs it on the GPU. Table setup, seeding and correctness checks run on the CPU outside the timed section, and every measured run passed its checks.

  • Databricks 17.3 on Azure, 2 x Standard_NC16as_T4_v3, delta_sf3000 loaded via abdatasets.

  • Empty target: MERGE into an empty identity table; every source row is inserted.

  • Quarter-seeded: the target holds 25% of the keys; matched rows are deleted or updated and the rest inserted. This is the realistic case, since most of the projection is key preserving.
  • Results (merge time in seconds, runs pooled over both arm orders):

    | Workload | Rule off | Rule on | Median change | p-value |
    |---|---|---|---|---|
    | Quarter-seeded | 171.5, 163.9, 208.3, 173.1, 158.4, 166.9 | 149.0, 156.6, 137.2, 146.2, 153.1, 164.4 | -10.7% | 0.026 |
    | Empty target | 80.9, 68.0, 122.5, 78.6, 71.3, 116.3 | 73.4, 61.2, 92.6, 82.4, 58.9, 81.5 | -2.9% | 0.22 |

    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: 513 lines (+384 / -129) across 6 files Reviewer: sdrp713 Review duration: 421m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 513 lines diff across 6 files
    0.48
    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.373
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #17103"
    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: 47.7% (MEDIUM) · Higher = larger blast radius
    47.7%
    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: 18.8% · Safe to merge
    18.8%