Skip to content

Commit ac7db5d

Browse files
authored
ESQL: Skip unsupported grapheme cluster test (#115258) (#115321)
This skips the test for reversing grapheme clusters if the node doesn't support reversing grapheme clusters. Nodes that are using a jdk before 20 won't support reversing grapheme clusters because they don't have https://bugs.openjdk.org/browse/JDK-8292387 This reworks `EsqlCapabilities` so we can easilly register it only if we're on jdk 20: ``` FN_REVERSE_GRAPHEME_CLUSTERS(Runtime.version().feature() < 20), ``` Closes #114537 Closes #114535 Closes #114536 Closes #114558 Closes #114559 Closes #114560
1 parent 6855db5 commit ac7db5d

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ off_on_holiday:keyword | back_home_again:keyword
12361236

12371237
reverseGraphemeClusters
12381238
required_capability: fn_reverse
1239+
required_capability: fn_reverse_grapheme_clusters
12391240
ROW message = "áéíóúàèìòùâêîôû😊👍🏽🎉💖कंठाी" | EVAL message_reversed = REVERSE(message);
12401241

12411242
message:keyword | message_reversed:keyword

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

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ public enum Cap {
3232
*/
3333
FN_REVERSE,
3434

35+
/**
36+
* Support for reversing whole grapheme clusters. This is not supported
37+
* on JDK versions less than 20 which are not supported in ES 9.0.0+ but this
38+
* exists to keep the {@code 8.x} branch similar to the {@code main} branch.
39+
*/
40+
FN_REVERSE_GRAPHEME_CLUSTERS,
41+
3542
/**
3643
* Support for function {@code CBRT}. Done in #108574.
3744
*/
@@ -133,7 +140,7 @@ public enum Cap {
133140
* - fixed variable shadowing
134141
* - fixed Join.references(), requiring breaking change to Join serialization
135142
*/
136-
LOOKUP_V4(true),
143+
LOOKUP_V4(Build.current().isSnapshot()),
137144

138145
/**
139146
* Support for requesting the "REPEAT" command.
@@ -279,7 +286,7 @@ public enum Cap {
279286
/**
280287
* Support for match operator
281288
*/
282-
MATCH_OPERATOR(true),
289+
MATCH_OPERATOR(Build.current().isSnapshot()),
283290

284291
/**
285292
* Removing support for the {@code META} keyword.
@@ -349,7 +356,7 @@ public enum Cap {
349356
/**
350357
* Supported the text categorization function "CATEGORIZE".
351358
*/
352-
CATEGORIZE(true),
359+
CATEGORIZE(Build.current().isSnapshot()),
353360

354361
/**
355362
* QSTR function
@@ -375,7 +382,7 @@ public enum Cap {
375382
/**
376383
* Support named parameters for field names.
377384
*/
378-
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES(true),
385+
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES(Build.current().isSnapshot()),
379386

380387
/**
381388
* Fix sorting not allowed on _source and counters.
@@ -401,45 +408,40 @@ public enum Cap {
401408
*/
402409
SEMANTIC_TEXT_TYPE(EsqlCorePlugin.SEMANTIC_TEXT_FEATURE_FLAG);
403410

404-
private final boolean snapshotOnly;
405-
private final FeatureFlag featureFlag;
411+
private final boolean enabled;
406412

407413
Cap() {
408-
this(false, null);
414+
this.enabled = true;
409415
};
410416

411-
Cap(boolean snapshotOnly) {
412-
this(snapshotOnly, null);
417+
Cap(boolean enabled) {
418+
this.enabled = enabled;
413419
};
414420

415421
Cap(FeatureFlag featureFlag) {
416-
this(false, featureFlag);
417-
}
418-
419-
Cap(boolean snapshotOnly, FeatureFlag featureFlag) {
420-
assert featureFlag == null || snapshotOnly == false;
421-
this.snapshotOnly = snapshotOnly;
422-
this.featureFlag = featureFlag;
422+
this.enabled = featureFlag.isEnabled();
423423
}
424424

425425
public boolean isEnabled() {
426-
if (featureFlag == null) {
427-
return Build.current().isSnapshot() || this.snapshotOnly == false;
428-
}
429-
return featureFlag.isEnabled();
426+
return enabled;
430427
}
431428

432429
public String capabilityName() {
433430
return name().toLowerCase(Locale.ROOT);
434431
}
435432
}
436433

437-
public static final Set<String> CAPABILITIES = capabilities();
434+
public static final Set<String> CAPABILITIES = capabilities(false);
438435

439-
private static Set<String> capabilities() {
436+
/**
437+
* Get a {@link Set} of all capabilities. If the {@code all} parameter is {@code false}
438+
* then only <strong>enabled</strong> capabilities are returned - otherwise <strong>all</strong>
439+
* known capabilities are returned.
440+
*/
441+
public static Set<String> capabilities(boolean all) {
440442
List<String> caps = new ArrayList<>();
441443
for (Cap cap : Cap.values()) {
442-
if (cap.isEnabled()) {
444+
if (all || cap.isEnabled()) {
443445
caps.add(cap.capabilityName());
444446
}
445447
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public final void test() throws Throwable {
257257
assertThat(
258258
"Capability is not included in the enabled list capabilities on a snapshot build. Spelling mistake?",
259259
testCase.requiredCapabilities,
260-
everyItem(in(EsqlCapabilities.CAPABILITIES))
260+
everyItem(in(EsqlCapabilities.capabilities(true)))
261261
);
262262
} else {
263263
for (EsqlCapabilities.Cap c : EsqlCapabilities.Cap.values()) {

0 commit comments

Comments
 (0)