Skip to content

Commit 8113b9c

Browse files
mgaido91gatorsmile
authored andcommitted
[SPARK-25605][TESTS] Run cast string to timestamp tests for a subset of timezones
## What changes were proposed in this pull request? The test `cast string to timestamp` used to run for all time zones. So it run for more than 600 times. Running the tests for a significant subset of time zones is probably good enough and doing this in a randomized manner enforces anyway that we are going to test all time zones in different runs. ## How was this patch tested? the test time reduces to 11 seconds from more than 2 minutes Closes apache#22631 from mgaido91/SPARK-25605. Authored-by: Marco Gaido <[email protected]> Signed-off-by: gatorsmile <[email protected]>
1 parent f27d96b commit 8113b9c

File tree

1 file changed

+3
-1
lines changed
  • sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+3
-1
lines changed

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package org.apache.spark.sql.catalyst.expressions
2020
import java.sql.{Date, Timestamp}
2121
import java.util.{Calendar, Locale, TimeZone}
2222

23+
import scala.util.Random
24+
2325
import org.apache.spark.SparkFunSuite
2426
import org.apache.spark.sql.Row
2527
import org.apache.spark.sql.catalyst.InternalRow
@@ -110,7 +112,7 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
110112
}
111113

112114
test("cast string to timestamp") {
113-
for (tz <- ALL_TIMEZONES) {
115+
for (tz <- Random.shuffle(ALL_TIMEZONES).take(50)) {
114116
def checkCastStringToTimestamp(str: String, expected: Timestamp): Unit = {
115117
checkEvaluation(cast(Literal(str), TimestampType, Option(tz.getID)), expected)
116118
}

0 commit comments

Comments
 (0)