-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-20256][SQL] SessionState should be created more lazily #18501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4412f46
eb4bcdb
6853a56
73df93d
137f252
c9686f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,6 +117,12 @@ class SparkSession private( | |
| existingSharedState.getOrElse(new SharedState(sparkContext)) | ||
| } | ||
|
|
||
| /** | ||
| * Initial options for session. This options are applied once when sessionState is created. | ||
| */ | ||
| @transient | ||
| private[sql] val initialSessionOptions = new scala.collection.mutable.HashMap[String, String] | ||
|
|
||
| /** | ||
| * State isolated across sessions, including SQL configurations, temporary tables, registered | ||
| * functions, and everything else that accepts a [[org.apache.spark.sql.internal.SQLConf]]. | ||
|
|
@@ -132,9 +138,11 @@ class SparkSession private( | |
| parentSessionState | ||
| .map(_.clone(this)) | ||
| .getOrElse { | ||
| SparkSession.instantiateSessionState( | ||
| val state = SparkSession.instantiateSessionState( | ||
| SparkSession.sessionStateClassName(sparkContext.conf), | ||
| self) | ||
| initialSessionOptions.foreach { case (k, v) => state.conf.setConfString(k, v) } | ||
| state | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -940,7 +948,7 @@ object SparkSession { | |
| } | ||
|
|
||
| session = new SparkSession(sparkContext, None, None, extensions) | ||
| options.foreach { case (k, v) => session.sessionState.conf.setConfString(k, v) } | ||
| options.foreach { case (k, v) => session.initialSessionOptions.put(k, v) } | ||
|
||
| defaultSession.set(session) | ||
|
|
||
| // Register a successfully instantiated context to the singleton. This should be at the | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optionsare not set bymergeSparkConf. Removing this line is wrong.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original @cloud-fan 's fix is to set them to
sparkContext.confThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for review, @gatorsmile .
I see. Then, @cloud-fan meant the whole #18172 intead of that line.