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
[SPARK-25525][SQL][PYSPARK] Do not update conf for existing SparkContext in SparkSession.getOrCreate. #22545
Closed
ueshin
wants to merge
4
commits into
apache:master
from
ueshin:issues/SPARK-25525/not_update_existing_conf
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,7 +156,7 @@ def getOrCreate(self): | |
default. | ||
|
||
>>> s1 = SparkSession.builder.config("k1", "v1").getOrCreate() | ||
>>> s1.conf.get("k1") == s1.sparkContext.getConf().get("k1") == "v1" | ||
>>> s1.conf.get("k1") == "v1" | ||
True | ||
|
||
In case an existing SparkSession is returned, the config options specified | ||
|
@@ -179,19 +179,13 @@ def getOrCreate(self): | |
sparkConf = SparkConf() | ||
for key, value in self._options.items(): | ||
sparkConf.set(key, value) | ||
sc = SparkContext.getOrCreate(sparkConf) | ||
# This SparkContext may be an existing one. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tiny nit: can we move this comment above |
||
for key, value in self._options.items(): | ||
# we need to propagate the confs | ||
# before we create the SparkSession. Otherwise, confs like | ||
# warehouse path and metastore url will not be set correctly ( | ||
# these confs cannot be changed once the SparkSession is created). | ||
sc._conf.set(key, value) | ||
sc = SparkContext.getOrCreate(sparkConf) | ||
# Do not update `SparkConf` for existing `SparkContext`, as it's shared | ||
# by all sessions. | ||
session = SparkSession(sc) | ||
for key, value in self._options.items(): | ||
session._jsparkSession.sessionState().conf().setConfString(key, value) | ||
for key, value in self._options.items(): | ||
session.sparkContext._conf.set(key, value) | ||
return session | ||
|
||
builder = Builder() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@ueshin Could we also update the migration guide about this change?
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.
In that case, we might have to put the behaviour changes by #18536 together to the migration guide as well.
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.
We can do it together.
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.
Submitted a pr to update the migration guide #22682.