Class PruneRedundantOrderBy
java.lang.Object
org.elasticsearch.xpack.esql.rule.Rule<LogicalPlan,LogicalPlan>
org.elasticsearch.xpack.esql.optimizer.rules.logical.OptimizerRules.OptimizerRule<LogicalPlan>
org.elasticsearch.xpack.esql.optimizer.rules.logical.PruneRedundantOrderBy
SORT cannot be executed without a LIMIT, as ES|QL doesn't support unbounded sort (yet).
The planner tries to push down LIMIT and transform all the unbounded sorts into a TopN. In some cases it's not possible though, eg.
from test | sort x | lookup join lookup on x | sort y
from test | sort x | mv_expand x | sort y
"sort y" will become a TopN due to the addition of the default Limit, but "sort x" will remain unbounded, so the query could not be executed.
In most cases though, following commands can make the previous SORTs redundant, because it will re-sort previously sorted results (eg. if there is another SORT) or because the order will be scrambled by another command (eg. a STATS)
This rule finds and prunes redundant SORTs, attempting to make the plan executable.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.elasticsearch.xpack.esql.optimizer.rules.logical.OptimizerRules.OptimizerRule
apply
-
Constructor Details
-
PruneRedundantOrderBy
public PruneRedundantOrderBy()
-
-
Method Details
-
rule
- Specified by:
rulein classOptimizerRules.OptimizerRule<LogicalPlan>
-