|
7 | 7 |
|
8 | 8 | package org.elasticsearch.xpack.esql.plan.logical.join; |
9 | 9 |
|
| 10 | +import org.elasticsearch.xpack.esql.capabilities.PostAnalysisVerificationAware; |
10 | 11 | import org.elasticsearch.xpack.esql.capabilities.TelemetryAware; |
| 12 | +import org.elasticsearch.xpack.esql.common.Failures; |
11 | 13 | import org.elasticsearch.xpack.esql.core.expression.Attribute; |
12 | 14 | import org.elasticsearch.xpack.esql.core.tree.NodeInfo; |
13 | 15 | import org.elasticsearch.xpack.esql.core.tree.Source; |
| 16 | +import org.elasticsearch.xpack.esql.plan.logical.Limit; |
14 | 17 | import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; |
15 | 18 | import org.elasticsearch.xpack.esql.plan.logical.SurrogateLogicalPlan; |
16 | 19 | import org.elasticsearch.xpack.esql.plan.logical.join.JoinTypes.UsingJoinType; |
17 | 20 |
|
| 21 | +import java.util.LinkedList; |
18 | 22 | import java.util.List; |
19 | 23 |
|
20 | 24 | import static java.util.Collections.emptyList; |
| 25 | +import static org.elasticsearch.xpack.esql.common.Failure.fail; |
21 | 26 | import static org.elasticsearch.xpack.esql.plan.logical.join.JoinTypes.LEFT; |
22 | 27 |
|
23 | 28 | /** |
24 | 29 | * Lookup join - specialized LEFT (OUTER) JOIN between the main left side and a lookup index (index_mode = lookup) on the right. |
25 | 30 | */ |
26 | | -public class LookupJoin extends Join implements SurrogateLogicalPlan, TelemetryAware { |
| 31 | +public class LookupJoin extends Join implements SurrogateLogicalPlan, TelemetryAware, PostAnalysisVerificationAware { |
27 | 32 |
|
28 | 33 | public LookupJoin(Source source, LogicalPlan left, LogicalPlan right, List<Attribute> joinFields, boolean isRemote) { |
29 | 34 | this(source, left, right, new UsingJoinType(LEFT, joinFields), emptyList(), emptyList(), emptyList(), isRemote); |
@@ -87,4 +92,21 @@ protected NodeInfo<Join> info() { |
87 | 92 | public String telemetryLabel() { |
88 | 93 | return "LOOKUP JOIN"; |
89 | 94 | } |
| 95 | + |
| 96 | + @Override |
| 97 | + public void postAnalysisVerification(Failures failures) { |
| 98 | + super.postAnalysisVerification(failures); |
| 99 | + if (isRemote()) { |
| 100 | + checkRemoteJoin(failures); |
| 101 | + } |
| 102 | + } |
| 103 | + |
| 104 | + private void checkRemoteJoin(Failures failures) { |
| 105 | + // Check only for LIMITs, Join will check the rest post-optimization |
| 106 | + this.forEachUp(Limit.class, f -> { |
| 107 | + failures.add( |
| 108 | + fail(this, "LOOKUP JOIN with remote indices can't be executed after [" + f.source().text() + "]" + f.source().source()) |
| 109 | + ); |
| 110 | + }); |
| 111 | + } |
90 | 112 | } |
0 commit comments