Skip to content

Commit 4a9a76d

Browse files
committed
Move loadTestDataBeforeTests/setupTestData/beforeAll to QueryTestBase
These don't depend on AnyFunSuite — they only use BeforeAndAfterAll and SQLTestData, both already in QueryTestBase. Co-authored-by: Isaac
1 parent 3f880f9 commit 4a9a76d

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

sql/core/src/test/scala/org/apache/spark/sql/QueryTest.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,24 @@ trait QueryTestBase extends PlanTestBase
582582
s"${cs.getClassName}.${cs.getMethodName}(${cs.getFileName}:${cs.getLineNumber + lines})")
583583
}
584584

585+
// Whether to materialize all test data before the first test is run
586+
private var loadTestDataBeforeTests = false
587+
588+
protected override def beforeAll(): Unit = {
589+
super.beforeAll()
590+
if (loadTestDataBeforeTests) {
591+
loadTestData()
592+
}
593+
}
594+
595+
/**
596+
* Materialize the test data immediately after the `SQLContext` is set up.
597+
* This is necessary if the data is accessed by name but not through direct reference.
598+
*/
599+
protected def setupTestData(): Unit = {
600+
loadTestDataBeforeTests = true
601+
}
602+
585603
}
586604

587605
abstract class QueryTest extends SparkFunSuite with QueryTestBase with PlanTest

sql/core/src/test/scala/org/apache/spark/sql/test/SQLTestUtils.scala

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ private[sql] trait SQLTestUtilsBase extends QueryTestBase { self: Suite => }
4545
* code base.
4646
*/
4747
private[sql] trait SQLTestUtils extends SparkFunSuite with SQLTestUtilsBase with PlanTest {
48-
// Whether to materialize all test data before the first test is run
49-
private var loadTestDataBeforeTests = false
50-
51-
protected override def beforeAll(): Unit = {
52-
super.beforeAll()
53-
if (loadTestDataBeforeTests) {
54-
loadTestData()
55-
}
56-
}
57-
5848
/**
5949
* Creates a temporary directory, which is then passed to `f` and will be deleted after `f`
6050
* returns.
@@ -80,14 +70,6 @@ private[sql] trait SQLTestUtils extends SparkFunSuite with SQLTestUtilsBase with
8070
}
8171
}
8272

83-
/**
84-
* Materialize the test data immediately after the `SQLContext` is set up.
85-
* This is necessary if the data is accessed by name but not through direct reference.
86-
*/
87-
protected def setupTestData(): Unit = {
88-
loadTestDataBeforeTests = true
89-
}
90-
9173
/**
9274
* Disable stdout and stderr when running the test. To not output the logs to the console,
9375
* ConsoleAppender's `follow` should be set to `true` so that it will honor reassignments of

0 commit comments

Comments
 (0)