AggregateExpression — Unevaluable Expression Container for AggregateFunction¶
AggregateExpression
is an unevaluable expression that acts as a container for an AggregateFunction.
AggregateExpression
contains the following:
- [[aggregateFunction]] AggregateFunction
- [[mode]]
AggregateMode
- [[isDistinct]]
isDistinct
flag indicating whether this aggregation is distinct or not (e.g. whether SQL'sDISTINCT
keyword was used for the <>) - [[resultId]]
ExprId
AggregateExpression
is created when:
-
Analyzer
is requested to resolve AggregateFunctions (and creates anAggregateExpression
withComplete
aggregate mode for the functions) -
UserDefinedAggregateFunction
is created withisDistinct
flag disabled or enabled -
AggUtils
is requested to planAggregateWithOneDistinct (and createsAggregateExpressions
withPartial
andFinal
aggregate modes for the functions) -
Aggregator
is requested for a spark-sql-TypedColumn.md[TypedColumn] (usingAggregator.toColumn
) -
AggregateFunction
is spark-sql-Expression-AggregateFunction.md#toAggregateExpression[wrapped in a AggregateExpression]
[[toString-prefixes]] .toString's Prefixes per AggregateMode [cols="1,2",options="header",width="100%"] |=== | Prefix | AggregateMode
| partial_
| Partial
| merge_
| PartialMerge
| (empty) | Final
or Complete
|===
[[properties]] .AggregateExpression's Properties [width="100%",cols="1,2",options="header"] |=== | Name | Description
| canonicalized
| AggregateExpression
with <canonicalized
with the special ExprId
as 0
.
| children
| <AggregateExpression
was created).
| dataType
| DataType of AggregateFunction expression
| foldable
| Disabled (i.e. false
)
| nullable
| Whether or not <
| [[references]] references
a| AttributeSet
with the following:
-
references
of <> when < > is Partial
orComplete
-
spark-sql-Expression-AggregateFunction.md#aggBufferAttributes[aggBufferAttributes] of <
> when PartialMerge
orFinal
| resultAttribute
a|
spark-sql-Expression-Attribute.md[Attribute] that is:
-
AttributeReference
when <> is itself resolved -
UnresolvedAttribute
otherwise
| sql
| Requests <
| toString
| <toAggString
(with <