Github user hvanhovell commented on a diff in the pull request: https://github.com/apache/spark/pull/8113#discussion_r36818586 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/functions.scala --- @@ -130,23 +138,36 @@ case class First(child: Expression) extends AlgebraicAggregate { private val first = AttributeReference("first", child.dataType)() - override val bufferAttributes = first :: Nil + private val valueSet = AttributeReference("valueSet", BooleanType)() + + override val bufferAttributes = first :: valueSet :: Nil override val initialValues = Seq( - /* first = */ Literal.create(null, child.dataType) + /* first = */ Literal.create(null, child.dataType), + /* valueSet = */ Literal.create(false, BooleanType) ) override val updateExpressions = Seq( - /* first = */ If(IsNull(first), child, first) + /* first = */ If(valueSet, first, child), + /* valueSet = */ If(valueSet, valueSet, Literal.create(true, BooleanType)) ) override val mergeExpressions = Seq( - /* first = */ If(IsNull(first.left), first.right, first.left) + /* first = */ If(valueSet, first.left, first.right), + /* valueSet = */ If(valueSet, valueSet, Literal.create(true, BooleanType)) --- End diff -- We could for now simplify this to ```Literal.create(true, BooleanType)```.
--- 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