Class MergeLimits
java.lang.Object
io.trino.sql.planner.iterative.rule.MergeLimits
This rule handles both LimitNode with ties and LimitNode without ties.
The parent LimitNode is without ties.
If the child LimitNode is without ties, both nodes are merged into a single LimitNode with row count being the minimum of their row counts:
- Limit (3)
- Limit (5)
is transformed into:
- Limit (3)
If the child LimitNode is with ties, the rule's behavior depends on both nodes' row count. If parent row count is lower or equal to child row count, child node is removed from the plan:
- Limit (3)
- Limit (5, withTies)
is transformed into:
- Limit (3)
If parent row count is greater than child row count, both nodes remain in the plan, but they are rearranged in the way that the LimitNode with ties is the root:
- Limit (5)
- Limit (3, withTies)
is transformed into:
- Limit (3, withTies)
- Limit (5)
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.trino.sql.planner.iterative.Rule
Rule.Context, Rule.Result -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapply(LimitNode parent, Captures captures, Rule.Context context) Returns a pattern to which plan nodes this rule applies.