Skip to content

Support ANSI JIT AST project expressions#15069

Draft
thirtiseven wants to merge 58 commits into
NVIDIA:mainfrom
thirtiseven:ast_exp
Draft

Support ANSI JIT AST project expressions#15069
thirtiseven wants to merge 58 commits into
NVIDIA:mainfrom
thirtiseven:ast_exp

Conversation

@thirtiseven

@thirtiseven thirtiseven commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Fixes #xxxx.

Current cuDF/JNI baseline

The current code is based on https://github.com/thirtiseven/cudf/tree/codex-ansi-jit-22602-22680-22836-jni-test.
This branch combines the current cuDF work from rapidsai/cudf#22602, rapidsai/cudf#22680, and rapidsai/cudf#22836 with the Java/JNI changes required by this prototype.

Description

ANSI JIT Project Benchmark

  • rows: 100000000
  • partitions: 16
  • app repeats: 3
  • warmups: 1
  • hot iterations per app: 3

Cache modes:

  • GPU_AST_JIT_COLD: runs in a fresh Spark application with an empty JIT cache.
  • GPU_AST_JIT_DISK_WARM: runs in a fresh application with the target kernel already in the on-disk cache, but not loaded in the process.
  • GPU_AST_JIT_PCH_WARM_KERNEL_COLD: creates a PCH with a distinct probe, then measures the first compilation of the target kernel.
  • GPU_AST_JIT_HOT: warms up the exact target expression and measures reuse from the in-process kernel cache.

PCH generation, disk-cache population, and hot warmup time are excluded from their corresponding measured results.

Previous benchmark results

based on draft pr

exprs depth mode cache apps avg wall ms min wall ms speedup vs CPU project op ms compile ASTs ms compute ASTs ms project other ms all GPU op ms
8 1 CPU none 3 3196.9 2830.6 1.00 0.0 0.0 0.0 0.0 0.0
8 1 GPU_PROJECT none 3 732.7 670.9 4.36 425.0 0.0 0.0 425.0 7702.6
8 1 GPU_AST_JIT_COLD cold 3 14320.7 14271.3 0.22 47608.1 65.5 47539.4 3.2 247575.5
8 1 GPU_AST_JIT_HOT hot 3 636.1 589.2 5.03 137.3 10.3 126.6 0.4 5971.6
8 4 CPU none 3 4257.3 4094.1 1.00 0.0 0.0 0.0 0.0 0.0
8 4 GPU_PROJECT none 3 915.5 871.9 4.65 1132.9 0.0 0.0 1132.9 11143.8
8 4 GPU_AST_JIT_COLD cold 3 14474.0 14272.2 0.29 48181.9 93.5 48083.8 4.6 250456.5
8 4 GPU_AST_JIT_HOT hot 3 652.4 599.6 6.53 156.0 10.0 145.6 0.4 6303.4
8 8 CPU none 3 5633.7 5470.2 1.00 0.0 0.0 0.0 0.0 0.0
8 8 GPU_PROJECT none 3 1148.8 1115.1 4.90 1977.7 0.0 0.0 1977.7 14937.2
8 8 GPU_AST_JIT_COLD cold 3 14563.6 14487.2 0.39 48389.4 96.1 48290.0 3.3 251701.0
8 8 GPU_AST_JIT_HOT hot 3 674.8 637.1 8.35 195.9 26.1 169.4 0.4 6171.1

based on new pr

exprs depth mode cache apps avg wall ms min wall ms speedup vs CPU project op ms compile ASTs ms compute ASTs ms project other ms all GPU op ms
8 1 CPU none 3 3252.2 2940.1 1.00 0.0 0.0 0.0 0.0 0.0
8 1 GPU_PROJECT none 3 728.9 670.8 4.46 410.5 0.0 0.0 410.5 7775.8
8 1 GPU_AST_JIT_COLD cold 3 15066.5 15045.1 0.22 50815.8 62.2 50750.5 3.1 263018.1
8 1 GPU_AST_JIT_HOT hot 3 711.5 663.1 4.57 562.5 12.6 549.5 0.5 8000.6
8 4 CPU none 3 4260.8 4081.4 1.00 0.0 0.0 0.0 0.0 0.0
8 4 GPU_PROJECT none 3 917.2 885.7 4.65 1135.5 0.0 0.0 1135.5 11065.3
8 4 GPU_AST_JIT_COLD cold 3 15236.8 15191.5 0.28 51174.4 102.2 51068.7 3.5 265237.3
8 4 GPU_AST_JIT_HOT hot 3 740.6 696.5 5.75 591.1 16.3 574.3 0.5 8417.0
8 8 CPU none 3 5709.8 5426.9 1.00 0.0 0.0 0.0 0.0 0.0
8 8 GPU_PROJECT none 3 1148.1 1081.9 4.97 1976.6 0.0 0.0 1976.6 14881.1
8 8 GPU_AST_JIT_COLD cold 3 15560.7 15417.7 0.37 52424.8 96.5 52324.1 4.2 271813.9
8 8 GPU_AST_JIT_HOT hot 3 748.7 680.5 7.63 651.5 40.0 611.1 0.5 8443.6

based on new pr, after RTCX cache optimization:

exprs depth mode cache apps avg wall ms min wall ms speedup vs CPU project op ms compile ASTs ms compute ASTs ms project other ms all GPU op ms
8 1 CPU none 3 2967.4 2826.8 1.00 0.0 0.0 0.0 0.0 0.0
8 1 GPU_PROJECT none 3 720.6 677.9 4.12 415.0 0.0 0.0 415.0 7497.1
8 1 GPU_AST_JIT_COLD cold 3 14987.9 14920.0 0.20 50448.5 70.2 50373.8 4.6 261427.3
8 1 GPU_AST_JIT_HOT hot 3 634.1 578.3 4.68 150.5 16.8 133.4 0.4 5787.7
8 4 CPU none 3 4187.0 3989.8 1.00 0.0 0.0 0.0 0.0 0.0
8 4 GPU_PROJECT none 3 930.3 874.9 4.50 1147.1 0.0 0.0 1147.1 11086.8
8 4 GPU_AST_JIT_COLD cold 3 15087.4 15070.7 0.28 50699.7 89.9 50605.8 4.1 262936.5
8 4 GPU_AST_JIT_HOT hot 3 660.7 625.5 6.34 160.5 15.9 144.2 0.4 6173.3
8 8 CPU none 3 5744.3 5393.7 1.00 0.0 0.0 0.0 0.0 0.0
8 8 GPU_PROJECT none 3 1128.2 1081.2 5.09 1949.9 0.0 0.0 1949.9 14638.6
8 8 GPU_AST_JIT_COLD cold 3 15501.6 15400.6 0.37 52202.9 92.8 52106.4 3.7 270534.0
8 8 GPU_AST_JIT_HOT hot 3 673.8 644.4 8.52 218.6 34.2 184.0 0.4 6367.3

results based on merge of 22602 + 22680 + 22836

exprs depth mode cache apps avg wall ms min wall ms speedup vs CPU project op ms compile ASTs ms compute ASTs ms project other ms all GPU op ms
8 1 CPU none 3 3116.0 2849.3 1.00 0.0 0.0 0.0 0.0 0.0
8 1 GPU_PROJECT none 3 729.6 701.6 4.27 428.0 0.0 0.0 428.0 7700.8
8 1 GPU_AST_JIT_COLD cold 3 7249.3 7236.6 0.43 19394.1 57.5 19333.1 3.5 105993.2
8 1 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 4065.8 4032.2 0.77 13114.7 17.3 13096.8 0.6 71126.9
8 1 GPU_AST_JIT_HOT hot 3 720.9 673.0 4.32 571.6 9.4 561.7 0.4 8027.2
8 4 CPU none 3 4176.0 3987.8 1.00 0.0 0.0 0.0 0.0 0.0
8 4 GPU_PROJECT none 3 924.1 867.9 4.52 1153.6 0.0 0.0 1153.6 11033.9
8 4 GPU_AST_JIT_COLD cold 3 7537.8 7501.9 0.55 20498.7 73.0 20422.1 3.6 112015.5
8 4 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 4307.3 4290.5 0.97 13985.7 30.4 13954.6 0.7 75410.8
8 4 GPU_AST_JIT_HOT hot 3 736.4 726.2 5.67 581.2 18.0 562.7 0.5 8278.1
8 8 CPU none 3 5559.0 5373.7 1.00 0.0 0.0 0.0 0.0 0.0
8 8 GPU_PROJECT none 3 1128.6 1051.0 4.93 1995.6 0.0 0.0 1995.6 14928.5
8 8 GPU_AST_JIT_COLD cold 3 7920.8 7899.7 0.70 21937.4 118.4 21815.6 3.4 119099.5
8 8 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 4762.4 4733.9 1.17 15721.8 41.0 15680.2 0.6 84214.3
8 8 GPU_AST_JIT_HOT hot 3 741.8 696.8 7.49 612.3 22.0 589.8 0.4 8337.2

on cudf main branch

exprs depth mode cache apps avg wall ms min wall ms speedup vs CPU project op ms compile ASTs ms compute ASTs ms project other ms all GPU op ms
8 1 CPU none 3 2982.9 2798.9 1.00 0.0 0.0 0.0 0.0 0.0
8 1 GPU_PROJECT none 3 718.3 659.5 4.15 418.1 0.0 0.0 418.1 7845.5
8 1 GPU_AST_JIT_COLD cold 3 8089.1 8054.8 0.37 22377.2 33.8 22324.2 19.1 122921.1
8 1 GPU_AST_JIT_DISK_WARM disk_warm 3 2597.8 2557.7 1.15 435.6 30.0 394.9 10.7 12938.5
8 1 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 4575.7 4485.0 0.65 15070.7 15.7 15054.3 0.8 81745.7
8 1 GPU_AST_JIT_HOT hot 3 627.2 597.1 4.76 144.0 14.4 129.0 0.5 6304.7
8 4 CPU none 3 4241.8 4031.7 1.00 0.0 0.0 0.0 0.0 0.0
8 4 GPU_PROJECT none 3 931.5 885.9 4.55 1177.7 0.0 0.0 1177.7 11578.5
8 4 GPU_AST_JIT_COLD cold 3 8422.9 8346.3 0.50 23645.3 52.4 23580.8 12.2 128938.7
8 4 GPU_AST_JIT_DISK_WARM disk_warm 3 2653.2 2646.6 1.60 489.6 43.1 430.1 16.5 13713.6
8 4 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 4811.1 4759.4 0.88 15901.6 21.5 15879.2 0.8 85819.8
8 4 GPU_AST_JIT_HOT hot 3 663.2 627.1 6.40 160.0 20.4 139.0 0.6 6657.7
8 8 CPU none 3 5603.2 5440.1 1.00 0.0 0.0 0.0 0.0 0.0
8 8 GPU_PROJECT none 3 1132.5 1082.0 4.95 1967.4 0.0 0.0 1967.4 15169.6
8 8 GPU_AST_JIT_COLD cold 3 8823.4 8771.6 0.64 25312.5 58.9 25242.0 11.5 136984.1
8 8 GPU_AST_JIT_DISK_WARM disk_warm 3 2625.8 2617.5 2.13 494.7 48.3 434.3 12.1 13112.8
8 8 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 5299.7 5248.3 1.06 17848.7 32.1 17815.8 0.9 95407.8
8 8 GPU_AST_JIT_HOT hot 3 688.3 650.9 8.14 195.7 47.3 147.9 0.5 6815.1
exprs depth mode cache apps avg wall ms min wall ms speedup vs CPU project op ms compile ASTs ms compute ASTs ms project other ms all GPU op ms
8 1 CPU none 3 3012.1 2769.8 1.00 0.0 0.0 0.0 0.0 0.0
8 1 GPU_PROJECT none 3 761.2 721.3 3.96 418.0 0.0 0.0 418.0 8415.5
8 1 GPU_AST_JIT_COLD cold 3 7981.4 7915.3 0.38 21950.7 30.9 21908.1 11.7 120787.2
8 1 GPU_AST_JIT_DISK_WARM disk_warm 3 2632.4 2608.5 1.14 453.8 30.6 411.5 11.7 13703.8
8 1 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 4491.1 4384.6 0.67 14575.7 21.1 14553.8 0.8 79642.6
8 1 GPU_AST_JIT_HOT hot 3 691.8 648.3 4.35 132.6 15.7 116.4 0.5 7191.9
8 4 CPU none 3 4173.1 4031.7 1.00 0.0 0.0 0.0 0.0 0.0
8 4 GPU_PROJECT none 3 992.0 933.7 4.21 1147.6 0.0 0.0 1147.6 12306.0
8 4 GPU_AST_JIT_COLD cold 3 8325.8 8288.9 0.50 23150.7 46.4 23091.8 12.5 127126.1
8 4 GPU_AST_JIT_DISK_WARM disk_warm 3 2691.9 2685.6 1.55 478.4 41.7 427.5 9.3 14096.7
8 4 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 4800.2 4788.1 0.87 15643.2 29.3 15613.1 0.8 85440.4
8 4 GPU_AST_JIT_HOT hot 3 719.1 675.5 5.80 160.4 30.2 129.8 0.5 7330.2
8 8 CPU none 3 5610.1 5392.2 1.00 0.0 0.0 0.0 0.0 0.0
8 8 GPU_PROJECT none 3 1177.5 1127.4 4.76 1965.2 0.0 0.0 1965.2 15698.4
8 8 GPU_AST_JIT_COLD cold 3 8771.4 8732.2 0.64 24916.0 57.0 24848.1 11.0 136009.6
8 8 GPU_AST_JIT_DISK_WARM disk_warm 3 2708.8 2694.2 2.07 524.4 54.6 458.2 11.6 14156.6
8 8 GPU_AST_JIT_PCH_WARM_KERNEL_COLD pch_warm_kernel_cold 3 5320.7 5259.7 1.05 17602.9 43.5 17558.6 0.7 95411.9
8 8 GPU_AST_JIT_HOT hot 3 727.5 673.8 7.71 192.1 44.3 147.3 0.5 7658.8

This PR adds initial spark-rapids support for cuDF ANSI row IR JIT project expressions.

The intent is to evaluate and review the Spark-side wiring against the cuDF/JNI baseline linked above. The feature remains guarded by existing AST/JIT configuration and by expression-level gating.

The changes include:

  • wiring additional project expressions into JIT AST conversion
  • adding decimal cast, bitwise, null-handling, and simple conditional expression support
  • adding ANSI integer DIV and % project AST support where Spark and cuDF row IR semantics are expected to match
  • gating unsupported or semantic-mismatched cases such as decimal literals and decimal DIV
  • preserving Spark selected-branch null semantics for simple IF expressions with NULLIFY_IF + COALESCE
  • adding project split retry support for JIT compiled expressions
  • adding integration coverage for enabled and intentionally-fallback cases

Open items for this draft:

  • This depends on the cuDF/JNI baseline linked above.
  • Spark % support depends on cuDF ANSI_MOD preserving cuDF MOD semantics. If cuDF intentionally keeps ANSI_MOD as floor/Python-style modulo, Spark should gate % out of AST and fall back.
  • Performance evaluation is still pending.

Validation in this PR creation step:

  • git diff --check

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

@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR wires cuDF ANSI row IR JIT AST support into the GPU project operator, adding convertToAst implementations for arithmetic, bitwise shift, conditional, null-handling, decimal cast, and reference expressions, all guarded by a new internal config (spark.rapids.sql.projectAstAnsiArithmeticEnabled) and a LIBCUDF_JIT_ENABLED env-var check.

  • New expressions supported in AST JIT: ANSI NEG/ABS/ADD/SUB/MUL for Int/Long; ANSI DIV/MOD for Int/Long; ShiftLeft/ShiftRight with Java-semantics mask; Coalesce via right-fold; IF (simple value branches only); decimal-to-decimal and Int→Long casts; decimal column references.
  • GpuProjectAstExec reworked: compiled AST expressions moved into a RetryableCompiledAstExpressions helper that recompiles on OOM retry (needed because JIT can initialize state lazily), replacing the old withRetry path with runWithSplitRetry.
  • isColumnSizeOverflow modified: suppresses split-retry for JIT-emitted CudfColumnSizeOverflowException by matching the error message string "error in transform UDF" — a fragile coupling to upstream cuDF error text that is explicitly noted as still under review.

Confidence Score: 3/5

The change is guarded by an internal config defaulting to false and depends on a cuDF JNI API still under review upstream; the new isColumnSizeOverflow exception-message filter is the main risk in a code path that affects all AST project executions, not just JIT ones.

Most of the new expression wiring looks correct and is well-tested. The key concern is the isColumnSizeOverflow modification: it changes retry behavior for every CudfColumnSizeOverflowException (not just JIT ones) by string-matching a message from upstream cuDF that is itself still in flux. A message change in cuDF could silently cause JIT arithmetic overflows to trigger unnecessary split-retries, or suppress a legitimate column-size overflow from being retried. The GpuLiteral.convertToAst decimal-null path and the inconsistency between spark330 and spark330db IntegralDivide AST gate logic are smaller but real divergences worth resolving before this goes to production.

RmmRapidsRetryIterator.scala (exception-message filter), literals.scala (null decimal in dead convertToAst path), and spark330/DecimalArithmeticOverrides.scala (weaker IntegralDivide AST gate vs. spark330db counterpart).

Important Files Changed

Filename Overview
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RmmRapidsRetryIterator.scala Modified isColumnSizeOverflow to suppress split-retry for JIT transform UDF errors using string matching on exception messages — fragile coupling to upstream cuDF error text.
sql-plugin/src/main/scala/com/nvidia/spark/rapids/basicPhysicalOperators.scala Refactored GpuProjectAstExec to use a new RetryableCompiledAstExpressions helper that recompiles AST expressions on retry; switches from withRetry to GpuProjectExec.runWithSplitRetry for split-retry support; adds compile/compute timing metrics.
sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala Adds convertToAst for decimal-to-decimal and Int→Long casts, along with canCastToAst and decimalCastToAst helpers; includes precision/scale validation and RESCALE/PRECISION_CHECK JIT operations.
sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuOverrides.scala Widens AST type signatures for Alias, BoundReference, AttributeReference to include DECIMAL_128; adds JIT-gated AST support for ShiftLeft, ShiftRight, Coalesce, and If; tightens ANSI arithmetic fallback conditions.
sql-plugin/src/main/scala/com/nvidia/spark/rapids/literals.scala Adds decimal literal support to GpuLiteral.convertToAst, but the path is currently gated out in GpuOverrides; the null-BigInteger case passed to ast.Literal.ofDecimal may NPE if the gate is ever relaxed.
sql-plugin/src/main/spark330/scala/com/nvidia/spark/rapids/shims/DecimalArithmeticOverrides.scala Promotes IntegralDivide and Remainder to AST-capable with ANSI JIT gating; IntegralDivide uses supportsAnsiArithmeticAst(a.dataType) (output type) instead of the more precise shouldUseAnsiDivModAst used in the spark330db counterpart.
sql-plugin/src/main/scala/com/nvidia/spark/rapids/RapidsConf.scala Adds ENABLE_PROJECT_AST_ANSI_ARITHMETIC internal config and isLibcudfJitEnabled env-var check; marks the new config .internal() and defaults to false as expected for new features.
integration_tests/src/main/python/ast_test.py Adds comprehensive JIT AST integration tests for coalesce, IF nullify/else, nullif, decimal cast, shift, ANSI arithmetic, div/mod including error-path tests for zero-division and overflow.
sql-plugin/src/main/scala/org/apache/spark/sql/rapids/arithmetic.scala Adds convertToAst overrides for unary/binary arithmetic ops (NEG, ABS, ADD, SUB, MUL, DIV, MOD) to emit ANSI JIT AST nodes when ANSI+JIT is enabled and the type is Int/Long.
sql-plugin/src/main/scala/org/apache/spark/sql/rapids/bitwise.scala Adds convertToAst to GpuShiftBase that masks shift distance per Java semantics and widens to INT64 for Long shifts; exposes astShiftOp override point for ShiftLeft/ShiftRight.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[GpuProjectExecMeta.convertToGpu] --> B{isProjectAstEnabled?}
    B -- No --> Z[GpuProjectExec]
    B -- Yes --> C{canUseAnsiJitAst?}
    C -- No --> W[warn: LIBCUDF_JIT_ENABLED missing]
    C -- Yes --> D{allReturnTypesFixedWidth AND canThisBeAst?}
    D -- No --> Y[log AST fallback reason]
    Y --> Z
    D -- Yes --> E[GpuProjectAstExec]
    E --> F[RetryableCompiledAstExpressions.compile]
    F --> G{JIT ops present?}
    G -- Yes --> H[cudf JIT compile JitOperator.ADD/SUB/MUL etc]
    G -- No --> I[cudf non-JIT compile]
    H & I --> J[computeColumns per batch]
    J --> K{OOM?}
    K -- No --> L[Return projected batch]
    K -- Yes --> M[runWithSplitRetry: split by rows, restore = recompile]
    M --> F
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[GpuProjectExecMeta.convertToGpu] --> B{isProjectAstEnabled?}
    B -- No --> Z[GpuProjectExec]
    B -- Yes --> C{canUseAnsiJitAst?}
    C -- No --> W[warn: LIBCUDF_JIT_ENABLED missing]
    C -- Yes --> D{allReturnTypesFixedWidth AND canThisBeAst?}
    D -- No --> Y[log AST fallback reason]
    Y --> Z
    D -- Yes --> E[GpuProjectAstExec]
    E --> F[RetryableCompiledAstExpressions.compile]
    F --> G{JIT ops present?}
    G -- Yes --> H[cudf JIT compile JitOperator.ADD/SUB/MUL etc]
    G -- No --> I[cudf non-JIT compile]
    H & I --> J[computeColumns per batch]
    J --> K{OOM?}
    K -- No --> L[Return projected batch]
    K -- Yes --> M[runWithSplitRetry: split by rows, restore = recompile]
    M --> F
Loading

Reviews (1): Last reviewed commit: "use new correctness branch" | Re-trigger Greptile

Comment on lines 262 to 270

private def isColumnSizeOverflow(ex: Throwable): Boolean =
ex.isInstanceOf[CudfColumnSizeOverflowException]
private def isColumnSizeOverflow(ex: Throwable): Boolean = ex match {
case e: CudfColumnSizeOverflowException =>
// JNI maps std::overflow_error to CudfColumnSizeOverflowException, but transform UDF
// arithmetic errors should propagate instead of split-retrying as column size overflows.
!Option(e.getMessage).exists(_.contains("error in transform UDF"))
case _ => false
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Fragile string-based exception routing for retry suppression

The filter !Option(e.getMessage).exists(_.contains("error in transform UDF")) relies on the cuDF JIT runtime producing a specific error message string to distinguish a JIT arithmetic overflow from a legitimate column-size overflow. If rapidsai/cudf#22224 changes this message (e.g., during ANSI JIT stabilization or localization), two silent failures become possible: (1) JIT arithmetic overflow errors are misclassified as column-size overflows and trigger unnecessary split-retries, or (2) a real CudfColumnSizeOverflowException that happens to contain that substring is incorrectly suppressed. Since this depends on an upstream API that is explicitly named as "still under review," the message contract is not stable.

Comment on lines +211 to +217
("lhs", TypeSig.LONG + TypeSig.DECIMAL_128, TypeSig.LONG + TypeSig.DECIMAL_128),
("rhs", TypeSig.LONG + TypeSig.DECIMAL_128, TypeSig.LONG + TypeSig.DECIMAL_128)),
(a, conf, p, r) => new BinaryExprMeta[IntegralDivide](a, conf, p, r) {
(a, conf, p, r) => new BinaryAstExprMeta[IntegralDivide](a, conf, p, r) {
override def tagSelfForAst(): Unit = {
super.tagSelfForAst()
if (!SQLConf.get.ansiEnabled || !conf.isProjectAstAnsiArithmeticEnabled ||
!GpuAnsi.supportsAnsiArithmeticAst(a.dataType)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 IntegralDivide AST gate uses a weaker check than the spark330db shim

spark330 checks !GpuAnsi.supportsAnsiArithmeticAst(a.dataType) (output type = LONG, always true for IntegralDivide), while spark330db uses !GpuAnsi.shouldUseAnsiDivModAst(...), which also validates that LHS and RHS types match and are themselves supported. Today the ExprChecks AST signature limits inputs to LONG, so the weaker check is safe, but the inconsistency across shims means a future type-signature widening in this shim could silently skip the input-type guard. Using shouldUseAnsiDivModAst here would align both shims.

Comment on lines 744 to +751
case LongType => ast.Literal.ofLong(value.asInstanceOf[java.lang.Long])
case FloatType => ast.Literal.ofFloat(value.asInstanceOf[java.lang.Float])
case DoubleType => ast.Literal.ofDouble(value.asInstanceOf[java.lang.Double])
case dt: DecimalType =>
val unscaledValue = value match {
case null => null
case d: Decimal => d.toBigDecimal.bigDecimal.unscaledValue()
case d: java.math.BigDecimal => d.unscaledValue()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Null BigInteger passed to ast.Literal.ofDecimal when value is null

When value is null, unscaledValue is null, and ast.Literal.ofDecimal(DecimalUtil.createCudfDecimal(dt), null) is called. The cuDF Java binding behavior for a null BigInteger argument is not specified in the change description, and the PR explicitly blocks decimal literals in AST via GpuOverrides (willNotWorkInAst), so this path is currently unreachable. However, a future enablement of decimal literals in AST would hit this NPE (or silently wrong-value) path. Consider either throwing explicitly on null or delegating null-decimal literals to a cuDF null-literal API.

Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
# Conflicts:
#	integration_tests/src/main/python/ast_test.py
Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
Signed-off-by: Haoyang Li <haoyangl@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants