Skip to content

[SPARK-55910][SQL][TESTS][FOLLOW-UP] Inline unnecessary asInstanceOf[classic.SparkSession] cast in QueryTest#55715

Closed
zhengruifeng wants to merge 1 commit intoapache:masterfrom
zhengruifeng:inline-classic-cast-query-test
Closed

[SPARK-55910][SQL][TESTS][FOLLOW-UP] Inline unnecessary asInstanceOf[classic.SparkSession] cast in QueryTest#55715
zhengruifeng wants to merge 1 commit intoapache:masterfrom
zhengruifeng:inline-classic-cast-query-test

Conversation

@zhengruifeng
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

In QueryTest.withQueryExecutionsCaptured, the local alias classicSession = spark.asInstanceOf[classic.SparkSession] is replaced with direct uses of spark. The cast is not needed: sparkContext (api/SparkSession.scala:72) and listenerManager (api/SparkSession.scala:144) are both declared on the abstract org.apache.spark.sql.SparkSession, so they are accessible without converting to the classic implementation.

Why are the changes needed?

Cleanup follow-up to #55339, which removed unnecessary asInstanceOf[classic.Dataset] casts in QueryTest. The same criterion applies here: when the called API is already on the abstract type, the explicit classic cast adds noise and obscures which code paths actually depend on classic-only functionality.

Does this PR introduce any user-facing change?

No. Test-only.

How was this patch tested?

build/sbt sql/Test/compile succeeds.

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

Generated-by: Claude Code (Opus 4.7)

@zhengruifeng zhengruifeng changed the title [MINOR][SQL][TESTS] Inline unnecessary asInstanceOf[classic.SparkSession] cast in QueryTest [SPARK-55910][SQL][TESTS][FOLLOW-UP] Inline unnecessary asInstanceOf[classic.SparkSession] cast in QueryTest May 7, 2026
@zhengruifeng zhengruifeng marked this pull request as ready for review May 7, 2026 00:57
zhengruifeng added a commit that referenced this pull request May 7, 2026
…classic.SparkSession] cast in QueryTest

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

In `QueryTest.withQueryExecutionsCaptured`, the local alias `classicSession = spark.asInstanceOf[classic.SparkSession]` is replaced with direct uses of `spark`. The cast is not needed: `sparkContext` (`api/SparkSession.scala:72`) and `listenerManager` (`api/SparkSession.scala:144`) are both declared on the abstract `org.apache.spark.sql.SparkSession`, so they are accessible without converting to the classic implementation.

### Why are the changes needed?

Cleanup follow-up to #55339, which removed unnecessary `asInstanceOf[classic.Dataset]` casts in `QueryTest`. The same criterion applies here: when the called API is already on the abstract type, the explicit classic cast adds noise and obscures which code paths actually depend on classic-only functionality.

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

No. Test-only.

### How was this patch tested?

`build/sbt sql/Test/compile` succeeds.

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

Generated-by: Claude Code (Opus 4.7)

Closes #55715 from zhengruifeng/inline-classic-cast-query-test.

Authored-by: Ruifeng Zheng <ruifengz@apache.org>
Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
(cherry picked from commit 1241434)
Signed-off-by: Ruifeng Zheng <ruifengz@foxmail.com>
@zhengruifeng
Copy link
Copy Markdown
Contributor Author

merged to master/4.x

@zhengruifeng zhengruifeng deleted the inline-classic-cast-query-test branch May 7, 2026 03:51
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.

2 participants