Class AggregateMinMaxToLimitRule

All Implemented Interfaces:
TransformationRule

@Enclosing public class AggregateMinMaxToLimitRule extends RelRule<AggregateMinMaxToLimitRule.Config> implements TransformationRule
Rule that transforms an MIN/MAX Aggregate functions into equivalent subqueries with ORDER BY and LIMIT 1 for potential performance optimization.

This rule converts queries of the form:


 SELECT MIN(c1), MAX(c2) FROM t;
 
into:

 SELECT
   (SELECT c1 FROM t WHERE c1 IS NOT NULL ORDER BY c1 ASC LIMIT 1)
     AS min_c1,
   (SELECT c2 FROM t WHERE c2 IS NOT NULL ORDER BY c2 DESC LIMIT 1)
    AS max_c2
 FROM (VALUES(1));