Skip to content

Commit b348671

Browse files
authored
Lookup join on multiple join fields not yet supported (#118858)
1 parent 37807b8 commit b348671

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

docs/changelog/118858.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 118858
2+
summary: Lookup join on multiple join fields not yet supported
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/LogicalPlanBuilder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ public PlanFactory visitJoinCommand(EsqlBaseParser.JoinCommandContext ctx) {
564564
}
565565
}
566566

567+
var matchFieldsCount = joinFields.size();
568+
if (matchFieldsCount > 1) {
569+
throw new ParsingException(source, "JOIN ON clause only supports one field at the moment, found [{}]", matchFieldsCount);
570+
}
571+
567572
return p -> new LookupJoin(source, p, right, joinFields);
568573
}
569574
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/ParsingTests.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.elasticsearch.xcontent.XContentBuilder;
1313
import org.elasticsearch.xcontent.json.JsonXContent;
1414
import org.elasticsearch.xpack.esql.LoadMapping;
15+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1516
import org.elasticsearch.xpack.esql.core.expression.Expression;
1617
import org.elasticsearch.xpack.esql.core.type.DataType;
1718
import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry;
@@ -111,6 +112,46 @@ public void testTooBigQuery() {
111112
assertEquals("-1:-1: ESQL statement is too large [1000011 characters > 1000000]", error(query.toString()));
112113
}
113114

115+
public void testJoinOnConstant() {
116+
assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled());
117+
assertEquals(
118+
"1:55: JOIN ON clause only supports fields at the moment, found [123]",
119+
error("row languages = 1, gender = \"f\" | lookup join test on 123")
120+
);
121+
assertEquals(
122+
"1:55: JOIN ON clause only supports fields at the moment, found [\"abc\"]",
123+
error("row languages = 1, gender = \"f\" | lookup join test on \"abc\"")
124+
);
125+
assertEquals(
126+
"1:55: JOIN ON clause only supports fields at the moment, found [false]",
127+
error("row languages = 1, gender = \"f\" | lookup join test on false")
128+
);
129+
}
130+
131+
public void testJoinOnMultipleFields() {
132+
assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled());
133+
assertEquals(
134+
"1:35: JOIN ON clause only supports one field at the moment, found [2]",
135+
error("row languages = 1, gender = \"f\" | lookup join test on gender, languages")
136+
);
137+
}
138+
139+
public void testJoinTwiceOnTheSameField() {
140+
assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled());
141+
assertEquals(
142+
"1:35: JOIN ON clause only supports one field at the moment, found [2]",
143+
error("row languages = 1, gender = \"f\" | lookup join test on languages, languages")
144+
);
145+
}
146+
147+
public void testJoinTwiceOnTheSameField_TwoLookups() {
148+
assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V7.isEnabled());
149+
assertEquals(
150+
"1:80: JOIN ON clause only supports one field at the moment, found [2]",
151+
error("row languages = 1, gender = \"f\" | lookup join test on languages | eval x = 1 | lookup join test on gender, gender")
152+
);
153+
}
154+
114155
private String functionName(EsqlFunctionRegistry registry, Expression functionCall) {
115156
for (FunctionDefinition def : registry.listFunctions()) {
116157
if (functionCall.getClass().equals(def.clazz())) {

0 commit comments

Comments
 (0)