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

   ### What changes were proposed in this pull request?
   
   This PR proposes to (mostly) refactor all the internal workarounds to get 
the active session correctly.
   
   There are few things to note:
   
   - _PySpark with Spark Connect does not already support the hierarchy of 
active sessions_. With pinned thread mode (enabled by default), PySpark does 
map each Python thread to JVM thread, but the thread creation happens within 
gateway server, that does not respect the thread hierarchy. Therefore, this PR 
follows the exactly same behaviour.
     - New thread will not have an active thread by default.
     - Other behaviours are same as PySpark without Connect, see also 
https://github.com/apache/spark/pull/42367
   - Since I am here, I piggiyback few documentation changes. We missed 
document `SparkSession.readStream`, `SparkSession.streams`, 
`SparkSession.udtf`, `SparkSession.conf` and `SparkSession.version` in Spark 
Connect.
   - The changes here are mostly refactoring that reuses existing unittests 
while I expose two methods:
     - `SparkSession.getActiveSession` (only for Spark Connect)
     - `SparkSession.active` (for both in PySpark)
   
   ### Why are the changes needed?
   
   For Spark Connect users to be able to play with active and default sessions 
in Python.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, it adds new API:
     - `SparkSession.getActiveSession` (only for Spark Connect)
     - `SparkSession.active` (for both in PySpark)
   
   ### How was this patch tested?
   
   Existing unittests should cover all.
   


-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to