Skip to content

[databricks] CheckOverflowInTableWrite Support#15366

Open
sdrp713 wants to merge 1 commit into
NVIDIA:mainfrom
sdrp713:CheckOverflowInTableWrite-gpu-support
Open

[databricks] CheckOverflowInTableWrite Support#15366
sdrp713 wants to merge 1 commit into
NVIDIA:mainfrom
sdrp713:CheckOverflowInTableWrite-gpu-support

Conversation

@sdrp713

@sdrp713 sdrp713 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Fixes #15234

Description

Add native GPU support for Databricks Delta’s CheckOverflowInTableWrite expression on DBR 17.3. The expression now delegates to GpuCast while preserving Delta’s DELTA_CAST_OVERFLOW_IN_TABLE_WRITE error behavior.

The change also:

  • Registers the expression rule with the DBR 17.3 Delta provider.
  • Adds success and overflow integration tests.
  • Disables the CPU-expression bridge in the focused tests to prove native GPU replacement.
  • Imports the DBR spark-protobuf_2.13 artifact required by the integration-test build.

Verification

Tested on DBR 17.3 GPU ML:

  • Built successfully with ./jenkins/databricks/build.sh.
  • Focused MERGE success and overflow tests passed.
  • Verified GpuRapidsProcessDeltaMergeJoinExec was used with the CPU bridge disabled.
  • Verified overflow retains DELTA_CAST_OVERFLOW_IN_TABLE_WRITE

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

@sdrp713 sdrp713 self-assigned this Jul 23, 2026
@sdrp713 sdrp713 added the bug Something isn't working label Jul 23, 2026
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds native GPU support for Databricks Delta's CheckOverflowInTableWrite expression on DBR 17.3, delegating to GpuCast while re-wrapping any ArithmeticException as Delta's DELTA_CAST_OVERFLOW_IN_TABLE_WRITE error — matching the existing GpuCheckOverflowInTableInsert pattern.

  • New expression: GpuCheckOverflowInTableWrite (new file in the delta-spark400db173 module) follows the established GpuCheckOverflowInTableInsert pattern: delegates to child GpuCast, catches ArithmeticException, and re-throws with Delta's typed error.
  • Provider registration: DeltaSpark400DB173Provider.getExprs correctly extends super.getExprs with the new expression rule, preserving any rules already registered by parent providers.
  • Tests: Two new DBR-17.3-gated integration tests cover the success path (GPU merge processor verified via ExecutionPlanCaptureCallback with the CPU bridge disabled) and the overflow path (assert_gpu_and_cpu_error confirms both CPU and GPU raise DELTA_CAST_OVERFLOW_IN_TABLE_WRITE).

Confidence Score: 5/5

Safe to merge — the change is a well-scoped, DBR-17.3-only expression wrapper that mirrors an already-proven pattern.

The implementation faithfully replicates the GpuCheckOverflowInTableInsert structure: delegates to GpuCast, catches ArithmeticException (which covers the SparkArithmeticException subtype thrown by GpuCast in ANSI mode), and re-wraps with Delta's typed error. Resource management is clean — the GpuColumnVector is returned directly on the success path and never partially allocated on the exception path. The provider registration correctly extends super.getExprs rather than replacing it. Both the success and overflow test paths are covered by DBR-17.3-gated integration tests, and the PR title carries the [databricks] tag to trigger Databricks CI.

No files require special attention.

Important Files Changed

Filename Overview
delta-lake/delta-spark400db173/src/main/scala/com/databricks/sql/transaction/tahoe/rapids/GpuCheckOverflowInTableWrite.scala New GPU expression following the GpuCheckOverflowInTableInsert pattern; correct resource handling, exception re-mapping, and ExprRule registration.
delta-lake/delta-spark400db173/src/main/scala/com/nvidia/spark/rapids/delta/DeltaSpark400DB173Provider.scala Correctly overrides getExprs by extending super.getExprs with the new CheckOverflowInTableWrite rule; import and registration look correct.
integration_tests/src/main/python/delta_lake_merge_test.py Two new DBR-17.3-gated tests; success path verifies GPU merge processor via plan capture with CPU bridge disabled, overflow path uses assert_gpu_and_cpu_error for symmetric error verification.

Sequence Diagram

sequenceDiagram
    participant Spark as Spark Planner
    participant Provider as DeltaSpark400DB173Provider
    participant Meta as UnaryExprMeta[CheckOverflowInTableWrite]
    participant Gpu as GpuCheckOverflowInTableWrite
    participant Cast as GpuCast (child)
    participant Delta as DeltaErrors

    Spark->>Provider: getExprs()
    Provider->>Provider: super.getExprs + exprRule
    Provider-->>Spark: Map with CheckOverflowInTableWrite rule

    Spark->>Meta: convertToGpu(gpuChild: GpuCast)
    Meta-->>Gpu: GpuCheckOverflowInTableWrite(cast, columnName)

    Note over Gpu,Cast: At execution time (columnarEval)
    Gpu->>Cast: columnarEval(batch)
    alt Cast succeeds
        Cast-->>Gpu: GpuColumnVector (result)
        Gpu-->>Spark: GpuColumnVector
    else Cast throws ArithmeticException (overflow)
        Cast-->>Gpu: ArithmeticException
        Gpu->>Delta: castingCauseOverflowErrorInTableWrite(fromType, toType, columnName)
        Delta-->>Spark: SparkException(DELTA_CAST_OVERFLOW_IN_TABLE_WRITE)
    end
Loading

Reviews (3): Last reviewed commit: "Init Commit" | Re-trigger Greptile

Comment thread integration_tests/src/main/python/delta_lake_merge_test.py
@sdrp713 sdrp713 changed the title CheckOverflowInTableWrite Support [databricks] CheckOverflowInTableWrite Support Jul 23, 2026
@sdrp713
sdrp713 force-pushed the CheckOverflowInTableWrite-gpu-support branch from cb9a5c5 to d73fa10 Compare July 23, 2026 21:25
Signed-off-by: Rahul Prabhu <raprabhu@nvidia.com>
@sdrp713
sdrp713 force-pushed the CheckOverflowInTableWrite-gpu-support branch from d73fa10 to ddaea75 Compare July 23, 2026 23:34
@sdrp713
sdrp713 requested a review from a team July 24, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Delta merge into write falls back from GPU due to unsupported CheckOverflowInTableWrite on Databricks 17.3

2 participants