Skip to content

[SPARK-56615][SQL] Throw overflow errors for ceil and floor#56921

Draft
ycli12 wants to merge 1 commit into
apache:masterfrom
ycli12:codex/spark-ceil-floor-overflow
Draft

[SPARK-56615][SQL] Throw overflow errors for ceil and floor#56921
ycli12 wants to merge 1 commit into
apache:masterfrom
ycli12:codex/spark-ceil-floor-overflow

Conversation

@ycli12

@ycli12 ycli12 commented Jul 1, 2026

Copy link
Copy Markdown

What changes were proposed in this pull request?

This PR makes CEIL and FLOOR throw ARITHMETIC_OVERFLOW for out-of-range DOUBLE inputs when ANSI mode is enabled. The non-ANSI path keeps the existing JVM cast behavior.

The change covers both interpreted evaluation and code generation, and updates the V2 expression conversion call sites after adding the new failOnError parameter.

Closes #56615.

Why are the changes needed?

In ANSI mode, Spark should report arithmetic overflow instead of silently converting out-of-range DOUBLE results to saturated Long values. CEIL and FLOOR were missing this overflow check.

Does this PR introduce any user-facing change?

Yes. With ANSI mode enabled, CEIL and FLOOR now fail with ARITHMETIC_OVERFLOW when the rounded DOUBLE result cannot be represented as Long. With ANSI mode disabled, the previous behavior is preserved.

How was this patch tested?

  • JAVA_HOME=/opt/homebrew/opt/openjdk@17 LC_ALL=C ./build/sbt "catalyst/clean" "catalyst/compile"
  • JAVA_HOME=/opt/homebrew/opt/openjdk@17 LC_ALL=C ./build/sbt "catalyst/Test/testOnly org.apache.spark.sql.catalyst.expressions.MathExpressionsSuite -- -z ceil"
  • JAVA_HOME=/opt/homebrew/opt/openjdk@17 LC_ALL=C ./build/sbt "catalyst/Test/testOnly org.apache.spark.sql.catalyst.expressions.MathExpressionsSuite -- -z floor"
  • JAVA_HOME=/opt/homebrew/opt/openjdk@17 LC_ALL=C ./build/sbt "catalyst/Test/testOnly org.apache.spark.sql.catalyst.expressions.MathExpressionsSuite"
  • git diff --check

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.

[SQL] Ceiling and floor do not throw on overflow

1 participant