ycli12 opened a new pull request, #56921:
URL: https://github.com/apache/spark/pull/56921

   ### 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`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to