Class SortMergeRule

All Implemented Interfaces:
TransformationRule

@Enclosing public class SortMergeRule extends RelRule<SortMergeRule.Config> implements TransformationRule
This rule try to merge the double Sort,one is Limit semantics, another sort is Limit or TOPN semantics.

It generally used with the SortProjectTransposeRule rule.

For example:


 select
   concat('-', N_REGIONKEY) from
   (
     select
       *
     from nation limit 10000) limit 10
  

will convert to


 select
   concat('-', N_REGIONKEY)
 from
   nation limit 10
 

The sql :


 select concat('-',N_REGIONKEY) from
 (SELECT * FROM nation order BY N_REGIONKEY DESC LIMIT 10000) limit 10
 

will convert to


 SELECT concat('-',N_REGIONKEY) FROM nation order BY N_REGIONKEY DESC LIMIT 10
 

In the future,we could also extend other sort merge logic in this rule.

See Also: