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

    https://github.com/apache/spark/pull/19729#discussion_r150501441
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala
 ---
    @@ -604,6 +604,8 @@ case class Least(children: Seq[Expression]) extends 
Expression {
         val evalChildren = children.map(_.genCode(ctx))
         val first = evalChildren(0)
    --- End diff --
    
    before using `ev.value`, `ev.isNull` is checked 
(https://github.com/kiszk/spark/blob/bc3f0a43956a1e46928f0269d1d8d0aad9ee02b1/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala#L612).
 So in case of all children with `-2`, the first one will see that `ev.isNull` 
is `true` and then it will set it to `false` and assign `-2` to `ev.value`. 
Thus the initial value assigned to `ev.value` is irrelevant, since `ev.isNull` 
is `true` and as far as `ev.isNull` is `true`, what `ev.value` contains doesn't 
matter.


---

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

Reply via email to