[SPARK-56483][SQL][TESTS] Use abstract SparkSession/DataFrame in SQLTestUtilsBase#55346
Closed
zhengruifeng wants to merge 12 commits into
Closed
[SPARK-56483][SQL][TESTS] Use abstract SparkSession/DataFrame in SQLTestUtilsBase#55346zhengruifeng wants to merge 12 commits into
zhengruifeng wants to merge 12 commits into
Conversation
…sBase Co-authored-by: Isaac
…switch Co-authored-by: Isaac
Co-authored-by: Isaac
… in SchemaPruningSuite Co-authored-by: Isaac
Co-authored-by: Isaac
…; fix Connect Dataset visibility Co-authored-by: Isaac
…park] Co-authored-by: Isaac
…ngth Co-authored-by: Isaac
Co-authored-by: Isaac
…ializeTablesSuite Co-authored-by: Isaac
Co-authored-by: Isaac
Co-authored-by: Isaac
d5e389b to
a497d90
Compare
cloud-fan
approved these changes
Apr 15, 2026
Contributor
cloud-fan
left a comment
There was a problem hiding this comment.
Clean decoupling of SQLTestUtilsBase from classic.SparkSession. The type-narrowing override removal is well-scoped, the asInstanceOf casts are localized to the few sites that genuinely need classic APIs, and the withColumnsRenamed visibility fix correctly unifies the override hierarchy across abstract/classic/connect.
No design, correctness, or coverage concerns.
Contributor
Author
|
merged to master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Decouple
SQLTestUtilsBasefrom classicSparkSessionandDataFrametypes, switching to the abstract SQL API types instead. This is a preparatory step toward mergingSQLTestUtilsBase/SQLTestUtilswithQueryTestBase/QueryTest.Core change in
SQLTestUtils.scala:override protected def spark: classic.SparkSessionfromSQLTestUtilsBase, letting it inherit the abstractSparkSessionfromSparkSessionProviderDataFrameandSparkSessionimports fromo.a.s.sql.classictoo.a.s.sql(abstract API)classic.SparkSessionlocally in methods that require classic-only APIs (testImplicits,stripSparkFilter,logicalPlanToSparkQuery,uncacheTable)logicalPlanToSparkQueryreturnsclassic.DataFrame(not abstract) since it satisfies both classic and abstract targets via subtyping, avoiding the need for implicit chainingAPI visibility fix:
Dataset.withColumnsRenamed(Seq, Seq)fromprotectedtoprotected[spark]in the abstract API, withoverridein classic and connect — unifying the visibility across all threeDownstream test fixes (using
import testImplicits._to provideClassicConversions):ReplaceIntegerLiteralsWithOrdinalsDataframeSuite— addedimport testImplicits._CollationExpressionWalkerSuite— addedimport testImplicits._AlterTableRenameSuiteBase— addedimport testImplicits._DropTableSuiteBase— addedimport testImplicits._OuterJoinSuite— widenedimport testImplicits.toRichColumntoimport testImplicits._SchemaPruningSuite— addedimport testImplicits.castToImpl(class-leveltestImplicits._conflicts with catalyst DSL$"col")HiveQuerySuite— replacedimport TestHive.sparkSession.implicits._withimport testImplicits._HiveUDFSuite— addedimport testImplicits.castToImplMaterializeTablesSuite— added class-levelimport testImplicits._, removed per-testimport session.implicits._and unusedval session = sparkPipelineTest,BaseCoreExecutionTest— addedimport testImplicits._Other fixes:
DDLSuite—spark.artifactManager→spark.sessionState.artifactManagerCachedTableSuite—getNumInMemoryRelationsaccepts abstractDataset[_]ParquetFilterSuite— removed pre-existing unusedClassicConversions._importWhy are the changes needed?
SQLTestUtilsBasecurrently requires aclassic.SparkSession, which tightly couples it to the classic implementation. This makes it difficult to mergeSQLTestUtilsBasewithQueryTestBase(which uses the abstractSparkSessionviaSparkSessionProvider). Decoupling the base types is a necessary first step toward consolidating the test utility class hierarchy.Does this PR introduce any user-facing change?
No.
How was this patch tested?
sql/Test/compile,hive/Test/compile,connect-common/compile,pipelines/Test/compile,avro/Test/compile, andkafka-0-10-sql/Test/compile.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-4-6)