-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-31532][SQL] Builder should not propagate static sql configs to the existing active or default SparkSession #28316
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ import org.scalatest.BeforeAndAfterEach | |
| import org.apache.spark.{SparkConf, SparkContext, SparkFunSuite} | ||
| import org.apache.spark.internal.config.UI.UI_ENABLED | ||
| import org.apache.spark.sql.internal.SQLConf | ||
| import org.apache.spark.sql.internal.StaticSQLConf.GLOBAL_TEMP_DATABASE | ||
| import org.apache.spark.sql.internal.StaticSQLConf._ | ||
|
|
||
| /** | ||
| * Test cases for the builder pattern of [[SparkSession]]. | ||
|
|
@@ -168,4 +168,51 @@ class SparkSessionBuilderSuite extends SparkFunSuite with BeforeAndAfterEach { | |
| assert(session.sessionState.conf.getConfString("spark.app.name") === "test-app-SPARK-31234") | ||
| assert(session.sessionState.conf.getConf(GLOBAL_TEMP_DATABASE) === "globaltempdb-spark-31234") | ||
| } | ||
|
|
||
| test("SPARK-31532: should not propagate static sql configs to the existing" + | ||
| " active/default SparkSession") { | ||
| val session = SparkSession.builder() | ||
| .master("local") | ||
| .config(GLOBAL_TEMP_DATABASE.key, value = "globalTempDB-SPARK-31532") | ||
| .config("spark.app.name", "test-app-SPARK-31532") | ||
| .getOrCreate() | ||
| // do not propagate static sql configs to the existing active session | ||
| val session1 = SparkSession | ||
| .builder() | ||
| .config(GLOBAL_TEMP_DATABASE.key, "globalTempDB-SPARK-31532-1") | ||
| .getOrCreate() | ||
| assert(session.conf.get(GLOBAL_TEMP_DATABASE) === "globaltempdb-spark-31532") | ||
| assert(session1.conf.get(GLOBAL_TEMP_DATABASE) === "globaltempdb-spark-31532") | ||
|
|
||
| // do not propagate static sql configs to the existing default session | ||
| SparkSession.clearActiveSession() | ||
| val session2 = SparkSession | ||
| .builder() | ||
| .config(WAREHOUSE_PATH.key, "SPARK-31532-db") | ||
| .config(GLOBAL_TEMP_DATABASE.key, value = "globalTempDB-SPARK-31532-2") | ||
| .getOrCreate() | ||
|
|
||
| assert(!session.conf.get(WAREHOUSE_PATH).contains("SPARK-31532-db")) | ||
| assert(session.conf.get(WAREHOUSE_PATH) === session2.conf.get(WAREHOUSE_PATH)) | ||
| assert(session2.conf.get(GLOBAL_TEMP_DATABASE) === "globaltempdb-spark-31532") | ||
| } | ||
|
|
||
| test("SPARK-31532: propagate static sql configs if no existing SparkSession") { | ||
| val conf = new SparkConf() | ||
| .setMaster("local") | ||
| .setAppName("test-app-SPARK-31532-2") | ||
| .set(GLOBAL_TEMP_DATABASE.key, "globaltempdb-spark-31532") | ||
| .set(WAREHOUSE_PATH.key, "SPARK-31532-db") | ||
| SparkContext.getOrCreate(conf) | ||
|
|
||
|
Member
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. nit: remove this blank |
||
| // propagate static sql configs if no existing session | ||
| val session = SparkSession | ||
| .builder() | ||
| .config(GLOBAL_TEMP_DATABASE.key, "globalTempDB-SPARK-31532-2") | ||
| .config(WAREHOUSE_PATH.key, "SPARK-31532-db-2") | ||
| .getOrCreate() | ||
| assert(session.conf.get("spark.app.name") === "test-app-SPARK-31532-2") | ||
| assert(session.conf.get(GLOBAL_TEMP_DATABASE) === "globaltempdb-spark-31532-2") | ||
| assert(session.conf.get(WAREHOUSE_PATH) === "SPARK-31532-db-2") | ||
| } | ||
| } | ||
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.
Just in case, could we add tests for the case where we should set static configs at SparkSession (In case that no active/default SparkSession exists)? Or, we already have such a test?
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.
I add a new test for such a case, that is, if SparkContext instance exists but no SparkSession exists, then the static configs remain changeable before SparkSession is finally created.