Extracts WindowExpressions from the projectList of a Project operator and
aggregateExpressions of an Aggregate operator and creates individual Window
operators for every distinct WindowSpecDefinition.
This rule handles three cases:
A Project having WindowExpressions in its projectList;
An Aggregate having WindowExpressions in its aggregateExpressions.
A Filter->Aggregate pattern representing GROUP BY with a HAVING
clause and the Aggregate has WindowExpressions in its aggregateExpressions.
Note: If there is a GROUP BY clause in the query, aggregations and corresponding
filters (expressions in the HAVING clause) should be evaluated before any
WindowExpression. If a query has SELECT DISTINCT, the DISTINCT part should be
evaluated after all WindowExpressions.
For every case, the transformation works as follows:
1. For a list of Expressions (a projectList or an aggregateExpressions), partitions
it two lists of Expressions, one for all WindowExpressions and another for
all regular expressions.
2. For all WindowExpressions, groups them based on their WindowSpecDefinitions.
3. For every distinct WindowSpecDefinition, creates a Window operator and inserts
it into the plan tree.
Extracts WindowExpressions from the projectList of a Project operator and aggregateExpressions of an Aggregate operator and creates individual Window operators for every distinct WindowSpecDefinition.
This rule handles three cases:
For every case, the transformation works as follows: 1. For a list of Expressions (a projectList or an aggregateExpressions), partitions it two lists of Expressions, one for all WindowExpressions and another for all regular expressions. 2. For all WindowExpressions, groups them based on their WindowSpecDefinitions. 3. For every distinct WindowSpecDefinition, creates a Window operator and inserts it into the plan tree.