LuciferYang opened a new pull request, #57379:
URL: https://github.com/apache/spark/pull/57379

   ### What changes were proposed in this pull request?
   
   `SparkSession.Builder.classic()` passed `CONNECT_COMPANION` to `mode(...)`, 
identical to `connect()`:
   
   ```scala
   def classic(): this.type = mode(CONNECT_COMPANION)
   def connect(): this.type = mode(CONNECT_COMPANION)
   ```
   
   `companion` drives `builder()` (`companion.builder()`), so on a classpath 
with both implementations `SparkSession.builder().classic().getOrCreate()` 
built a Connect session rather than a Classic one. This changes `classic()` to 
pass `CLASSIC_COMPANION` (which is already defined and used by the config-key 
path `API_MODE_CLASSIC => CLASSIC_COMPANION`).
   
   It also adds regression coverage: 
`SparkSessionBuilderImplementationBindingSuite` gains a shared 
`implementationSpecificBuilder` hook and a test asserting the built session is 
in the expected package, exercised by both the Classic (`.classic()`) and 
Connect (`.connect()`) concrete suites -- the mode selectors previously had no 
coverage.
   
   ### Why are the changes needed?
   
   `builder().classic()` does not honor its contract: it returns a Connect 
session (or fails, if only the classic implementation is available), 
contradicting the method name and scaladoc. Introduced by SPARK-49700; present 
since 4.1.0.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `SparkSession.builder().classic().getOrCreate()` now builds a Classic 
session as documented, instead of a Connect session. This is a bug fix relative 
to released 4.1.x.
   
   ### How was this patch tested?
   
   New shared test `SPARK-58223: mode selector binds to the correct 
implementation` in `SparkSessionBuilderImplementationBindingSuite`, run by both 
the Classic and Connect suites. Verified reproduce-then-fix: the Classic case 
fails on the unfixed tree (the built session is not in 
`org.apache.spark.sql.classic`) and passes after the fix; the classic suite 
passes.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to