Skip to content

Commit

Permalink
Use fresh SparkSession when capturing to avoid late capture of previo…
Browse files Browse the repository at this point in the history
…us query (#537)

Signed-off-by: Jason Lowe <jlowe@nvidia.com>
  • Loading branch information
jlowe authored Aug 11, 2020
1 parent 8b87ed2 commit f7e8536
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.json4s.JsonAST
import org.apache.spark.{SparkContext, SparkEnv, SparkUpgradeException}
import org.apache.spark.broadcast.Broadcast
import org.apache.spark.executor.InputMetrics
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.catalyst.plans.physical.{BroadcastMode, IdentityBroadcastMode}
import org.apache.spark.sql.execution.SparkPlan
import org.apache.spark.sql.execution.joins.HashedRelationBroadcastMode
Expand Down Expand Up @@ -69,4 +70,7 @@ object TrampolineUtil {
cause: Throwable): SparkUpgradeException = {
new SparkUpgradeException(version, message, cause)
}

/** Shuts down and cleans up any existing Spark session */
def cleanupAnyExistingSession(): Unit = SparkSession.cleanupAnyExistingSession()
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.spark.SparkConf
import org.apache.spark.internal.Logging
import org.apache.spark.sql.{DataFrame, Row, SparkSession}
import org.apache.spark.sql.execution.SparkPlan
import org.apache.spark.sql.rapids.execution.TrampolineUtil
import org.apache.spark.sql.types._

object TestResourceFinder {
Expand Down Expand Up @@ -225,6 +226,8 @@ trait SparkQueryCompareTestSuite extends FunSuite with Arm {
: (Array[Row], SparkPlan, Array[Row], SparkPlan) = {
conf.setIfMissing("spark.sql.shuffle.partitions", "2")

// force a new session to avoid accidentally capturing a late callback from a previous query
TrampolineUtil.cleanupAnyExistingSession()
ExecutionPlanCaptureCallback.startCapture()
var cpuPlan: Option[SparkPlan] = null
val fromCpu =
Expand Down

0 comments on commit f7e8536

Please sign in to comment.