MaxGekk commented on a change in pull request #32212:
URL: https://github.com/apache/spark/pull/32212#discussion_r615272903
##########
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)
})
case YearMonthIntervalType => Some(() => {
Review comment:
The same here:
```scala
case YearMonthIntervalType => Some(() =>
Period.ofMonths(rand.nextInt()))
```
--
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]