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

    https://github.com/apache/spark/pull/7928#discussion_r36823318
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala
 ---
    @@ -746,13 +746,11 @@ case class Last(child: Expression) extends 
PartialAggregate with trees.UnaryNode
     case class LastFunction(expr: Expression, base: AggregateExpression) 
extends AggregateFunction {
       def this() = this(null, null) // Required for serialization.
     
    -  var result: Any = null
    +  var result: MutableLiteral = MutableLiteral(null, expr.dataType)
     
       override def update(input: InternalRow): Unit = {
    -    result = input
    +    result.value = expr.eval(input)
    --- End diff --
    
    @ggupta81 I see the problem. I think we only need to change this line to 
fix it. Basically, the input row can be a mutable row. So, we need to eagerly 
evaluate the expression instead of just pointing result to the input.  


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to