MaxGekk commented on a change in pull request #32945:
URL: https://github.com/apache/spark/pull/32945#discussion_r654150276



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/RandomDataGenerator.scala
##########
@@ -284,7 +285,10 @@ object RandomDataGenerator {
         new CalendarInterval(months, days, ns)
       })
       case _: DayTimeIntervalType => Some(() => Duration.of(rand.nextLong(), 
ChronoUnit.MICROS))
-      case _: YearMonthIntervalType => Some(() => 
Period.ofMonths(rand.nextInt()).normalized())
+      case YearMonthIntervalType(_, YEAR) =>
+        val period = Period.ofMonths(rand.nextInt()).normalized()
+        Some(() => Period.ofYears(period.getYears).normalized())

Review comment:
       And I guess that `.normalized()` is not needed since we don't have other 
fields - so nothing to normalize.

##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/RandomDataGenerator.scala
##########
@@ -284,7 +285,9 @@ object RandomDataGenerator {
         new CalendarInterval(months, days, ns)
       })
       case _: DayTimeIntervalType => Some(() => Duration.of(rand.nextLong(), 
ChronoUnit.MICROS))
-      case _: YearMonthIntervalType => Some(() => 
Period.ofMonths(rand.nextInt()).normalized())
+      case YearMonthIntervalType(_, YEAR) =>
+        Some(() => Period.ofYears(rand.nextInt() / 12).normalized())

Review comment:
       12 -> MONTHS_PER_YEAR




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

Reply via email to