Skip to content
Closed
Changes from all commits
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 @@ -98,12 +98,31 @@ class SparkSessionBuilderSuite extends SparkFunSuite {
val session = SparkSession.builder().config("key2", "value2").getOrCreate()
assert(session.conf.get("key1") == "value1")
assert(session.conf.get("key2") == "value2")
assert(session.sparkContext == sparkContext2)
assert(session.sparkContext.conf.get("key1") == "value1")
// If the created sparkContext is not passed through the Builder's API sparkContext,
// the conf of this sparkContext will also contain the conf set through the API config.
assert(session.sparkContext.conf.get("key2") == "value2")
assert(session.sparkContext.conf.get("spark.app.name") == "test")
session.stop()
}

test("create SparkContext first then pass context to SparkSession") {
sparkContext.stop()
val conf = new SparkConf().setAppName("test").setMaster("local").set("key1", "value1")
val newSC = new SparkContext(conf)
val session = SparkSession.builder().sparkContext(newSC).config("key2", "value2").getOrCreate()
assert(session.conf.get("key1") == "value1")
assert(session.conf.get("key2") == "value2")
assert(session.sparkContext == newSC)
assert(session.sparkContext.conf.get("key1") == "value1")
// If the created sparkContext is passed through the Builder's API sparkContext,
// the conf of this sparkContext will not contain the conf set through the API config.
assert(!session.sparkContext.conf.contains("key2"))
assert(session.sparkContext.conf.get("spark.app.name") == "test")
session.stop()
}

test("SPARK-15887: hive-site.xml should be loaded") {
val session = SparkSession.builder().master("local").getOrCreate()
assert(session.sessionState.newHadoopConf().get("hive.in.test") == "true")
Expand Down