Skip to content

Commit 85e3fb7

Browse files
authored
Reword lookup join error messages (#129312)
1 parent 61594da commit 85e3fb7

File tree

6 files changed

+46
-10
lines changed

6 files changed

+46
-10
lines changed

x-pack/plugin/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->
134134
task.skipTest("esql/90_non_indexed/fetch", "Temporary until backported")
135135
task.skipTest("esql/63_enrich_int_range/Invalid age as double", "TODO: require disable allow_partial_results")
136136
task.skipTest("esql/191_lookup_join_on_datastreams/data streams not supported in LOOKUP JOIN", "Added support for aliases in JOINs")
137+
task.skipTest("esql/190_lookup_join/non-lookup index", "Error message changed")
138+
task.skipTest("esql/192_lookup_join_on_aliases/alias-pattern-multiple", "Error message changed")
137139
})
138140

139141
tasks.named('yamlRestCompatTest').configure {

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,11 @@ public enum Cap {
11821182
*/
11831183
ENABLE_LOOKUP_JOIN_ON_ALIASES,
11841184

1185+
/**
1186+
* Lookup error messages were updated to make them a bit easier to understand.
1187+
*/
1188+
UPDATE_LOOKUP_JOIN_ERROR_MESSAGES,
1189+
11851190
/**
11861191
* Allows RLIKE to correctly handle the "empty language" flag, `#`.
11871192
*/

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/join/LookupJoin.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,24 @@ public void postAnalysisVerification(Failures failures) {
9090
var indexNameWithModes = esr.indexNameWithModes();
9191
if (indexNameWithModes.size() != 1) {
9292
failures.add(
93-
fail(esr, "invalid [{}] resolution in lookup mode to [{}] indices", esr.indexPattern(), indexNameWithModes.size())
93+
fail(
94+
esr,
95+
"Lookup Join requires a single lookup mode index; [{}] resolves to [{}] indices",
96+
esr.indexPattern(),
97+
indexNameWithModes.size()
98+
)
9499
);
95-
} else if (indexNameWithModes.values().iterator().next() != IndexMode.LOOKUP) {
100+
return;
101+
}
102+
var indexAndMode = indexNameWithModes.entrySet().iterator().next();
103+
if (indexAndMode.getValue() != IndexMode.LOOKUP) {
96104
failures.add(
97105
fail(
98106
esr,
99-
"invalid [{}] resolution in lookup mode to an index in [{}] mode",
107+
"Lookup Join requires a single lookup mode index; [{}] resolves to [{}] in [{}] mode",
100108
esr.indexPattern(),
101-
indexNameWithModes.values().iterator().next()
109+
indexAndMode.getKey(),
110+
indexAndMode.getValue()
102111
)
103112
);
104113
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,12 +2306,18 @@ public void testLookupJoinIndexMode() {
23062306
AnalyzerTestUtils.analyzer(lookupResolutionAsIndex, indexResolutionAsLookup)
23072307
)
23082308
);
2309-
assertThat(e.getMessage(), containsString("1:70: invalid [test] resolution in lookup mode to an index in [standard] mode"));
2309+
assertThat(
2310+
e.getMessage(),
2311+
containsString("1:70: Lookup Join requires a single lookup mode index; [test] resolves to [test] in [standard] mode")
2312+
);
23102313
e = expectThrows(
23112314
VerificationException.class,
23122315
() -> analyze("FROM test | LOOKUP JOIN test ON languages", AnalyzerTestUtils.analyzer(indexResolution, indexResolutionAsLookup))
23132316
);
2314-
assertThat(e.getMessage(), containsString("1:25: invalid [test] resolution in lookup mode to an index in [standard] mode"));
2317+
assertThat(
2318+
e.getMessage(),
2319+
containsString("1:25: Lookup Join requires a single lookup mode index; [test] resolves to [test] in [standard] mode")
2320+
);
23152321
}
23162322

23172323
public void testImplicitCasting() {

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/190_lookup_join.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,22 @@ basic:
145145
- match: {values.1: [2, "yellow"]}
146146

147147
---
148-
non-lookup index:
148+
fails with non-lookup index:
149+
- requires:
150+
capabilities:
151+
- method: POST
152+
path: /_query
153+
parameters: []
154+
capabilities: [update_lookup_join_error_messages]
155+
reason: "checks updated error messages"
149156
- do:
150157
esql.query:
151158
body:
152159
query: 'FROM test-lookup-1 | SORT key | LOOKUP JOIN test ON key | LIMIT 3'
153160
catch: "bad_request"
154161

155162
- match: { error.type: "verification_exception" }
156-
- contains: { error.reason: "Found 1 problem\nline 1:45: invalid [test] resolution in lookup mode to an index in [standard] mode" }
163+
- contains: { error.reason: "Found 1 problem\nline 1:45: Lookup Join requires a single lookup mode index; [test] resolves to [test] in [standard] mode" }
157164

158165
---
159166
pattern-multiple:

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/192_lookup_join_on_aliases.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,22 @@ alias-repeated-index:
186186
- match: {values.1: [2, "yellow"]}
187187

188188
---
189-
alias-pattern-multiple:
189+
fails when alias or pattern resolves to multiple:
190+
- requires:
191+
capabilities:
192+
- method: POST
193+
path: /_query
194+
parameters: []
195+
capabilities: [update_lookup_join_error_messages]
196+
reason: "checks updated error messages"
190197
- do:
191198
esql.query:
192199
body:
193200
query: 'FROM test-lookup-1 | LOOKUP JOIN test-lookup-alias-pattern-multiple ON key'
194201
catch: "bad_request"
195202

196203
- match: { error.type: "verification_exception" }
197-
- contains: { error.reason: "Found 1 problem\nline 1:34: invalid [test-lookup-alias-pattern-multiple] resolution in lookup mode to [4] indices" }
204+
- contains: { error.reason: "Found 1 problem\nline 1:34: Lookup Join requires a single lookup mode index; [test-lookup-alias-pattern-multiple] resolves to [4] indices" }
198205

199206
---
200207
alias-pattern-single:

0 commit comments

Comments
 (0)