Class AggregateFilterToFilteredAggregateRule


@Enclosing public class AggregateFilterToFilteredAggregateRule extends RelRule<AggregateFilterToFilteredAggregateRule.Config>
Rule that converts an aggregate on top of a filter into a filtered aggregate.

Before


   SELECT SUM(salary)
   FROM Emp
   WHERE deptno = 10
  

After


   SELECT SUM(salary) FILTER (WHERE deptno = 10)
   FROM Emp
  

The transformation is particularly useful in view-based rewriting. The removal of the Filter operators lifts some restrictions when using the MaterializedViewRules.

Filtered aggregates can be transformed to other equivalent forms via other transformation rules (e.g., AggregateFilterToCaseRule).