77
88package org .elasticsearch .xpack .esql .plugin ;
99
10- import org .elasticsearch .Build ;
1110import org .elasticsearch .ElasticsearchException ;
1211import org .elasticsearch .action .index .IndexRequest ;
1312import org .elasticsearch .action .support .WriteRequest ;
1413import org .elasticsearch .common .settings .Settings ;
1514import org .elasticsearch .test .junit .annotations .TestLogging ;
1615import org .elasticsearch .xpack .esql .VerificationException ;
1716import org .elasticsearch .xpack .esql .action .AbstractEsqlIntegTestCase ;
18- import org .elasticsearch .xpack .esql .action .ColumnInfoImpl ;
17+ import org .elasticsearch .xpack .esql .action .EsqlCapabilities ;
1918import org .elasticsearch .xpack .esql .action .EsqlQueryRequest ;
2019import org .elasticsearch .xpack .esql .action .EsqlQueryResponse ;
21- import org .elasticsearch .xpack .esql .core .type .DataType ;
2220import org .junit .Before ;
2321
2422import java .util .List ;
2523
26- import static org .elasticsearch .test .ListMatcher .matchesList ;
27- import static org .elasticsearch .test .MapMatcher .assertMap ;
2824import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
29- import static org .elasticsearch .xpack .esql .EsqlTestUtils .getValuesList ;
3025import static org .hamcrest .CoreMatchers .containsString ;
31- import static org .hamcrest .Matchers .equalTo ;
3226
3327@ TestLogging (value = "org.elasticsearch.xpack.esql:TRACE,org.elasticsearch.compute:TRACE" , reason = "debug" )
3428public class MatchOperatorIT extends AbstractEsqlIntegTestCase {
@@ -40,7 +34,7 @@ public void setupIndex() {
4034
4135 @ Override
4236 protected EsqlQueryResponse run (EsqlQueryRequest request ) {
43- assumeTrue ("match operator available in snapshot builds only " , Build . current (). isSnapshot ());
37+ assumeTrue ("match operator capability not available " , EsqlCapabilities . Cap . MATCH_OPERATOR_COLON . isEnabled ());
4438 return super .run (request );
4539 }
4640
@@ -53,11 +47,9 @@ public void testSimpleWhereMatch() {
5347 """ ;
5448
5549 try (var resp = run (query )) {
56- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::name ).toList (), equalTo (List .of ("id" )));
57- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::type ).map (DataType ::toString ).toList (), equalTo (List .of ("INTEGER" )));
58- // values
59- List <List <Object >> values = getValuesList (resp );
60- assertMap (values , matchesList ().item (List .of (1 )).item (List .of (6 )));
50+ assertColumnNames (resp .columns (), List .of ("id" ));
51+ assertColumnTypes (resp .columns (), List .of ("integer" ));
52+ assertValues (resp .values (), List .of (List .of (1 ), List .of (6 )));
6153 }
6254 }
6355
@@ -70,11 +62,9 @@ public void testCombinedWhereMatch() {
7062 """ ;
7163
7264 try (var resp = run (query )) {
73- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::name ).toList (), equalTo (List .of (("id" ))));
74- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::type ).map (DataType ::toString ).toList (), equalTo (List .of (("INTEGER" ))));
75- // values
76- List <List <Object >> values = getValuesList (resp );
77- assertMap (values , matchesList ().item (List .of (6 )));
65+ assertColumnNames (resp .columns (), List .of ("id" ));
66+ assertColumnTypes (resp .columns (), List .of ("integer" ));
67+ assertValues (resp .values (), List .of (List .of (6 )));
7868 }
7969 }
8070
@@ -87,12 +77,9 @@ public void testMultipleMatch() {
8777 """ ;
8878
8979 try (var resp = run (query )) {
90- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::name ).toList (), equalTo (List .of (("id" ))));
91- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::type ).map (DataType ::toString ).toList (), equalTo (List .of (("INTEGER" ))));
92- // values
93- List <List <Object >> values = getValuesList (resp );
94- assertThat (values .size (), equalTo (2 ));
95- assertMap (values , matchesList ().item (List .of (1 )).item (List .of (6 )));
80+ assertColumnNames (resp .columns (), List .of ("id" ));
81+ assertColumnTypes (resp .columns (), List .of ("integer" ));
82+ assertValues (resp .values (), List .of (List .of (1 ), List .of (6 )));
9683 }
9784 }
9885
@@ -121,11 +108,9 @@ public void testNotWhereMatch() {
121108 """ ;
122109
123110 try (var resp = run (query )) {
124- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::name ).toList (), equalTo (List .of (("id" ))));
125- assertThat (resp .columns ().stream ().map (ColumnInfoImpl ::type ).map (DataType ::toString ).toList (), equalTo (List .of (("INTEGER" ))));
126- // values
127- List <List <Object >> values = getValuesList (resp );
128- assertMap (values , matchesList ().item (List .of (5 )));
111+ assertColumnNames (resp .columns (), List .of ("id" ));
112+ assertColumnTypes (resp .columns (), List .of ("integer" ));
113+ assertValues (resp .values (), List .of (List .of (5 )));
129114 }
130115 }
131116
0 commit comments