Skip to content
Closed
Show file tree
Hide file tree
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 @@ -142,9 +142,19 @@ object SQLExecution {
val sc = sparkSession.sparkContext
val localProps = Utils.cloneProperties(sc.getLocalProperties)
Future {
val originalSession = SparkSession.getActiveSession
val originalLocalProps = sc.getLocalProperties
SparkSession.setActiveSession(activeSession)
sc.setLocalProperties(localProps)
body
val res = body
// reset active session and local props.
sc.setLocalProperties(originalLocalProps)
if (originalSession.nonEmpty) {
SparkSession.setActiveSession(originalSession.get)
} else {
SparkSession.clearActiveSession()
}
res
}(exec)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

package org.apache.spark.sql.internal

import java.util.UUID

import org.scalatest.Assertions._

import org.apache.spark.{SparkException, SparkFunSuite, TaskContext}
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{Dataset, SparkSession}
Expand Down Expand Up @@ -148,14 +152,14 @@ class ExecutorSideSQLConfSuite extends SparkFunSuite with SQLTestUtils {
}

// set local configuration and assert
val confValue1 = "e"
val confValue1 = UUID.randomUUID().toString()
createDataframe(confKey, confValue1).createOrReplaceTempView("m")
spark.sparkContext.setLocalProperty(confKey, confValue1)
val result1 = sql("SELECT value, (SELECT MAX(*) FROM m) x FROM l").collect
assert(result1.forall(_.getBoolean(1)))

// change the conf value and assert again
val confValue2 = "f"
val confValue2 = UUID.randomUUID().toString()
createDataframe(confKey, confValue2).createOrReplaceTempView("n")
spark.sparkContext.setLocalProperty(confKey, confValue2)
val result2 = sql("SELECT value, (SELECT MAX(*) FROM n) x FROM l").collect
Expand Down