Skip to content

Commit 5adb513

Browse files
committed
making conditionMet a local variable
1 parent f4c7896 commit 5adb513

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/conditionalExpressions.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,25 @@ case class CaseWhen(
219219
val code = if (ctx.INPUT_ROW == null || ctx.currentVars != null) {
220220
allConditions.mkString("\n")
221221
} else {
222+
// This generates code like:
223+
// do {
224+
// conditionMet = caseWhen_1(i);
225+
// if(conditionMet) {
226+
// continue;
227+
// }
228+
// conditionMet = caseWhen_2(i);
229+
// if(conditionMet) {
230+
// continue;
231+
// }
232+
// ...
233+
// } while (false);
222234
ctx.splitExpressions(allConditions, "caseWhen",
223-
("InternalRow", ctx.INPUT_ROW) :: (ctx.JAVA_BOOLEAN, conditionMet) :: Nil,
235+
("InternalRow", ctx.INPUT_ROW) :: Nil,
224236
returnType = ctx.JAVA_BOOLEAN,
225237
makeSplitFunction = {
226238
func =>
227239
s"""
240+
${ctx.JAVA_BOOLEAN} $conditionMet = false;
228241
$func
229242
return $conditionMet;
230243
"""
@@ -243,7 +256,7 @@ case class CaseWhen(
243256
ev.copy(code = s"""
244257
${ev.isNull} = true;
245258
${ev.value} = ${ctx.defaultValue(dataType)};
246-
boolean $conditionMet = false;
259+
${ctx.JAVA_BOOLEAN} $conditionMet = false;
247260
$code""")
248261
}
249262
}

0 commit comments

Comments
 (0)