Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ case class TypedAggregateExpression(

override def eval(buffer: InternalRow): Any = {
val b = boundB.shift(mutableAggBufferOffset).fromRow(buffer)
val result = cEncoder.toRow(aggregator.present(b))
val result = cEncoder.toRow(aggregator.finish(b))
dataType match {
case _: StructType => result
case _ => result.get(0, dataType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ abstract class Aggregator[-A, B, C] {
/**
* Transform the output of the reduction.
*/
def present(reduction: B): C
def finish(reduction: B): C

/**
* Returns this `Aggregator` as a [[TypedColumn]] that can be used in [[Dataset]] or [[DataFrame]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SumOf[I, N : Numeric](f: I => N) extends Aggregator[I, N, N] with Serializ

override def merge(b1: N, b2: N): N = numeric.plus(b1, b2)

override def present(reduction: N): N = reduction
override def finish(reduction: N): N = reduction
}

object TypedAverage extends Aggregator[(String, Int), (Long, Long), Double] with Serializable {
Expand All @@ -50,7 +50,7 @@ object TypedAverage extends Aggregator[(String, Int), (Long, Long), Double] with
(b1._1 + b2._1, b1._2 + b2._2)
}

override def present(countAndSum: (Long, Long)): Double = countAndSum._2 / countAndSum._1
override def finish(countAndSum: (Long, Long)): Double = countAndSum._2 / countAndSum._1
}

object ComplexResultAgg extends Aggregator[(String, Int), (Long, Long), (Long, Long)]
Expand All @@ -66,7 +66,7 @@ object ComplexResultAgg extends Aggregator[(String, Int), (Long, Long), (Long, L
(b1._1 + b2._1, b1._2 + b2._2)
}

override def present(reduction: (Long, Long)): (Long, Long) = reduction
override def finish(reduction: (Long, Long)): (Long, Long) = reduction
}

class DatasetAggregatorSuite extends QueryTest with SharedSQLContext {
Expand Down