jiangxt2 commented on code in PR #58029:
URL: https://github.com/apache/spark/pull/58029#discussion_r3797025944
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -684,6 +685,10 @@ case class Cast(
with ToStringBase
with SupportQueryContext
with QueryErrorsBase {
+ private val MICROS_PER_SECOND_BD =
java.math.BigDecimal.valueOf(MICROS_PER_SECOND)
+ private val LONG_MAX_BD = java.math.BigDecimal.valueOf(Long.MaxValue)
+ private val LONG_MIN_BD = java.math.BigDecimal.valueOf(Long.MinValue)
Review Comment:
I had checked for an existing shared definition for these BigDecimal
boundary constants before adding them, but could not find one, so I
intentionally kept them local to Cast at first. To address the placement
concern, I removed the need for boundary constants altogether: the shared
decimal-to-timestamp arithmetic is now centralized in
DateTimeUtils.decimalToTimestamp, which scales the value to microseconds,
truncates toward zero with toBigInteger, and performs an exact Long conversion
with longValueExact(). Both the interpreted and codegen Cast paths, as well as
VariantGet, use this helper, so no Cast-specific boundary constants remain.
--
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]