[SPARK-56591][SQL][TESTS] Remove redundant QueryTest mixin from SharedSparkSession subclasses by zhengruifeng · Pull Request #55503 · apache/spark · GitHub
Skip to content

[SPARK-56591][SQL][TESTS] Remove redundant QueryTest mixin from SharedSparkSession subclasses#55503

Open
zhengruifeng wants to merge 4 commits intoapache:masterfrom
zhengruifeng:spark-remove-redundant-querytest-mixin
Open

[SPARK-56591][SQL][TESTS] Remove redundant QueryTest mixin from SharedSparkSession subclasses#55503
zhengruifeng wants to merge 4 commits intoapache:masterfrom
zhengruifeng:spark-remove-redundant-querytest-mixin

Conversation

@zhengruifeng
Copy link
Copy Markdown
Contributor

@zhengruifeng zhengruifeng commented Apr 23, 2026

What changes were proposed in this pull request?

Since SharedSparkSession already extends QueryTest (trait SharedSparkSession extends QueryTest with SharedSparkSessionBase), mixing QueryTest in again alongside SharedSparkSession in the extends list is a no-op. Linearization:

SharedSparkSession  ->  QueryTest  ->  PlanTest -> PlanTestBase
                                    \> QueryTestBase
                                    \> SparkFunSuite
                    \>  SharedSparkSessionBase

Mechanical cleanup across 242 test files in sql-core, sql-hive, sql-hive-thriftserver, sql-connect, sql-kafka-0-10, avro, protobuf, and docker-integration-tests:

  • extends QueryTest with SharedSparkSession -> extends SharedSparkSession
  • extends QueryTest with ParquetTest with SharedSparkSession -> extends ParquetTest with SharedSparkSession (ParquetTest -> FileBasedDataSourceTest -> QueryTest, so QueryTest is already brought in twice)
  • extends QueryTest with test.SharedSparkSession -> extends test.SharedSparkSession (QueryTestSuite in QueryTest.scala)
  • multi-line variants (extends QueryTest\n with SharedSparkSession) handled the same way
  • removed the now-unused QueryTest imports where the file no longer referenced it; kept the import when the file still uses QueryTest.checkAnswer / QueryTest.compare / QueryTest.sameRows statically

Intentionally left untouched:

  • SharedSparkSession itself (its own definition)
  • traits that extend QueryTest but not SharedSparkSession (e.g. CharVarcharTestSuite, V1WriteCommandSuiteBase)

Why are the changes needed?

Removes a redundant trait mixin and the resulting dead QueryTest imports, so the extends lists faithfully describe the class hierarchy and scalastyle's unused-import check stays clean.

Does this PR introduce any user-facing change?

No. Test-only class-declaration cleanup.

How was this patch tested?

Existing tests. The affected modules compile cleanly:

build/sbt sql/Test/compile connect/Test/compile hive/Test/compile \
          avro/Test/compile protobuf/Test/compile \
          sql-kafka-0-10/Test/compile docker-integration-tests/Test/compile
build/sbt -Phive-thriftserver hive-thriftserver/Test/compile

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

Generated-by: Claude Code (model: claude-opus-4-7)

…dSparkSession subclasses

### What changes were proposed in this pull request?

Since `SharedSparkSession` already extends `QueryTest` (`trait SharedSparkSession extends QueryTest with SharedSparkSessionBase`), mixing `QueryTest` in again alongside `SharedSparkSession` in the `extends` list is a no-op.

Mechanical cleanup across 242 test files in `sql-core`, `sql-hive`, `sql-hive-thriftserver`, `sql-connect`, `sql-kafka-0-10`, `avro`, `protobuf`, and `docker-integration-tests`:

- `extends QueryTest with SharedSparkSession` -> `extends SharedSparkSession`
- `extends QueryTest with ParquetTest with SharedSparkSession` -> `extends ParquetTest with SharedSparkSession` (`ParquetTest` transitively extends `QueryTest` as well)
- `extends QueryTest with test.SharedSparkSession` -> `extends test.SharedSparkSession` (in `QueryTestSuite`)
- multi-line variants (`extends QueryTest\n  with SharedSparkSession`) handled the same way
- removed the now-unused `QueryTest` imports where the file no longer referenced it

Intentionally left untouched:
- `SharedSparkSession` itself (its own definition)
- traits that extend `QueryTest` but not `SharedSparkSession` (e.g. `CharVarcharTestSuite`, `V1WriteCommandSuiteBase`)
- files that still use `QueryTest.checkAnswer` / `QueryTest.compare` / `QueryTest.sameRows` statically (imports kept)

### Why are the changes needed?

Remove redundant trait mixin and the resulting dead `QueryTest` imports so that the `extends` lists faithfully describe the class hierarchy and scalastyle's unused-import check stays clean.

### Does this PR introduce _any_ user-facing change?

No, this only touches test-suite class declarations.

### How was this patch tested?

`build/sbt sql/Test/compile connect/Test/compile hive/Test/compile avro/Test/compile protobuf/Test/compile sql-kafka-0-10/Test/compile docker-integration-tests/Test/compile` and `build/sbt -Phive-thriftserver hive-thriftserver/Test/compile` both pass.

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

Yes, generated by Claude Code.

Co-authored-by: Isaac
@zhengruifeng zhengruifeng changed the title [SPARK-XXXXX][SQL][TESTS] Remove redundant QueryTest mixin from SharedSparkSession subclasses [SPARK-56591][SQL][TESTS] Remove redundant QueryTest mixin from SharedSparkSession subclasses Apr 23, 2026
…rt in AvroRowReaderSuite

### What changes were proposed in this pull request?

CI flagged `import org.apache.spark.sql._` in `AvroRowReaderSuite.scala` as an unused import after the prior commit removed `QueryTest` from the `extends` list — the wildcard's only consumer was `QueryTest`. Drop the wildcard. The file still imports everything it needs explicitly (`SparkConf`, `catalyst`, `types._`, `SharedSparkSession`, etc.).

### Why are the changes needed?

Fix the `-Wconf:cat=unused-imports:error` compile failure in the avro module, which cascades into every downstream `sql`/`hive` test job.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

`build/sbt avro/Test/compile` succeeds locally.

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

Generated-by: Claude Code (model: claude-opus-4-7)

Co-authored-by: Isaac
…tions after QueryTest mixin removal

### What changes were proposed in this pull request?

Two mechanical cleanups in files already touched by the QueryTest mixin removal:

1. Drop the redundant brace group from single-item imports left behind when `QueryTest, ` was removed from the import list, e.g.
   `import org.apache.spark.sql.{AnalysisException}` -> `import org.apache.spark.sql.AnalysisException` (37 files).
2. Collapse `class X\n    extends SharedSparkSession {` onto one line when the result fits within 100 chars (7 files, e.g. `MetadataResolverSuite`, `AvroRowReaderSuite`).

### Why are the changes needed?

Keeps the imports and class declarations in their canonical single-line form so reviewers do not need to flag the leftover formatting artifacts from the sed-based cleanup.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

`build/sbt sql/Test/compile avro/Test/compile connect/Test/compile` passes.

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

Generated-by: Claude Code (model: claude-opus-4-7)

Co-authored-by: Isaac
…yContextSuite

### What changes were proposed in this pull request?

`QueryContextSuite.summary of DataFrame context` asserts against a `QueryContextSuite.scala:<N>` string that refers back to the test's own source line. Removing `import org.apache.spark.sql.QueryTest` in the first commit shifted every subsequent line down by 1, so the expected literal `:33` needs to become `:32`.

### Why are the changes needed?

Fix the only in-tree test that failed after the mixin cleanup.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

`build/sbt "sql/testOnly org.apache.spark.sql.errors.QueryContextSuite"` passes.

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

Generated-by: Claude Code (model: claude-opus-4-7)

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