Skip to content

Aggregate Logical Operator

Aggregate is a unary logical operator for Aggregation Queries and can represent the following high-level operators in a logical query plan:

Internal Use

Aggregate logical operator is also used internally as part of logical and physical optimizations.

Creating Instance

Aggregate takes the following to be created:

Aggregate is created when:

Output Schema

QueryPlan
output: Seq[Attribute]

output is part of the QueryPlan abstraction.

output is the Attributes of the aggregate expressions.

Metadata Output Schema

LogicalPlan
metadataOutput: Seq[Attribute]

metadataOutput is part of the LogicalPlan abstraction.

metadataOutput is empty (Nil).

Node Patterns

TreeNode
nodePatterns : Seq[TreePattern]

nodePatterns is part of the TreeNode abstraction.

nodePatterns is AGGREGATE.

Checking Requirements for HashAggregateExec

supportsHashAggregate(
  aggregateBufferAttributes: Seq[Attribute]): Boolean

supportsHashAggregate builds a StructType for the given aggregateBufferAttributes.

In the end, supportsHashAggregate isAggregateBufferMutable.


supportsHashAggregate is used when:

isAggregateBufferMutable

isAggregateBufferMutable(
  schema: StructType): Boolean

isAggregateBufferMutable is enabled (true) when the type of all the fields (in the given schema) are mutable.


isAggregateBufferMutable is used when: