viirya commented on code in PR #59334:
URL: https://github.com/apache/spark/pull/59334#discussion_r4244140029
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/types/DecimalSuite.scala:
##########
@@ -446,6 +446,24 @@ class DecimalSuite extends SparkFunSuite with
PrivateMethodTester with SQLHelper
}
}
+ test("UTF8String to Decimal with exponent near Int.MaxValue") {
+ // The number of integral digits (precision - scale) of these values
overflows Int.
+ Seq("1e2147483647", "-1E+2147483647", "12e2147483647", "1.5e2147483647",
+ "1e2147483648").foreach { string =>
Review Comment:
Good catch, thanks. My local runs used JDK 21, where `new
BigDecimal("1e2147483648")` parses with scale `Int.MinValue`; JDK 17 rejects it
with `NumberFormatException` before the fast-fail runs. I replaced
`'1e2147483648'` with `'12e2147483647'` (precision 2, scale -2147483647) and
dropped `'0.0e2147483648'`; `'0e2147483647'` still covers the zero case with an
`Int`-overflowing digit count, so `'0.0e2147483647'` (whose count, 2147483647,
fits in `Int`) wouldn't add coverage. On JDK 17, the updated tests pass, and
all four fail again if `numDigitsInIntegralPart` is reverted to `Int`
arithmetic. I also corrected the PR description, which mentioned the JDK
21-only `Underflow` failure.
--
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]