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

    https://github.com/apache/spark/pull/10734#discussion_r49557974
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
 ---
    @@ -183,32 +175,38 @@ case class CaseWhen(branches: Seq[Expression]) 
extends Expression {
           boolean ${ev.isNull} = true;
           ${ctx.javaType(dataType)} ${ev.value} = 
${ctx.defaultValue(dataType)};
           $cases
    -      $other
    +      $elseCase
         """
       }
     
       override def toString: String = {
    -    "CASE" + branches.sliding(2, 2).map {
    -      case Seq(cond, value) => s" WHEN $cond THEN $value"
    -      case Seq(elseValue) => s" ELSE $elseValue"
    -    }.mkString
    +    val cases = branches.map { case (c, v) => s" WHEN $c THEN $v" 
}.mkString
    +    val elseCase = elseValue.map(" ELSE " + _).getOrElse("")
    +    "CASE" + cases + elseCase + " END"
       }
     
    -  override def sql: String = {
    -    val branchesSQL = branches.map(_.sql)
    -    val (cases, maybeElse) = if (branches.length % 2 == 0) {
    -      (branchesSQL, None)
    -    } else {
    -      (branchesSQL.init, Some(branchesSQL.last))
    -    }
    +  override def sql: String = prettyString
    --- End diff --
    
    yes - actually we should just remove the existing "sql" and rename 
"prettyString" "sql".



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to