Skip to content

Commit 85a442f

Browse files
committed
Add required_capability: fn_contains to trigger CONTAINS test cases replacing skip logic.
1 parent 5db47a2 commit 85a442f

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ emp_no:integer | name:keyword
389389
;
390390

391391

392-
contains#[skip:-9.2.99,reason:new string function added in 9.3]
392+
contains
393+
required_capability: fn_contains
393394
// tag::contains[]
394395
ROW a = "hello"
395396
| EVAL has_ll = CONTAINS(a, "ll")
@@ -402,28 +403,32 @@ hello | true
402403
// end::contains-result[]
403404
;
404405

405-
containsFail#[skip:-9.2.99,reason:new string function added in 9.3]
406+
containsFail
407+
required_capability: fn_contains
406408
row a = "hello" | eval a_ll = contains(a, "int");
407409

408410
a:keyword | a_ll:boolean
409411
hello | false
410412
;
411413

412-
containsLongerSubstr#[skip:-9.2.99,reason:new string function added in 9.3]
414+
containsLongerSubstr
415+
required_capability: fn_contains
413416
row a = "hello" | eval a_ll = contains(a, "farewell");
414417

415418
a:keyword | a_ll:boolean
416419
hello | false
417420
;
418421

419-
containsSame#[skip:-9.2.99,reason:new string function added in 9.3]
422+
containsSame
423+
required_capability: fn_contains
420424
row a = "hello" | eval a_ll = contains(a, "hello");
421425

422426
a:keyword | a_ll:boolean
423427
hello | true
424428
;
425429

426-
containsWithSubstring#[skip:-9.2.99,reason:new string function added in 9.3]
430+
containsWithSubstring
431+
required_capability: fn_contains
427432
from employees | where emp_no <= 10010 | eval f_s = substring(last_name, 2) | eval f_l = contains(last_name, f_s) | keep emp_no, last_name, f_s, f_l;
428433
ignoreOrder:true
429434

@@ -440,28 +445,32 @@ emp_no:integer | last_name:keyword | f_s:keyword | f_l:boolean
440445
10010 | Piveteau | iveteau | true
441446
;
442447

443-
containsUtf16Emoji#[skip:-9.2.99,reason:new string function added in 9.3]
448+
containsUtf16Emoji
449+
required_capability: fn_contains
444450
row a = "🐱Meow!🐶Woof!" | eval f_s = substring(a, 2) | eval f_l = contains(a, f_s);
445451

446452
a:keyword | f_s:keyword | f_l:boolean
447453
🐱Meow!🐶Woof! | Meow!🐶Woof! | true
448454
;
449455

450-
containsNestedCase#[skip:-9.2.99,reason:new string function added in 9.3]
456+
containsNestedCase
457+
required_capability: fn_contains
451458
row a = "hello" | eval a_ll = CASE(contains(a, "ll"), "success","fail");
452459

453460
a:keyword | a_ll:keyword
454461
hello | success
455462
;
456463

457-
containsNestSubstring#[skip:-9.2.99,reason:new string function added in 9.3]
464+
containsNestSubstring
465+
required_capability: fn_contains
458466
row a = "hello" | eval a_ll = contains(substring(a, 2), "ll");
459467

460468
a:keyword | a_ll:boolean
461469
hello | true
462470
;
463471

464-
containsWarnings#[skip:-9.2.99,reason:new string function added in 9.3]
472+
containsWarnings
473+
required_capability: fn_contains
465474

466475
from hosts | where host=="epsilon" | eval l1 = contains(host_group, "ate"), l2 = contains(description, "ate") | keep l1, l2;
467476
ignoreOrder:true

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
@@ -190,6 +190,11 @@ public enum Cap {
190190
*/
191191
FN_REVERSE_GRAPHEME_CLUSTERS,
192192

193+
/**
194+
* Support for function {@code CONTAINS}. Done in <a href="https://github.com/elastic/elasticsearch/pull/133016">#133016.</a>
195+
*/
196+
FN_CONTAINS,
197+
193198
/**
194199
* Support for function {@code CBRT}. Done in #108574.
195200
*/

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/Contains.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ static boolean process(BytesRef str, BytesRef substr) {
103103
if (str == null || substr == null || str.length < substr.length) {
104104
return false;
105105
}
106-
String utf8ToString = str.utf8ToString();
107-
return utf8ToString.contains(substr.utf8ToString());
106+
return str.utf8ToString().contains(substr.utf8ToString());
108107
}
109108

110109
@Override

0 commit comments

Comments
 (0)