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

    https://github.com/apache/spark/pull/2113#discussion_r35326423
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala
 ---
    @@ -105,17 +105,18 @@ case class Min(child: Expression) extends 
PartialAggregate with trees.UnaryNode[
     case class MinFunction(expr: Expression, base: AggregateExpression) 
extends AggregateFunction {
       def this() = this(null, null) // Required for serialization.
     
    -  var currentMin: Any = _
    +  val currentMin: MutableLiteral = MutableLiteral(null, expr.dataType)
    +  val cmp = GreaterThan(currentMin, expr)
     
       override def update(input: Row): Unit = {
    -    if (currentMin == null) {
    -      currentMin = expr.eval(input)
    -    } else if(GreaterThan(Literal(currentMin, expr.dataType), 
expr).eval(input) == true) {
    -      currentMin = expr.eval(input)
    +    if (currentMin.value == null) {
    +      currentMin.value = expr.eval(input)
    +    } else if(cmp.eval(input) == true) {
    +      currentMin.value = expr.eval(input)
    --- End diff --
    
    @chenghao-intel , will this cause twice evaluation of expr on the same 
input line? why not eval once and store in a tmp val? Did I miss something?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to