spark-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shixiong Zhu (JIRA)" <>
Subject [jira] [Created] (SPARK-4812) SparkPlan.codegenEnabled may be initialized to a wrong value
Date Wed, 10 Dec 2014 07:26:13 GMT
Shixiong Zhu created SPARK-4812:

             Summary: SparkPlan.codegenEnabled may be initialized to a wrong value
                 Key: SPARK-4812
             Project: Spark
          Issue Type: Bug
          Components: SQL
            Reporter: Shixiong Zhu

The problem is `codegenEnabled` is `val`, but it uses a `val` `sqlContext`, which can be override
by subclasses. Here is a simple example to show this issue.

scala> :paste
// Entering paste mode (ctrl-D to finish)

abstract class Foo {

  protected val sqlContext = "Foo"

  val codegenEnabled: Boolean = {
    println(sqlContext) // it will call subclass's `sqlContext` which has not yet been initialized.
    if (sqlContext != null) {
    } else {

class Bar extends Foo {
  override val sqlContext = "Bar"

println(new Bar().codegenEnabled)

// Exiting paste mode, now interpreting.

defined class Foo
defined class Bar


To fix it, we should mark `codegenEnabled` as `lazy`.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message