Skip to content

[SPARK-55910][SQL][TESTS] Merge SQLTestUtils into QueryTest#55269

Draft
zhengruifeng wants to merge 15 commits intoapache:masterfrom
zhengruifeng:sql_util_and_query
Draft

[SPARK-55910][SQL][TESTS] Merge SQLTestUtils into QueryTest#55269
zhengruifeng wants to merge 15 commits intoapache:masterfrom
zhengruifeng:sql_util_and_query

Conversation

@zhengruifeng
Copy link
Copy Markdown
Contributor

@zhengruifeng zhengruifeng commented Apr 9, 2026

What changes were proposed in this pull request?

Merge SQLTestUtils/SQLTestUtilsBase utility methods into QueryTest/QueryTestBase, making SQLTestUtils a thin alias of QueryTest.

Before:

trait QueryTestBase extends PlanTestBase with SparkSessionProvider
abstract class QueryTest extends SparkFunSuite with QueryTestBase

trait SQLTestUtilsBase extends Eventually with BeforeAndAfterAll with SQLTestData with PlanTestBase
trait SQLTestUtils extends SparkFunSuite with SQLTestUtilsBase with PlanTest

QueryTest and SQLTestUtils were independent — test suites had to mix in both.

After:

trait QueryTestBase extends PlanTestBase with SparkSessionProvider with Eventually with BeforeAndAfterAll
abstract class QueryTest extends SparkFunSuite with QueryTestBase with PlanTest

trait SQLTestUtilsBase extends QueryTestBase with SQLTestData   // thin alias
trait SQLTestUtils extends QueryTest with SQLTestUtilsBase      // thin alias + test data setup

All utility methods (withTable, withView, withSQLConf, checkAnswer, testImplicits, etc.) now live in QueryTest/QueryTestBase. SQLTestUtils retains only 3 members for SQLTestData loading (setupTestData, loadTestDataBeforeTests, beforeAll).

Why are the changes needed?

SQLTestUtils and QueryTest served complementary roles (test infrastructure vs query validation) but were always used together. Merging them into QueryTest reduces the number of traits test suites need to mix in and simplifies the test class hierarchy.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing tests. This is a pure refactor — all methods are moved as-is with no behavioral changes. SQLTestUtils and SQLTestUtilsBase remain as backward-compatible aliases.

Was this patch authored or co-authored using generative AI tooling?

Co-authored-by: Claude code (Opus 4.6)

@zhengruifeng zhengruifeng marked this pull request as draft April 9, 2026 03:58
Move waitForTasksToFinish, withTempPaths, getCurrentClassCallSitePattern,
and getNextLineCallSitePattern into QueryTestBase since they don't depend
on AnyFunSuite.

Co-authored-by: Isaac
Remove the override that narrowed spark to classic.SparkSession.
Cast to classic.SparkSession only where needed: testImplicits,
stripSparkFilter, and logicalPlanToSparkQuery.

Co-authored-by: Isaac
…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
QueryTestBase already declares self: Suite, so SQLTestUtilsBase
inherits the constraint.

Co-authored-by: Isaac
After removing testImplicits from QueryTestBase, it needs to be
defined in the session-providing traits instead.

Co-authored-by: Isaac
Move SparkFunSuite-dependent methods (test overrides, withTempDir,
setupTestData, etc.) back to SQLTestUtils to avoid class hierarchy
conflicts. QueryTest class becomes a minimal SparkFunSuite + QueryTestBase
+ PlanTest combination.

Co-authored-by: Isaac
These don't depend on AnyFunSuite — they only use BeforeAndAfterAll
and SQLTestData, both already in QueryTestBase.

Co-authored-by: Isaac
Methods like withTempDir, testQuietly, testWithWholeStageCodegenOnAndOff
need SparkFunSuite and are used by suites that extend SQLTestUtils
(via SharedSparkSession) without extending QueryTest. Keep them in
SQLTestUtils; QueryTest class remains minimal.

Co-authored-by: Isaac
SQLTestUtils body is now empty. Methods like withTempDir, testQuietly,
testWithWholeStageCodegenOnAndOff are in QueryTest. SparkPlanTest,
PlannerSuite, and HDFSMetadataLogSuite updated to extend QueryTest.

Co-authored-by: Isaac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant