Skip to content

Commit b4221e4

Browse files
committed
Fix tests
1 parent 318b06e commit b4221e4

File tree

4 files changed

+30
-61
lines changed

4 files changed

+30
-61
lines changed

x-pack/plugin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,6 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->
9696
task.skipTest("esql/180_match_operator/match with non text field", "Match operator can now be used on non-text fields")
9797
task.skipTest("esql/180_match_operator/match with functions", "Error message changed")
9898
task.skipTest("esql/40_unsupported_types/semantic_text declared in mapping", "The semantic text field format changed")
99+
task.skipTest("esql/180_match_operator/match with disjunctions", "Disjunctions in full text functions work now")
99100
})
100101

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/MatchFunctionIT.java

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ public void setupIndex() {
3131
createAndPopulateIndex();
3232
}
3333

34-
@Override
35-
protected EsqlQueryResponse run(EsqlQueryRequest request) {
36-
assumeTrue("match function capability not available", EsqlCapabilities.Cap.MATCH_FUNCTION.isEnabled());
37-
return super.run(request);
38-
}
39-
4034
public void testSimpleWhereMatch() {
4135
var query = """
4236
FROM test
@@ -230,20 +224,19 @@ public void testWhereMatchAfterStats() {
230224
assertThat(error.getMessage(), containsString("Unknown column [content]"));
231225
}
232226

233-
public void testWhereMatchWithFunctions() {
227+
public void testWhereMatchNotPushedDown() {
234228
var query = """
235229
FROM test
236-
| WHERE match(content, "fox") OR to_upper(content) == "FOX"
230+
| WHERE match(content, "fox") OR length(content) < 20
231+
| KEEP id
232+
| SORT id
237233
""";
238-
var error = expectThrows(ElasticsearchException.class, () -> run(query));
239-
assertThat(
240-
error.getMessage(),
241-
containsString(
242-
"Invalid condition [match(content, \"fox\") OR to_upper(content) == \"FOX\"]. "
243-
+ "Full text functions can be used in an OR condition,"
244-
+ " but only if just full text functions are used in the OR condition"
245-
)
246-
);
234+
235+
try (var resp = run(query)) {
236+
assertColumnNames(resp.columns(), List.of("id"));
237+
assertColumnTypes(resp.columns(), List.of("integer"));
238+
assertValues(resp.values(), List.of(List.of(1), List.of(2), List.of(6)));
239+
}
247240
}
248241

249242
public void testWhereMatchWithRow() {
@@ -269,21 +262,6 @@ public void testMatchWithinEval() {
269262
assertThat(error.getMessage(), containsString("[MATCH] function is only supported in WHERE commands"));
270263
}
271264

272-
public void testMatchNonPushedDown() {
273-
var query = """
274-
FROM test
275-
| WHERE match(content, "fox") OR length(content) < 20
276-
| KEEP id
277-
| SORT id
278-
""";
279-
280-
try (var resp = run(query)) {
281-
assertColumnNames(resp.columns(), List.of("id"));
282-
assertColumnTypes(resp.columns(), List.of("integer"));
283-
assertValues(resp.values(), List.of(List.of(1), List.of(2), List.of(6)));
284-
}
285-
}
286-
287265
private void createAndPopulateIndex() {
288266
var indexName = "test";
289267
var client = client().admin().indices();

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/MatchOperatorIT.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,19 @@ public void testWhereMatchAfterStats() {
206206
assertThat(error.getMessage(), containsString("Unknown column [content]"));
207207
}
208208

209-
public void testWhereMatchWithFunctions() {
209+
public void testWhereMatchNotPushedDown() {
210210
var query = """
211211
FROM test
212-
| WHERE content:"fox" OR to_upper(content) == "FOX"
212+
| WHERE content:"fox" OR length(content) < 20
213+
| KEEP id
214+
| SORT id
213215
""";
214-
var error = expectThrows(ElasticsearchException.class, () -> run(query));
215-
assertThat(
216-
error.getMessage(),
217-
containsString(
218-
"Invalid condition [content:\"fox\" OR to_upper(content) == \"FOX\"]. "
219-
+ "Full text functions can be used in an OR condition, "
220-
+ "but only if just full text functions are used in the OR condition"
221-
)
222-
);
216+
217+
try (var resp = run(query)) {
218+
assertColumnNames(resp.columns(), List.of("id"));
219+
assertColumnTypes(resp.columns(), List.of("integer"));
220+
assertValues(resp.values(), List.of(List.of(1), List.of(2), List.of(6)));
221+
}
223222
}
224223

225224
public void testWhereMatchWithRow() {

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/180_match_operator.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -171,30 +171,21 @@ setup:
171171

172172
---
173173
"match with disjunctions":
174+
- requires:
175+
capabilities:
176+
- method: POST
177+
path: /_query
178+
parameters: [ method, path, parameters, capabilities ]
179+
capabilities: [ full_text_functions_disjunctions ]
180+
reason: "Full text functions disjunctions support"
174181
- do:
175-
catch: bad_request
176-
allowed_warnings_regex:
177-
- "No limit defined, adding default limit of \\[.*\\]"
178-
esql.query:
179-
body:
180-
query: 'FROM test | WHERE content:"fox" OR to_upper(content) == "FOX"'
181-
182-
- match: { status: 400 }
183-
- match: { error.type: verification_exception }
184-
- match: { error.reason: "/.+Invalid\\ condition\\ \\[content\\:\"fox\"\\ OR\\ to_upper\\(content\\)\\ ==\\ \"FOX\"\\]\\./" }
185-
186-
- do:
187-
catch: bad_request
188182
allowed_warnings_regex:
189183
- "No limit defined, adding default limit of \\[.*\\]"
190184
esql.query:
191185
body:
192-
query: 'FROM test | WHERE content:"fox" OR to_upper(content) == "FOX"'
193-
194-
- match: { status: 400 }
195-
- match: { error.type: verification_exception }
196-
- match: { error.reason: "/.+Invalid\\ condition\\ \\[content\\:\"fox\"\\ OR\\ to_upper\\(content\\)\\ ==\\ \"FOX\"\\]\\./" }
186+
query: 'FROM test | WHERE content:"fox" OR length(content) < 20'
197187

188+
- length: { values: 3 }
198189

199190
---
200191
"match within eval":

0 commit comments

Comments
 (0)