Skip to content

Add decimal remainder and checked_remainder for Spark arithmetic #16354

@n0r0shi

Description

@n0r0shi

Description

Description:
Part of #3869

Description

Spark's % (remainder/modulo) operator supports decimal types, but Velox currently
only has remainder for integer and floating-point types — not for decimals.

In Spark's ANSI mode (spark.sql.ansi.enabled=true), decimal remainder should raise
an error on division by zero rather than returning null. This requires both a regular
and a checked variant.

This follows the same pattern established by:

Scope

  • remainder for all decimal input combinations (short/long × short/long)
  • checked_remainder for all decimal input combinations
  • Both allowPrecisionLoss and denyPrecisionLoss variants
  • Division by zero: null (non-checked) / throw (checked)
  • int128 fast path with int256 fallback for rescaling overflow

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