Skip to content

Add checked_multiply for Spark decimal types #16306

@n0r0shi

Description

@n0r0shi

Description

Part of #3869

Description

PR #10083 added checked_add, checked_subtract, checked_multiply, and
checked_divide for integer and floating-point types to support Spark's ANSI mode.
However, other arithmetic "checked" operators with decimal type were not included.

In Spark's ANSI mode (spark.sql.ansi.enabled=true), decimal arithmetic overflow
should raise an error rather than returning null. Decimal multiplication
goes through CheckOverflow(BinaryArithmetic, decimalType, nullOnOverflow=false),
which requires a checked variant that throws on overflow.

Currently, the existing multiply for decimal types returns null on overflow
(matching Spark's default non-ANSI behavior). We need decimal checked_multiply
that returns an error status on overflow instead. This follows the same pattern
established by checked_divide (PR #14935) and checked_add/checked_subtract
(PR #16302).

Scope

  • checked_multiply for all decimal input combinations (short/long x short/long)
  • Both allowPrecisionLoss and denyPrecisionLoss variants

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions