Skip to content

Commit 2f4bace

Browse files
Fix unit tests failing
1 parent faba3e0 commit 2f4bace

File tree

2 files changed

+46
-7
lines changed

2 files changed

+46
-7
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/QueryPlanningBenchmark.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ public class QueryPlanningBenchmark {
7070
private EsqlParser defaultParser;
7171
private Analyzer manyFieldsAnalyzer;
7272
private LogicalPlanOptimizer defaultOptimizer;
73+
private Configuration config;
7374

7475
@Setup
7576
public void setup() {
7677

77-
var config = new Configuration(
78+
this.config = new Configuration(
7879
DateUtils.UTC,
7980
Locale.US,
8081
null,
@@ -116,7 +117,7 @@ public void setup() {
116117
}
117118

118119
private LogicalPlan plan(EsqlParser parser, Analyzer analyzer, LogicalPlanOptimizer optimizer, String query) {
119-
var parsed = parser.createStatement(query, new QueryParams(), telemetry);
120+
var parsed = parser.createStatement(query, new QueryParams(), telemetry, config);
120121
var analyzed = analyzer.analyze(parsed);
121122
var optimized = optimizer.optimize(analyzed);
122123
return optimized;

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,7 @@ private <C, V> void assertResultMapForLike(
176176
requiredCapabilities.add("like_list_on_index_fields");
177177
}
178178
// the feature is completely supported if both local and remote clusters support it
179-
boolean isSupported = clusterHasCapability("POST", "/_query", List.of(), requiredCapabilities).orElse(false);
180-
try (RestClient remoteClient = remoteClusterClient()) {
181-
isSupported = isSupported
182-
&& clusterHasCapability(remoteClient, "POST", "/_query", List.of(), requiredCapabilities).orElse(false);
183-
}
179+
boolean isSupported = capabilitiesSupportedNewAndOld(requiredCapabilities);
184180

185181
if (isSupported) {
186182
assertResultMap(includeCCSMetadata, result, columns, values, remoteOnly);
@@ -193,6 +189,15 @@ private <C, V> void assertResultMapForLike(
193189
}
194190
}
195191

192+
private boolean capabilitiesSupportedNewAndOld(List<String> requiredCapabilities) throws IOException {
193+
boolean isSupported = clusterHasCapability("POST", "/_query", List.of(), requiredCapabilities).orElse(false);
194+
try (RestClient remoteClient = remoteClusterClient()) {
195+
isSupported = isSupported
196+
&& clusterHasCapability(remoteClient, "POST", "/_query", List.of(), requiredCapabilities).orElse(false);
197+
}
198+
return isSupported;
199+
}
200+
196201
private <C, V> void assertResultMap(boolean includeCCSMetadata, Map<String, Object> result, C columns, V values, boolean remoteOnly) {
197202
MapMatcher mapMatcher = getResultMatcher(
198203
ccsMetadataAvailable(),
@@ -438,6 +443,12 @@ public void testNotLikeIndex() throws Exception {
438443
}
439444

440445
public void testLikeListIndex() throws Exception {
446+
List<String> requiredCapabilities = new ArrayList<>(List.of("like_list_on_index_fields"));
447+
// the feature is completely supported if both local and remote clusters support it
448+
if (capabilitiesSupportedNewAndOld(requiredCapabilities) == false) {
449+
logger.info("--> skipping testNotLikeListIndex, due to missing capability");
450+
return;
451+
}
441452
boolean includeCCSMetadata = includeCCSMetadata();
442453
Map<String, Object> result = run("""
443454
FROM test-local-index,*:test-remote-index METADATA _index
@@ -453,6 +464,12 @@ public void testLikeListIndex() throws Exception {
453464
}
454465

455466
public void testNotLikeListIndex() throws Exception {
467+
List<String> requiredCapabilities = new ArrayList<>(List.of("like_list_on_index_fields"));
468+
// the feature is completely supported if both local and remote clusters support it
469+
if (capabilitiesSupportedNewAndOld(requiredCapabilities) == false) {
470+
logger.info("--> skipping testNotLikeListIndex, due to missing capability");
471+
return;
472+
}
456473
boolean includeCCSMetadata = includeCCSMetadata();
457474
Map<String, Object> result = run("""
458475
FROM test-local-index,*:test-remote-index METADATA _index
@@ -467,6 +484,27 @@ public void testNotLikeListIndex() throws Exception {
467484
assertResultMapForLike(includeCCSMetadata, result, columns, values, false, true);
468485
}
469486

487+
public void testNotLikeListKeyWord() throws Exception {
488+
List<String> requiredCapabilities = new ArrayList<>(List.of("like_list_on_index_fields"));
489+
// the feature is completely supported if both local and remote clusters support it
490+
if (capabilitiesSupportedNewAndOld(requiredCapabilities) == false) {
491+
logger.info("--> skipping testNotLikeListIndex, due to missing capability");
492+
return;
493+
}
494+
boolean includeCCSMetadata = includeCCSMetadata();
495+
Map<String, Object> result = run("""
496+
FROM test-local-index,*:test-remote-index METADATA _index
497+
| WHERE color NOT LIKE ("*blue*", "*red*")
498+
| STATS c = COUNT(*) BY _index
499+
| SORT _index ASC
500+
""", includeCCSMetadata);
501+
var columns = List.of(Map.of("name", "c", "type", "long"), Map.of("name", "_index", "type", "keyword"));
502+
var values = List.of(List.of(localDocs.size(), localIndex));
503+
String resultString = Strings.toString(JsonXContent.contentBuilder().prettyPrint().map(result));
504+
System.out.println(resultString);
505+
assertResultMapForLike(includeCCSMetadata, result, columns, values, false, true);
506+
}
507+
470508
public void testRLikeIndex() throws Exception {
471509
boolean includeCCSMetadata = includeCCSMetadata();
472510
Map<String, Object> result = run("""

0 commit comments

Comments
 (0)