Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/683#discussion_r12404003
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala
---
@@ -86,6 +86,67 @@ abstract class AggregateFunction
override def newInstance() = makeCopy(productIterator.map { case a:
AnyRef => a }.toArray)
}
+case class Min(child: Expression) extends PartialAggregate with
trees.UnaryNode[Expression] {
+ override def references = child.references
+ override def nullable = child.nullable
+ override def dataType = child.dataType
+ override def toString = s"MIN($child)"
+
+ override def asPartial: SplitEvaluation = {
+ val partialMin = Alias(Min(child), "PartialMin")()
+ SplitEvaluation(Min(partialMin.toAttribute), partialMin :: Nil)
+ }
+
+ override def newInstance() = new MinFunction(child, this)
+}
+
+case class MinFunction(expr: Expression, base: AggregateExpression)
extends AggregateFunction {
--- End diff --
this is unrelated to this pr - but I just realized the way we are storing
the aggregation buffer in Spark SQL uses much more memory than needed, because
there are two extra pointers to expr/base, which is identical for every tuple.
---
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.
---