Skip to content

Commit fd6bd17

Browse files
committed
Make QueryTestBase extend SQLTestData; simplify SQLTestUtils to pure alias
QueryTestBase now extends SQLTestData directly, so setupTestData/ loadTestData logic moves into QueryTest. SQLTestUtils and SQLTestUtilsBase become truly empty aliases with no additional members. Co-authored-by: Isaac
1 parent 1722002 commit fd6bd17

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ import org.apache.spark.util.ArrayImplicits._
6969
trait QueryTestBase extends PlanTestBase
7070
with SparkSessionProvider
7171
with Eventually
72-
with BeforeAndAfterAll { self: Suite =>
72+
with BeforeAndAfterAll
73+
with test.SQLTestData { self: Suite =>
7374

7475
protected def sparkContext = spark.sparkContext
7576

@@ -588,6 +589,23 @@ trait QueryTestBase extends PlanTestBase
588589
}
589590

590591
abstract class QueryTest extends SparkFunSuite with QueryTestBase with PlanTest {
592+
// Whether to materialize all test data before the first test is run
593+
private var loadTestDataBeforeTests = false
594+
595+
protected override def beforeAll(): Unit = {
596+
super.beforeAll()
597+
if (loadTestDataBeforeTests) {
598+
loadTestData()
599+
}
600+
}
601+
602+
/**
603+
* Materialize the test data immediately after the `SQLContext` is set up.
604+
* This is necessary if the data is accessed by name but not through direct reference.
605+
*/
606+
protected def setupTestData(): Unit = {
607+
loadTestDataBeforeTests = true
608+
}
591609

592610
/**
593611
* Creates a temporary directory, which is then passed to `f` and will be deleted after `f`

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import org.apache.spark.unsafe.types.CalendarInterval
3030
/**
3131
* A collection of sample data used in SQL tests.
3232
*/
33-
private[sql] trait SQLTestData extends SparkSessionProvider { self =>
33+
trait SQLTestData extends SparkSessionProvider { self =>
3434
import SQLTestData._
3535

3636
// Note: all test data should be lazy because the SparkSession is not set up yet.

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

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,17 @@ import org.apache.spark.sql.{QueryTest, QueryTestBase, Row}
2424
/**
2525
* Helper trait that can be extended by all external SQL test suites.
2626
*
27-
* This is now a thin wrapper around [[QueryTestBase]] that also provides [[SQLTestData]].
27+
* This is now an alias for [[QueryTestBase]].
2828
*/
29-
private[sql] trait SQLTestUtilsBase
30-
extends QueryTestBase
31-
with SQLTestData { self: Suite =>
32-
}
29+
private[sql] trait SQLTestUtilsBase extends QueryTestBase { self: Suite => }
3330

3431
/**
3532
* Helper trait that should be extended by all SQL test suites within the Spark
3633
* code base.
3734
*
38-
* This is now a thin wrapper around [[QueryTest]] that also provides [[SQLTestData]].
35+
* This is now an alias for [[QueryTest]].
3936
*/
40-
private[sql] trait SQLTestUtils extends QueryTest with SQLTestUtilsBase {
41-
// Whether to materialize all test data before the first test is run
42-
private var loadTestDataBeforeTests = false
43-
44-
protected override def beforeAll(): Unit = {
45-
super.beforeAll()
46-
if (loadTestDataBeforeTests) {
47-
loadTestData()
48-
}
49-
}
50-
51-
/**
52-
* Materialize the test data immediately after the `SQLContext` is set up.
53-
* This is necessary if the data is accessed by name but not through direct reference.
54-
*/
55-
protected def setupTestData(): Unit = {
56-
loadTestDataBeforeTests = true
57-
}
58-
}
37+
private[sql] trait SQLTestUtils extends QueryTest
5938

6039
private[sql] object SQLTestUtils {
6140

0 commit comments

Comments
 (0)