You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/18 14:32:15 UTC

[GitHub] [spark] dbaliafroozeh commented on a change in pull request #27267: [SPARK-30556][SQL] Copy sparkContext.localproperties to child thread inSubqueryExec.executionContext

dbaliafroozeh commented on a change in pull request #27267: [SPARK-30556][SQL] Copy sparkContext.localproperties to child thread inSubqueryExec.executionContext
URL: https://github.com/apache/spark/pull/27267#discussion_r380707786
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/SQLExecution.scala
 ##########
 @@ -164,4 +166,20 @@ object SQLExecution {
       }
     }
   }
+
+  /**
+   * Wrap passed function to ensure necessary thread-local variables like
+   * SparkContext local properties are forwarded to execution thread
+   */
+  def withThreadLocalCaptured[T](
+      sparkSession: SparkSession, exec: ExecutionContext)(body: => T): Future[T] = {
+    val activeSession = sparkSession
+    val sc = sparkSession.sparkContext
+    val localProps = Utils.cloneProperties(sc.getLocalProperties)
+    Future {
+      SparkSession.setActiveSession(activeSession)
+      sc.setLocalProperties(localProps)
 
 Review comment:
   @hvanhovell two questions:
   - Shouldn't we clone`localProps` here? in the sense that what if a concurrent thread modify them?
   - Does the order of setting `localProps` and `activeSession` matter?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org