This is an automated email from the ASF dual-hosted git repository.

wenchen pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.0 by this push:
     new 53059e3  [SPARK-31117][SQL][TEST] reduce the test time of 
DateTimeUtilsSuite
53059e3 is described below

commit 53059e39180604c6676bb644c831caa9265437aa
Author: Wenchen Fan <[email protected]>
AuthorDate: Wed Mar 11 23:47:13 2020 +0800

    [SPARK-31117][SQL][TEST] reduce the test time of DateTimeUtilsSuite
    
    `DateTimeUtilsSuite.daysToMicros and microsToDays` takes 30 seconds, which 
is too long for a UT.
    
    This PR changes the test to check random data, to reduce testing time. Now 
this test takes 1 second.
    
    make test faster
    
    no
    
    N/A
    
    Closes #27873 from cloud-fan/test.
    
    Authored-by: Wenchen Fan <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
    (cherry picked from commit 5be0d04f16dce1f2a3ad94669b6cff7460287397)
    Signed-off-by: Wenchen Fan <[email protected]>
---
 .../org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala     | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
index d98cd0a..a88a8dd 100644
--- 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/util/DateTimeUtilsSuite.scala
@@ -622,10 +622,12 @@ class DateTimeUtilsSuite extends SparkFunSuite with 
Matchers with SQLHelper {
       "MIT" -> Set(15338))
     for (tz <- ALL_TIMEZONES) {
       val skipped = skipped_days.getOrElse(tz.getID, Set.empty)
-      (-20000 to 20000).foreach { d =>
+      val testingData = Seq(-20000, 20000) ++
+        (1 to 1000).map(_ => (math.random() * 40000 - 20000).toInt)
+      testingData.foreach { d =>
         if (!skipped.contains(d)) {
           assert(millisToDays(daysToMillis(d, tz.toZoneId), tz.toZoneId) === d,
-            s"Round trip of ${d} did not work in tz ${tz}")
+            s"Round trip of $d did not work in tz $tz")
         }
       }
     }


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

Reply via email to