Skip to content

Commit 4a471e0

Browse files
committed
[SPARK-55910][SQL][TESTS] Merge SQLTestUtilsBase/SQLTestUtils into QueryTestBase/QueryTest
### What changes were proposed in this pull request? Merge both test utility hierarchies into one: - Move all `SQLTestUtilsBase` methods into `QueryTestBase` - Change `QueryTest` from abstract class to trait, move all `SQLTestUtils` methods into it - Make `SQLTestUtilsBase` and `SQLTestUtils` thin empty aliases **Changes in `QueryTest.scala`:** *`QueryTestBase` (trait):* - Add `Eventually`, `BeforeAndAfterAll`, `SQLTestData` mixins - Move all methods from `SQLTestUtilsBase`: `testImplicits`, `sql`, `sparkContext`, `withSQLConf`, `withTable`, `withView`, `withTempView`, `withGlobalTempView`, `withDatabase`, `withNamespace`, `withCache`, `uncacheTable`, `withTempDatabase`, `withCurrentCatalogAndNamespace`, `withLocale`, `withSessionVariable`, `withUserDefinedFunction`, `activateDatabase`, `stripSparkFilter`, `logicalPlanToSparkQuery`, `makeQualifiedPath`, `testFile`, `getLocalDirSize` *`QueryTest` (changed from abstract class to trait):* - Add `PlanTest` mixin - Move all methods from `SQLTestUtils`: `setupTestData`, `loadTestData`, `beforeAll`, `withTempDir`, `testWithWholeStageCodegenOnAndOff`, `testQuietly`, `test` override (DisableAdaptiveExecution), `testWithUninterruptibleThread`, `withResourceTempPath`, `waitForTasksToFinish`, `withTempPaths` - Fix `getCurrentClassCallSitePattern` and `getNextLineCallSitePattern` to use `lastIndexWhere` for stack frame lookup — trait default methods may add mixin forwarder frames that shift the stack layout **Changes in `SQLTestUtils.scala`:** - `SQLTestUtilsBase` → empty trait alias of `QueryTestBase` - `SQLTestUtils` → empty trait alias of `QueryTest` - `object SQLTestUtils.compareAnswers` kept as-is **Unused import fixes:** - `AlterTableTests.scala` — removed unused `QueryTest.checkAnswer` static import - `HivePlanTest.scala` — removed unused `import spark.sql` (now inherited) ### Why are the changes needed? Consolidates two parallel test utility hierarchies (`QueryTestBase`/`QueryTest` and `SQLTestUtilsBase`/`SQLTestUtils`) into one. Previously they shared `PlanTestBase` and `SparkSessionProvider` but were maintained as separate hierarchies, causing confusion about which to extend. After this PR: ``` QueryTestBase (trait — has all base utilities from both old QueryTestBase + SQLTestUtilsBase) └── QueryTest (trait — has all test-registration methods from both old QueryTest + SQLTestUtils) ├── SQLTestUtils (empty alias) └── SQLTestUtilsBase (empty alias, also extends QueryTestBase) ``` Changing `QueryTest` from abstract class to trait enables `SQLTestUtils` to extend it directly, and allows test suites to mix in `QueryTest` alongside `SparkFunSuite` or `SparkPlanTest` without inheritance conflicts. ### Semantic change: `DisableAdaptiveExecution` tag handling The `test()` override that honors `DisableAdaptiveExecution` previously lived only on `SQLTestUtils`. Moving it onto `QueryTest` means every `extends QueryTest` suite now honors the tag — including ones that previously didn't (e.g., `HivePlanTest` and a handful of connector suites that extend `QueryTest` directly without going through `SharedSparkSession`). No live regression today since all current `DisableAdaptiveExecution` usages go through `SharedSparkSession`, but this is a semantic expansion beyond just moving methods between traits. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? - CI compilation across all modules - Locally verified affected tests pass (DataFrameFunctionsSuite, ReplaceIntegerLiteralsWithOrdinalsDataframeSuite, QueryTestSuite) ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (claude-opus-4-6) Closes #55381 from zhengruifeng/sql_merge_utils_into_query. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
1 parent 5365b3f commit 4a471e0

File tree

4 files changed

+461
-480
lines changed

4 files changed

+461
-480
lines changed

0 commit comments

Comments
 (0)