Skip to content

Commit af2236b

Browse files
revert the short-circuit expression evaluation for IF
1 parent b7861d2 commit af2236b

File tree

1 file changed

+2
-5
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+2
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ case class If(predicate: Expression, trueValue: Expression, falseValue: Expressi
174174
extends Expression {
175175

176176
def children = predicate :: trueValue :: falseValue :: Nil
177-
override def nullable = predicate.nullable || (trueValue.nullable && falseValue.nullable)
177+
override def nullable = trueValue.nullable || falseValue.nullable
178178
def references = children.flatMap(_.references).toSet
179179
override lazy val resolved = childrenResolved && trueValue.dataType == falseValue.dataType
180180
def dataType = {
@@ -189,10 +189,7 @@ case class If(predicate: Expression, trueValue: Expression, falseValue: Expressi
189189
type EvaluatedType = Any
190190

191191
override def eval(input: Row): Any = {
192-
val condition = predicate.eval(input)
193-
if (null == condition) {
194-
null
195-
} else if(condition == true) {
192+
if (true == predicate.eval(input)) {
196193
trueValue.eval(input)
197194
} else {
198195
falseValue.eval(input)

0 commit comments

Comments
 (0)