You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/04/18 01:29:14 UTC

[GitHub] [spark] beliefer commented on a change in pull request #32212: [SPARK-35116] The generated data fits the precision of DayTimeIntervalType in spark

beliefer commented on a change in pull request #32212:
URL: https://github.com/apache/spark/pull/32212#discussion_r615325950



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/RandomDataGenerator.scala
##########
@@ -275,8 +275,13 @@ object RandomDataGenerator {
       case DayTimeIntervalType => Some(() => {
         val maxSeconds = Duration.ofDays(106751991).getSeconds
         val seconds = rand.nextLong() % maxSeconds
+        // The precision of java.time.Duration is nanosecond, but when it is used as
+        // DayTimeIntervalType in Spark, it is microsecond. Here by following the behavior
+        // of DurationConverter to achieve consistency
         val nanoAdjustment = rand.nextLong() % 999999000
-        Duration.ofSeconds(seconds, nanoAdjustment)
+        val duration = Duration.ofSeconds(seconds, nanoAdjustment)
+        val micros = IntervalUtils.durationToMicros(duration)
+        IntervalUtils.microsToDuration(micros)
       })

Review comment:
       OK




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org