[SPARK-56615][SQL] Throw overflow errors for ceil and floor#56921
Draft
ycli12 wants to merge 1 commit into
Draft
[SPARK-56615][SQL] Throw overflow errors for ceil and floor#56921ycli12 wants to merge 1 commit into
ycli12 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR makes
CEILandFLOORthrowARITHMETIC_OVERFLOWfor out-of-rangeDOUBLEinputs 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
failOnErrorparameter.Closes #56615.
Why are the changes needed?
In ANSI mode, Spark should report arithmetic overflow instead of silently converting out-of-range
DOUBLEresults to saturatedLongvalues.CEILandFLOORwere missing this overflow check.Does this PR introduce any user-facing change?
Yes. With ANSI mode enabled,
CEILandFLOORnow fail withARITHMETIC_OVERFLOWwhen the roundedDOUBLEresult cannot be represented asLong. 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