AggregateFunction Expressions¶
AggregateFunction is an extension of the Expression abstraction for aggregate functions.
AggregateFunction can never be foldable.
Contract¶
Aggregation Buffer Attributes¶
aggBufferAttributes: Seq[AttributeReference]
Aggregation Buffer Schema¶
aggBufferSchema: StructType
Schema of an aggregation buffer with partial aggregate results
Used when:
AggregationIteratoris requested to initializeAggregateFunctions
inputAggBufferAttributes¶
inputAggBufferAttributes: Seq[AttributeReference]
Implementations¶
- DeclarativeAggregate
- ImperativeAggregate
TypedAggregateExpression
foldable¶
foldable is always disabled (false).
Converting into AggregateExpression¶
toAggregateExpression(): AggregateExpression // (1)
toAggregateExpression(
isDistinct: Boolean,
filter: Option[Expression] = None): AggregateExpression
isDistinctflag isfalse
toAggregateExpression creates an AggregateExpression for this AggregateFunction (with Complete mode).
import org.apache.spark.sql.functions.collect_list
val fn = collect_list("gid")
import org.apache.spark.sql.catalyst.expressions.aggregate.AggregateExpression
val aggFn = fn.expr.asInstanceOf[AggregateExpression].aggregateFunction
scala> println(aggFn.numberedTreeString)
00 collect_list('gid, 0, 0)
01 +- 'gid
toAggregateExpression is used when:
AggregateFunctionis requested to toAggregateExpressionfunctionsutility is used to withAggregateFunction- others