Skip to content

Commit e367e8c

Browse files
Fix more UTs
1 parent ef894f3 commit e367e8c

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ static TransportVersion def(int id) {
346346
public static final TransportVersion ML_INFERENCE_LLAMA_ADDED = def(9_125_0_00);
347347
public static final TransportVersion ESQL_LOOKUP_JOIN_ON_MANY_FIELDS = def(9_126_0_00);
348348

349-
350349
/*
351350
* STOP! READ THIS FIRST! No, really,
352351
* ____ _____ ___ ____ _ ____ _____ _ ____ _____ _ _ ___ ____ _____ ___ ____ ____ _____ _

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,21 @@ public PlanFactory visitJoinCommand(EsqlBaseParser.JoinCommandContext ctx) {
634634
}
635635
}
636636

637+
var matchFieldsCount = joinFields.size();
638+
if (matchFieldsCount > 1) {
639+
Set<String> matchFieldNames = new LinkedHashSet<>();
640+
for (Attribute field : joinFields) {
641+
if (matchFieldNames.add(field.name()) == false) {
642+
throw new ParsingException(
643+
field.source(),
644+
"JOIN ON clause does not support multiple fields with the same name, found multiple instances of [{}]",
645+
field.name()
646+
);
647+
}
648+
649+
}
650+
}
651+
637652
return p -> {
638653
boolean hasRemotes = p.anyMatch(node -> {
639654
if (node instanceof UnresolvedRelation r) {

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,26 +135,18 @@ public void testJoinOnConstant() {
135135
);
136136
}
137137

138-
public void testJoinOnMultipleFields() {
139-
assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled());
140-
assertEquals(
141-
"1:35: JOIN ON clause only supports one field at the moment, found [2]",
142-
error("row languages = 1, gender = \"f\" | lookup join test on gender, languages")
143-
);
144-
}
145-
146138
public void testJoinTwiceOnTheSameField() {
147139
assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled());
148140
assertEquals(
149-
"1:35: JOIN ON clause only supports one field at the moment, found [2]",
141+
"1:66: JOIN ON clause does not support multiple fields with the same name, found multiple instances of [languages]",
150142
error("row languages = 1, gender = \"f\" | lookup join test on languages, languages")
151143
);
152144
}
153145

154146
public void testJoinTwiceOnTheSameField_TwoLookups() {
155147
assumeTrue("LOOKUP JOIN available as snapshot only", EsqlCapabilities.Cap.JOIN_LOOKUP_V12.isEnabled());
156148
assertEquals(
157-
"1:80: JOIN ON clause only supports one field at the moment, found [2]",
149+
"1:108: JOIN ON clause does not support multiple fields with the same name, found multiple instances of [gender]",
158150
error("row languages = 1, gender = \"f\" | lookup join test on languages | eval x = 1 | lookup join test on gender, gender")
159151
);
160152
}

0 commit comments

Comments
 (0)