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 2019/04/07 20:03:27 UTC

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

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 the 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:
users@infra.apache.org


With regards,
Apache Git Services

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