Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,7 @@ class SparkSession private(
* @since 2.0.0
*/
def sql(sqlText: String): DataFrame = {
SparkSession.setActiveSession(this)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

And only
SparkSession.cleanupAnyExistingSession() will call

  SparkSession.clearActiveSession()
      SparkSession.clearDefaultSession()

val tracker = new QueryPlanningTracker
val plan = tracker.measurePhase(QueryPlanningTracker.PARSING) {
sessionState.sqlParser.parsePlan(sqlText)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that we use SQLConf.get a lot in analyzer/optimizer rules, but does it also true for the parser?

Copy link
Contributor Author

@AngersZhuuuu AngersZhuuuu Oct 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that we use SQLConf.get a lot in analyzer/optimizer rules, but does it also true for the parser?

Parser use SQLConf.get too.
It truly make some configuration about parser mess in SparkThriftServer multi thread mode.

lexer.legacy_setops_precedence_enbled = SQLConf.get.setOpsPrecedenceEnforced

It is all about error happened in #26172

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we define a conf: SQLConf method in ParserDriver so that we can avoid calling SQLConf.get in the parser?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we define a conf: SQLConf method in ParserDriver so that we can avoid calling SQLConf.get in the parser?

How about new change? Test is ok for #26172 . also cc @juliuszsompolski

Expand Down