Skip to content

[VL] Support ANSI and TRY mode for decimal Add/Subtract/Multiply#12192

Open
n0r0shi wants to merge 1 commit into
apache:mainfrom
n0r0shi:checked-decimal-add-subtract
Open

[VL] Support ANSI and TRY mode for decimal Add/Subtract/Multiply#12192
n0r0shi wants to merge 1 commit into
apache:mainfrom
n0r0shi:checked-decimal-add-subtract

Conversation

@n0r0shi
Copy link
Copy Markdown

@n0r0shi n0r0shi commented May 30, 2026

Summary

Routes decimal Add, Subtract, and Multiply to Velox's checked_add, checked_subtract, and checked_multiply for both ANSI and TRY eval modes:

  • ANSI mode (nullOnOverflow=false): checked_* throw on overflow, matching Spark's ANSI behavior.
  • TRY mode: try(checked_*) returns null on overflow, using the same try(checked_*) pattern as integer arithmetic.

Previously, TRY mode for decimal arithmetic relied on a tryCast in CheckOverflowTransformer to detect overflow. This change uses the consistent try(checked_*) pattern instead.

Dependencies

Context

This supersedes #11705 (stale-closed draft). Rebased on current main; force-push of the same branch broke the reopen path, so opening as a new PR.

Scope extended to include Multiply (vs original Add/Subtract only) since #16307 is also merged.

How was this patch tested?

ArithmeticAnsiValidateSuite (new) covers ANSI + TRY mode for decimal Add/Subtract/Multiply.

@github-actions github-actions Bot added CORE works for Gluten Core VELOX labels May 30, 2026
@github-actions
Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@n0r0shi
Copy link
Copy Markdown
Author

n0r0shi commented May 30, 2026

@baibaichen this is a sub-task of #10134; wires Velox's now-merged checked_add / checked_subtract (facebookincubator/velox#16302) into Gluten's ANSI and TRY paths for decimal Add/Subtract, using the same try(checked_*) pattern already in place for integer arithmetic. Would appreciate your review when you have time.
cc @FelixYBW @malinjawi

Routes decimal Add, Subtract, and Multiply to Velox's checked_add,
checked_subtract, and checked_multiply functions for both ANSI and TRY
eval modes:

- ANSI mode (nullOnOverflow=false): checked_* throw on overflow,
  matching Spark's ANSI behavior.
- TRY mode: try(checked_*) returns null on overflow, using the same
  try(checked_*) pattern as integer arithmetic.

Previously, TRY mode for decimal arithmetic relied on a tryCast in
CheckOverflowTransformer to detect overflow. This change uses the
consistent try(checked_*) pattern instead.

Depends on:
- facebookincubator/velox#16302 — checked_add and checked_subtract
  for decimal types (merged)
- facebookincubator/velox#16307 — checked_multiply for decimal types
  (merged)
@n0r0shi n0r0shi force-pushed the checked-decimal-add-subtract branch from 61c39ac to 6d0f17f Compare May 30, 2026 05:48
@github-actions
Copy link
Copy Markdown

Run Gluten Clickhouse CI on x86

@n0r0shi n0r0shi changed the title [VL] Support ANSI and TRY mode for decimal Add/Subtract [VL] Support ANSI and TRY mode for decimal Add/Subtract/Multiply May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CORE works for Gluten Core VELOX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant