You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by we...@apache.org on 2017/11/28 14:43:30 UTC

spark git commit: [SPARK-22520][SQL][FOLLOWUP] remove outer if for case when codegen

Repository: spark
Updated Branches:
  refs/heads/master 64817c423 -> 1e07fff24


[SPARK-22520][SQL][FOLLOWUP] remove outer if for case when codegen

## What changes were proposed in this pull request?

a minor cleanup for https://github.com/apache/spark/pull/19752 . Remove the outer if as the code is inside `do while`

## How was this patch tested?

existing tests

Author: Wenchen Fan <we...@databricks.com>

Closes #19830 from cloud-fan/minor.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/1e07fff2
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/1e07fff2
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/1e07fff2

Branch: refs/heads/master
Commit: 1e07fff248088ef4854e430928149ad3809f799f
Parents: 64817c4
Author: Wenchen Fan <we...@databricks.com>
Authored: Tue Nov 28 22:43:24 2017 +0800
Committer: Wenchen Fan <we...@databricks.com>
Committed: Tue Nov 28 22:43:24 2017 +0800

----------------------------------------------------------------------
 .../expressions/conditionalExpressions.scala    | 30 +++++++++-----------
 1 file changed, 13 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/1e07fff2/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
index a8629c1..43e6431 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala
@@ -197,28 +197,24 @@ case class CaseWhen(
       val cond = condExpr.genCode(ctx)
       val res = valueExpr.genCode(ctx)
       s"""
-        if(!$conditionMet) {
-          ${cond.code}
-          if (!${cond.isNull} && ${cond.value}) {
-            ${res.code}
-            ${ev.isNull} = ${res.isNull};
-            ${ev.value} = ${res.value};
-            $conditionMet = true;
-            continue;
-          }
-        }
-      """
+         |${cond.code}
+         |if (!${cond.isNull} && ${cond.value}) {
+         |  ${res.code}
+         |  ${ev.isNull} = ${res.isNull};
+         |  ${ev.value} = ${res.value};
+         |  $conditionMet = true;
+         |  continue;
+         |}
+       """.stripMargin
     }
 
     val elseCode = elseValue.map { elseExpr =>
       val res = elseExpr.genCode(ctx)
       s"""
-        if(!$conditionMet) {
-          ${res.code}
-          ${ev.isNull} = ${res.isNull};
-          ${ev.value} = ${res.value};
-        }
-      """
+         |${res.code}
+         |${ev.isNull} = ${res.isNull};
+         |${ev.value} = ${res.value};
+       """.stripMargin
     }
 
     val allConditions = cases ++ elseCode


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org