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

    https://github.com/apache/spark/pull/1055#discussion_r13683452
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala
 ---
    @@ -202,3 +203,139 @@ case class If(predicate: Expression, trueValue: 
Expression, falseValue: Expressi
     
       override def toString = s"if ($predicate) $trueValue else $falseValue"
     }
    +
    +// scalastyle:off
    +/**
    + * Case statements of the form "CASE WHEN a THEN b [WHEN c THEN d]* [ELSE 
e] END".
    + * Refer to this link for the corresponding semantics:
    + * 
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-ConditionalFunctions
    + *
    + * Note that branches are considered in consecutive pairs (cond, val), and 
the optional last element
    + * is the val for the default catch-all case (if provided). Hence, 
`branches` consist of at least
    + * two elements, and can have an odd or even length.
    + */
    +// scalastyle:on
    +case class CaseWhen(branches: Seq[Expression]) extends Expression {
    +  type EvaluatedType = Any
    +  def children = branches
    +  def references = children.flatMap(_.references).toSet
    +  def dataType = {
    +    if (!resolved) {
    +      throw new UnresolvedException(this, "cannot resolve due to differing 
types in some branches")
    +    }
    +    branches(1).dataType
    +  }
    +
    +  override def nullable = branches.sliding(2, 2).map {
    +      case Seq(cond, value) => value.nullable
    +      case Seq(elseValue) => elseValue.nullable
    +    }.reduce(_ || _)
    +
    +  override lazy val resolved = {
    +    lazy val allCondBooleans = branches.sliding(2, 2).map {
    --- End diff --
    
    Is there a reason to make these inner variables lazy?


---
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