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

    https://github.com/apache/spark/pull/10737#discussion_r49672588
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
 ---
    @@ -137,45 +137,50 @@ case class CaseWhen(branches: Seq[(Expression, 
Expression)], elseValue: Option[E
       }
     
       override def genCode(ctx: CodeGenContext, ev: GeneratedExpressionCode): 
String = {
    -    val got = ctx.freshName("got")
    +    val len = branches.length
     
    -    val cases = branches.map { case (condition, value) =>
    -      val cond = condition.gen(ctx)
    -      val res = value.gen(ctx)
    -      s"""
    -        if (!$got) {
    +    def genBranch(branchIndex: Int): String =
    --- End diff --
    
    this code is pretty confusing. do you think you can simplify the flow a bit?
    
    maybe it'd help to not do this with recursion, and also have the else case 
outside (if you want to have it inside, it should be at the end rather than in 
the beginning because else is conceptually the last case, not the first)


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