dongjoon-hyun commented on a change in pull request #24311: [SPARK-27401][SQL] 
Refactoring conversion of Timestamp to/from java.sql.Timestamp
URL: https://github.com/apache/spark/pull/24311#discussion_r272849594
 
 

 ##########
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/LiteralGenerator.scala
 ##########
 @@ -102,8 +102,14 @@ object LiteralGenerator {
   lazy val dateLiteralGen: Gen[Literal] =
     for { d <- Arbitrary.arbInt.arbitrary } yield Literal.create(new Date(d), 
DateType)
 
-  lazy val timestampLiteralGen: Gen[Literal] =
-    for { t <- Arbitrary.arbLong.arbitrary } yield Literal.create(new 
Timestamp(t), TimestampType)
+  private def yearToMillis(year: Long): Long = {
+    year * 365 * 24 * 3600 * 1000L
+  }
+
+  lazy val timestampLiteralGen: Gen[Literal] = {
+    for { millis <- Gen.choose(yearToMillis(-9999), yearToMillis(10000)) }
+      yield Literal.create(new Timestamp(millis), TimestampType)
+  }
 
 Review comment:
   That's the exact reason you should not put that in this PR, @MaxGekk .
   Please do that improvement in another PR first. And do the refactoring PR 
later.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to