Skip to content

Commit c198d91

Browse files
committed
Fixing tests
1 parent 68e88ef commit c198d91

File tree

7 files changed

+53
-42
lines changed

7 files changed

+53
-42
lines changed

x-pack/plugin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@ tasks.named("yamlRestCompatTestTransform").configure({ task ->
9494
task.skipTest("privileges/11_builtin/Test get builtin privileges" ,"unnecessary to test compatibility")
9595
task.skipTest("esql/61_enrich_ip/Invalid IP strings", "We switched from exceptions to null+warnings for ENRICH runtime errors")
9696
task.skipTest("esql/180_match_operator/match with non text field", "Match operator can now be used on non-text fields")
97+
task.skipTest("esql/180_match_operator/match with functions", "Error message changed")
9798
})
9899

x-pack/plugin/esql/qa/testFixtures/src/main/resources/match-function.csv-spec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ book_no:keyword | author:text | year:integer
146146

147147
matchWithDisjunctionAndConjunction
148148
required_capability: match_function
149+
required_capability: full_text_functions_disjunctions
149150

150151
from books
151152
| where (match(author, "Vonnegut") or match(author, "Marquez")) and match(description, "realism")
@@ -157,6 +158,7 @@ book_no:keyword
157158

158159
matchWithDisjunctionIncludingConjunction
159160
required_capability: match_function
161+
required_capability: full_text_functions_disjunctions
160162

161163
from books
162164
| where match(author, "Vonnegut") or (match(author, "Marquez") and match(description, "realism"))

x-pack/plugin/esql/qa/testFixtures/src/main/resources/match-operator.csv-spec

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ book_no:keyword | title:text
104104

105105

106106
matchWithDisjunction
107-
required_capability: match_function
107+
required_capability: match_operator
108108

109109
from books
110110
| where author : "Vonnegut" or author : "Guinane"
@@ -120,7 +120,7 @@ book_no:keyword | author:text
120120
;
121121

122122
matchWithDisjunctionAndFiltersConjunction
123-
required_capability: match_function
123+
required_capability: match_operator
124124

125125
from books
126126
| where (author : "Vonnegut" or author : "Guinane") and year > 1997
@@ -133,7 +133,8 @@ book_no:keyword | author:text | year:integer
133133
;
134134

135135
matchWithDisjunctionAndConjunction
136-
required_capability: match_function
136+
required_capability: match_operator
137+
required_capability: full_text_functions_disjunctions
137138

138139
from books
139140
| where (author : "Vonnegut" or author : "Marquez") and description : "realism"
@@ -144,7 +145,8 @@ book_no:keyword
144145
;
145146

146147
matchWithDisjunctionIncludingConjunction
147-
required_capability: match_function
148+
required_capability: match_operator
149+
required_capability: full_text_functions_disjunctions
148150

149151
from books
150152
| where author : "Vonnegut" or (author : "Marquez" and description : "realism")
@@ -159,7 +161,6 @@ book_no:keyword
159161
3950
160162
;
161163

162-
163164
matchWithFunctionPushedToLucene
164165
required_capability: match_operator_colon
165166

@@ -277,7 +278,7 @@ count(*): long | author.keyword:keyword
277278
;
278279

279280
testMatchBooleanField
280-
required_capability: match_function
281+
required_capability: match_operator
281282
required_capability: match_additional_types
282283

283284
from employees
@@ -293,7 +294,7 @@ Amabile | true | 2.09
293294
;
294295

295296
testMatchIntegerField
296-
required_capability: match_function
297+
required_capability: match_operator
297298
required_capability: match_additional_types
298299

299300
from employees
@@ -305,7 +306,7 @@ emp_no:integer | first_name:keyword
305306
;
306307

307308
testMatchDoubleField
308-
required_capability: match_function
309+
required_capability: match_operator
309310
required_capability: match_additional_types
310311

311312
from employees
@@ -317,7 +318,7 @@ emp_no:integer | salary_change:double
317318
;
318319

319320
testMatchLongField
320-
required_capability: match_function
321+
required_capability: match_operator
321322
required_capability: match_additional_types
322323

323324
from date_nanos
@@ -329,7 +330,7 @@ num:long
329330
;
330331

331332
testMatchUnsignedLongField
332-
required_capability: match_function
333+
required_capability: match_operator
333334
required_capability: match_additional_types
334335

335336
from ul_logs
@@ -341,7 +342,7 @@ bytes_out:unsigned_long
341342
;
342343

343344
testMatchIpFieldAsString
344-
required_capability: match_function
345+
required_capability: match_operator
345346
required_capability: match_additional_types
346347

347348
from sample_data
@@ -353,7 +354,7 @@ client_ip:ip | message:keyword
353354
;
354355

355356
testMatchDateFieldAsString
356-
required_capability: match_function
357+
required_capability: match_operator
357358
required_capability: match_additional_types
358359

359360
from date_nanos
@@ -365,7 +366,7 @@ millis:date
365366
;
366367

367368
testMatchDateNanosFieldAsString
368-
required_capability: match_function
369+
required_capability: match_operator
369370
required_capability: match_additional_types
370371

371372
from date_nanos
@@ -377,7 +378,7 @@ nanos:date_nanos
377378
;
378379

379380
testMatchBooleanFieldAsString
380-
required_capability: match_function
381+
required_capability: match_operator
381382
required_capability: match_additional_types
382383

383384
from employees
@@ -393,7 +394,7 @@ Amabile | true | 2.09
393394
;
394395

395396
testMatchIntegerFieldAsString
396-
required_capability: match_function
397+
required_capability: match_operator
397398
required_capability: match_additional_types
398399

399400
from employees
@@ -405,7 +406,7 @@ emp_no:integer | first_name:keyword
405406
;
406407

407408
testMatchDoubleFieldAsString
408-
required_capability: match_function
409+
required_capability: match_operator
409410
required_capability: match_additional_types
410411

411412
from employees
@@ -417,7 +418,7 @@ emp_no:integer | salary_change:double
417418
;
418419

419420
testMatchLongFieldAsString
420-
required_capability: match_function
421+
required_capability: match_operator
421422
required_capability: match_additional_types
422423

423424
from date_nanos
@@ -429,7 +430,7 @@ num:long
429430
;
430431

431432
testMatchUnsignedLongFieldAsString
432-
required_capability: match_function
433+
required_capability: match_operator
433434
required_capability: match_additional_types
434435

435436
from ul_logs
@@ -441,7 +442,7 @@ bytes_out:unsigned_long
441442
;
442443

443444
testMatchVersionFieldAsString
444-
required_capability: match_function
445+
required_capability: match_operator
445446
required_capability: match_additional_types
446447

447448
from apps
@@ -453,7 +454,7 @@ bbbbb | 2.1
453454
;
454455

455456
testMatchIntegerAsDouble
456-
required_capability: match_function
457+
required_capability: match_operator
457458
required_capability: match_additional_types
458459

459460
from employees
@@ -466,7 +467,7 @@ emp_no:integer | first_name:keyword
466467
;
467468

468469
testMatchDoubleAsIntegerField
469-
required_capability: match_function
470+
required_capability: match_operator
470471
required_capability: match_additional_types
471472

472473
from employees
@@ -481,7 +482,7 @@ emp_no:integer | height:double
481482
;
482483

483484
testMatchMultipleFieldTypes
484-
required_capability: match_function
485+
required_capability: match_operator
485486
required_capability: match_additional_types
486487

487488
from employees,employees_incompatible
@@ -498,7 +499,7 @@ emp_as_int:integer | name_as_kw:keyword
498499

499500

500501
testMatchMultipleFieldTypesKeywordText
501-
required_capability: match_function
502+
required_capability: match_operator
502503
required_capability: match_additional_types
503504

504505
from employees,employees_incompatible
@@ -513,7 +514,7 @@ Kazuhito
513514
;
514515

515516
testMatchMultipleFieldTypesDoubleFloat
516-
required_capability: match_function
517+
required_capability: match_operator
517518
required_capability: match_additional_types
518519

519520
from employees,employees_incompatible
@@ -532,7 +533,7 @@ emp_no:integer | height_dbl:double
532533
;
533534

534535
testMatchMultipleFieldTypesBooleanKeyword
535-
required_capability: match_function
536+
required_capability: match_operator
536537
required_capability: match_additional_types
537538

538539
from employees,employees_incompatible
@@ -549,7 +550,7 @@ true
549550
;
550551

551552
testMatchMultipleFieldTypesLongUnsignedLong
552-
required_capability: match_function
553+
required_capability: match_operator
553554
required_capability: match_additional_types
554555

555556
from employees,employees_incompatible
@@ -564,7 +565,7 @@ avg_worked_seconds_ul:unsigned_long
564565
;
565566

566567
testMatchMultipleFieldTypesDateNanosDate
567-
required_capability: match_function
568+
required_capability: match_operator
568569
required_capability: match_additional_types
569570

570571
from employees,employees_incompatible
@@ -579,7 +580,7 @@ hire_date_nanos:date_nanos
579580
;
580581

581582
testMatchWithWrongFieldValue
582-
required_capability: match_function
583+
required_capability: match_operator
583584
required_capability: match_additional_types
584585

585586
from employees,employees_incompatible

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,12 @@ public enum Cap {
565565
/**
566566
* Additional types for match function and operator
567567
*/
568-
MATCH_ADDITIONAL_TYPES;
568+
MATCH_ADDITIONAL_TYPES,
569+
570+
/**
571+
* Full text functions can be used in disjunctions
572+
*/
573+
FULL_TEXT_FUNCTIONS_DISJUNCTIONS;
569574

570575
private final boolean enabled;
571576

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/analysis/Verifier.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,10 +784,10 @@ private static void checkFullTextSearchDisjunctions(
784784
boolean right = checkFullTextSearchInDisjunctions(or.right());
785785
if (left ^ right) {
786786
Holder<String> elementName = new Holder<>();
787-
if (right) {
788-
or.left().forEachDown(FullTextFunction.class, ftf -> elementName.set(typeNameProvider.apply(ftf)));
789-
} else {
787+
if (left) {
790788
or.right().forEachDown(FullTextFunction.class, ftf -> elementName.set(typeNameProvider.apply(ftf)));
789+
} else {
790+
or.left().forEachDown(FullTextFunction.class, ftf -> elementName.set(typeNameProvider.apply(ftf)));
791791
}
792792
failures.add(
793793
fail(

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,14 @@ public void testMatchInsideEval() throws Exception {
11681168
public void testMatchFilter() throws Exception {
11691169
assertEquals(
11701170
"1:19: Invalid condition [first_name:\"Anna\" or starts_with(first_name, \"Anne\")]. "
1171-
+ "[:] operator can't be used as part of an or condition",
1171+
+ "[:] operator can be used as part of an OR condition, " +
1172+
"but only if other full text functions are used as part of the condition",
11721173
error("from test | where first_name:\"Anna\" or starts_with(first_name, \"Anne\")")
11731174
);
11741175

11751176
assertEquals(
1176-
"1:51: Invalid condition [first_name:\"Anna\" OR new_salary > 100]. " + "[:] operator can't be used as part of an or condition",
1177+
"1:51: Invalid condition [first_name:\"Anna\" OR new_salary > 100]. [:] operator can be used as part of an OR " +
1178+
"condition, but only if other full text functions are used as part of the condition",
11771179
error("from test | eval new_salary = salary + 10 | where first_name:\"Anna\" OR new_salary > 100")
11781180
);
11791181
}
@@ -1417,7 +1419,7 @@ private void checkWithDisjunctions(String functionName, String functionInvocatio
14171419
"1:19: Invalid condition [{} or length(first_name) > 12]. "
14181420
+ "[{}] "
14191421
+ functionType
1420-
+ " can't be used as part of an or condition",
1422+
+ " can be used as part of an OR condition, but only if other full text functions are used as part of the condition",
14211423
functionInvocation,
14221424
functionName
14231425
),
@@ -1426,30 +1428,30 @@ private void checkWithDisjunctions(String functionName, String functionInvocatio
14261428
assertEquals(
14271429
LoggerMessageFormat.format(
14281430
null,
1429-
"1:19: Invalid condition [({} and first_name is not null) or (length(first_name) > 12 and first_name is null)]. "
1431+
"1:20: Invalid condition [{} or first_name is not null]. "
14301432
+ "[{}] "
14311433
+ functionType
1432-
+ " can't be used as part of an or condition",
1434+
+ " can be used as part of an OR condition, but only if other full text functions are used as part of the condition",
14331435
functionInvocation,
14341436
functionName
14351437
),
14361438
error(
14371439
"from test | where ("
14381440
+ functionInvocation
1439-
+ " and first_name is not null) or (length(first_name) > 12 and first_name is null)"
1441+
+ " or first_name is not null) or (length(first_name) > 12 and match(last_name, \"Smith\"))"
14401442
)
14411443
);
14421444
assertEquals(
14431445
LoggerMessageFormat.format(
14441446
null,
1445-
"1:19: Invalid condition [({} and first_name is not null) or first_name is null]. "
1447+
"1:19: Invalid condition [{} or (last_name is not null and first_name is null)]. "
14461448
+ "[{}] "
14471449
+ functionType
1448-
+ " can't be used as part of an or condition",
1450+
+ " can be used as part of an OR condition, but only if other full text functions are used as part of the condition",
14491451
functionInvocation,
14501452
functionName
14511453
),
1452-
error("from test | where (" + functionInvocation + " and first_name is not null) or first_name is null")
1454+
error("from test | where " + functionInvocation + " or (last_name is not null and first_name is null)")
14531455
);
14541456
}
14551457

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ setup:
181181

182182
- match: { status: 400 }
183183
- match: { error.type: verification_exception }
184-
- match: { error.reason: "Found 1 problem\nline 1:19: Invalid condition [content:\"fox\" OR to_upper(content) == \"FOX\"]. [:] operator can't be used as part of an or condition" }
184+
- match: { error.reason: "Found 1 problem\nline 1:19: Invalid condition [content:\"fox\" OR to_upper(content) == \"FOX\"]. [:] operator can be used as part of an OR condition, but only if other full text functions are used as part of the condition" }
185185

186186
---
187187
"match within eval":

0 commit comments

Comments
 (0)