|
24 | 24 | import org.elasticsearch.xpack.esql.optimizer.PhysicalOptimizerRules; |
25 | 25 | import org.elasticsearch.xpack.esql.plan.physical.EsQueryExec; |
26 | 26 | import org.elasticsearch.xpack.esql.plan.physical.EvalExec; |
27 | | -import org.elasticsearch.xpack.esql.plan.physical.ExchangeExec; |
28 | 27 | import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; |
29 | 28 | import org.elasticsearch.xpack.esql.plan.physical.TopNExec; |
30 | 29 |
|
@@ -82,17 +81,6 @@ public PhysicalPlan rewrite(TopNExec topNExec) { |
82 | 81 | } |
83 | 82 | } |
84 | 83 |
|
85 | | - /** |
86 | | - * TODO: Consider deleting this case entirely. We do not know if this is ever hit. |
87 | | - */ |
88 | | - record PushableExchangeExec(ExchangeExec exchangeExec, EsQueryExec queryExec) implements Pushable { |
89 | | - public PhysicalPlan rewrite(TopNExec topNExec) { |
90 | | - var sorts = buildFieldSorts(topNExec.order()); |
91 | | - var limit = topNExec.limit(); |
92 | | - return exchangeExec.replaceChild(queryExec.withSorts(sorts).withLimit(limit)); |
93 | | - } |
94 | | - } |
95 | | - |
96 | 84 | record PushableQueryExec(EsQueryExec queryExec) implements Pushable { |
97 | 85 | public PhysicalPlan rewrite(TopNExec topNExec) { |
98 | 86 | var sorts = buildFieldSorts(topNExec.order()); |
@@ -141,13 +129,6 @@ && canPushDownOrders(topNExec.order(), hasIdenticalDelegate)) { |
141 | 129 | // With the simplest case of `FROM index | SORT ...` we only allow pushing down if the sort is on a field |
142 | 130 | return new PushableQueryExec(queryExec); |
143 | 131 | } |
144 | | - if (child instanceof ExchangeExec exchangeExec |
145 | | - && exchangeExec.child() instanceof EsQueryExec queryExec |
146 | | - && queryExec.canPushSorts() |
147 | | - && canPushDownOrders(topNExec.order(), hasIdenticalDelegate)) { |
148 | | - // When we have an exchange between the FROM and the SORT, we also only allow pushing down if the sort is on a field |
149 | | - return new PushableExchangeExec(exchangeExec, queryExec); |
150 | | - } |
151 | 132 | if (child instanceof EvalExec evalExec && evalExec.child() instanceof EsQueryExec queryExec && queryExec.canPushSorts()) { |
152 | 133 | // When we have an EVAL between the FROM and the SORT, we consider pushing down if the sort is on a field and/or |
153 | 134 | // a distance function defined in the EVAL. We also move the EVAL to after the SORT. |
|
0 commit comments