Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/993#discussion_r15333936
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkPlan.scala ---
    @@ -18,22 +18,53 @@
     package org.apache.spark.sql.execution
     
     import org.apache.spark.annotation.DeveloperApi
    +import org.apache.spark.Logging
     import org.apache.spark.rdd.RDD
    -import org.apache.spark.sql.{Logging, Row}
    +import org.apache.spark.sql.{SQLContext, Row}
     import org.apache.spark.sql.catalyst.trees
     import org.apache.spark.sql.catalyst.analysis.MultiInstanceRelation
    -import org.apache.spark.sql.catalyst.expressions.GenericRow
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.catalyst.expressions.codegen._
     import org.apache.spark.sql.catalyst.plans.QueryPlan
     import org.apache.spark.sql.catalyst.plans.logical.BaseRelation
     import org.apache.spark.sql.catalyst.plans.physical._
     
    +
    +object SparkPlan {
    +  protected[sql] val currentContext = new ThreadLocal[SQLContext]()
    +}
    +
     /**
      * :: DeveloperApi ::
      */
     @DeveloperApi
    -abstract class SparkPlan extends QueryPlan[SparkPlan] with Logging {
    +abstract class SparkPlan extends QueryPlan[SparkPlan] with Logging with 
Serializable {
       self: Product =>
     
    +  /**
    +   * A handle to the SQL Context that was used to create this plan.   
Since many operators need
    +   * access to the sqlContext for RDD operations or configuration this 
field is automatically
    +   * populated by the query planning infrastructure.
    +   */
    +  @transient
    +  protected val sqlContext = SparkPlan.currentContext.get()
    +
    +  protected def sparkContext = sqlContext.sparkContext
    +
    +  def logger = log
    +
    +  val codegenEnabled: Boolean = if(sqlContext != null) {
    --- End diff --
    
    when is context null?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to