AngersZhuuuu commented on a change in pull request #26187: [SPARK-29530][SQL]
Reset active SparkSession before parse sql in SparkSession
URL: https://github.com/apache/spark/pull/26187#discussion_r336880662
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/SparkSession.scala
##########
@@ -600,6 +600,7 @@ class SparkSession private(
* @since 2.0.0
*/
def sql(sqlText: String): DataFrame = {
+ SparkSession.setActiveSession(this)
Review comment:
> Who takes responsibility to set this back if we set the active session in
this method? For example, the current active session is `spark1` when calling
`spark2.sql(...)`, then the active session will become `spark2`. When we will
set it back to `spark1`, or it will always be `spark2`?
Under normal circumstances, our spark program use one SparkSession, if some
one write program use multi sparksession, they should control these things.
And for analyzer, it will set this.
https://github.com/apache/spark/blob/e99a9f78ea2e18eabca722c5714280eb7a737499/sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala#L64
And only
`SparkSession.cleanupAnyExistingSession()` will call
```
SparkSession.clearActiveSession()
SparkSession.clearDefaultSession()
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]