Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/19729#discussion_r150437176
--- 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 --
[`defaultValue`
function](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala#L596)
returns `-1` or `null`.
When we compare any non-primitive value with `null`, `NullPointerException`
may occur.
Wehn we compare primitive value with initial value `-1`, the result may
cause an incorrect result. For example, in `Greatest`, if all of the given
values are `-2`, the result will be `-1`. It is incorrect.
What do you think?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]