maropu commented on a change in pull request #28060: [SPARK-31291][SQL][TEST]
Avoid load test data if test case not uses them
URL: https://github.com/apache/spark/pull/28060#discussion_r399898528
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
##########
@@ -570,82 +579,94 @@ class SQLQueryTestSuite extends QueryTest with
SharedSparkSession {
}
/** Load built-in test tables into the SparkSession. */
- private def loadTestData(session: SparkSession): Unit = {
+ private def loadTestData(session: SparkSession, testTables: Seq[String]):
Unit = {
import session.implicits._
- (1 to 100).map(i => (i, i.toString)).toDF("key",
"value").createOrReplaceTempView("testdata")
-
- ((Seq(1, 2, 3), Seq(Seq(1, 2, 3))) :: (Seq(2, 3, 4), Seq(Seq(2, 3, 4))) ::
Nil)
- .toDF("arraycol", "nestedarraycol")
- .createOrReplaceTempView("arraydata")
-
- (Tuple1(Map(1 -> "a1", 2 -> "b1", 3 -> "c1", 4 -> "d1", 5 -> "e1")) ::
- Tuple1(Map(1 -> "a2", 2 -> "b2", 3 -> "c2", 4 -> "d2")) ::
- Tuple1(Map(1 -> "a3", 2 -> "b3", 3 -> "c3")) ::
- Tuple1(Map(1 -> "a4", 2 -> "b4")) ::
- Tuple1(Map(1 -> "a5")) :: Nil)
- .toDF("mapcol")
- .createOrReplaceTempView("mapdata")
-
- session
- .read
- .format("csv")
- .options(Map("delimiter" -> "\t", "header" -> "false"))
- .schema("a int, b float")
- .load(testFile("test-data/postgresql/agg.data"))
- .createOrReplaceTempView("aggtest")
-
- session
- .read
- .format("csv")
- .options(Map("delimiter" -> "\t", "header" -> "false"))
- .schema(
- """
- |unique1 int,
- |unique2 int,
- |two int,
- |four int,
- |ten int,
- |twenty int,
- |hundred int,
- |thousand int,
- |twothousand int,
- |fivethous int,
- |tenthous int,
- |odd int,
- |even int,
- |stringu1 string,
- |stringu2 string,
- |string4 string
- """.stripMargin)
- .load(testFile("test-data/postgresql/onek.data"))
- .createOrReplaceTempView("onek")
-
- session
- .read
- .format("csv")
- .options(Map("delimiter" -> "\t", "header" -> "false"))
- .schema(
- """
- |unique1 int,
- |unique2 int,
- |two int,
- |four int,
- |ten int,
- |twenty int,
- |hundred int,
- |thousand int,
- |twothousand int,
- |fivethous int,
- |tenthous int,
- |odd int,
- |even int,
- |stringu1 string,
- |stringu2 string,
- |string4 string
- """.stripMargin)
- .load(testFile("test-data/postgresql/tenk.data"))
- .createOrReplaceTempView("tenk1")
+ if (testTables.contains("testdata")) {
+ (1 to 100).map(i => (i, i.toString)).toDF("key",
"value").createOrReplaceTempView("testdata")
+ }
+
+ if (testTables.contains("arraydata")) {
+ ((Seq(1, 2, 3), Seq(Seq(1, 2, 3))) :: (Seq(2, 3, 4), Seq(Seq(2, 3, 4)))
:: Nil)
+ .toDF("arraycol", "nestedarraycol")
+ .createOrReplaceTempView("arraydata")
Review comment:
To avoid the overhead of per-session init, we cannot just move these local
temp views into a session-independent place, e.g., global temp views?
----------------------------------------------------------------
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]