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

   ### What changes were proposed in this pull request?
   
   This PR makes one-argument `ceil` and `floor` check the rounded `Double` 
result before converting it to `Long` when ANSI mode is enabled.
   
   Both interpreted evaluation and generated code now throw 
`ARITHMETIC_OVERFLOW` when the rounded value is outside the `Long` range. 
Non-ANSI behavior continues to use the existing Java cast behavior.
   
   Closes #56615.
   
   ### Why are the changes needed?
   
   In ANSI mode, `ceil(1e30)` and `floor(-1e30)` currently saturate to 
`Long.MaxValue` / `Long.MinValue` instead of failing. That differs from other 
ANSI arithmetic overflow paths, such as `abs`, and hides overflow from users.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. In ANSI mode, `ceil` and `floor` now throw `SparkArithmeticException` 
with `ARITHMETIC_OVERFLOW` for `Double` inputs whose rounded value cannot fit 
in `Long`. Non-ANSI behavior is unchanged.
   
   ### How was this patch tested?
   
   - `./build/sbt "catalyst/compile"`
   - `./build/sbt "catalyst/Test/testOnly 
org.apache.spark.sql.catalyst.expressions.MathExpressionsSuite -- -z ceil"` 
(JUnit report: 55 tests, 0 failures, 0 errors)
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex


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