EaswarKilari commented on code in PR #60212:
URL: https://github.com/apache/spark/pull/60212#discussion_r4505747585
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala:
##########
@@ -1171,23 +1171,29 @@ object DateTimeUtils extends SparkDateTimeUtils {
/**
* Creates a TIME value from seconds since midnight (decimal type).
* @param seconds Seconds (0 to 86399.999999)
- * @return Nanoseconds since midnight
+ * @return Nanoseconds since midnight, truncated to microsecond precision
*/
- def timeFromSeconds(seconds: Decimal): Long =
withTimeConversionErrorHandling {
- val operand = new java.math.BigDecimal(NANOS_PER_SECOND)
- seconds.toJavaBigDecimal.multiply(operand).longValueExact()
+ def timeFromSeconds(seconds: Decimal): Long = {
+ val nanos = withTimeConversionErrorHandling {
+ val operand = new java.math.BigDecimal(NANOS_PER_SECOND)
+ seconds.toJavaBigDecimal.multiply(operand).longValueExact()
+ }
+ truncateTimeToPrecision(nanos, TimeType.MICROS_PRECISION)
Review Comment:
Addressed in the latest commit. Both overloads now floor to microseconds
directly on the decimal value, so already-aligned DECIMAL inputs no longer go
through an extra truncation.
--
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]