Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/reference/esql/functions/description/reverse.asciidoc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/reference/esql/functions/kibana/docs/reverse.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,7 @@ off_on_holiday:keyword | back_home_again:keyword

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

message:keyword | message_reversed:keyword
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public enum Cap {
*/
FN_REVERSE,

/**
* Support for reversing whole grapheme clusters. This is not supported
* on JDK versions less than 20.
*/
FN_REVERSE_GRAPHEME_CLUSTERS(Runtime.version().feature() < 20),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


/**
* Support for function {@code CBRT}. Done in #108574.
*/
Expand Down Expand Up @@ -133,7 +139,7 @@ public enum Cap {
* - fixed variable shadowing
* - fixed Join.references(), requiring breaking change to Join serialization
*/
LOOKUP_V4(true),
LOOKUP_V4(Build.current().isSnapshot()),

/**
* Support for requesting the "REPEAT" command.
Expand Down Expand Up @@ -279,7 +285,7 @@ public enum Cap {
/**
* Support for match operator
*/
MATCH_OPERATOR(true),
MATCH_OPERATOR(Build.current().isSnapshot()),

/**
* Removing support for the {@code META} keyword.
Expand Down Expand Up @@ -349,7 +355,7 @@ public enum Cap {
/**
* Supported the text categorization function "CATEGORIZE".
*/
CATEGORIZE(true),
CATEGORIZE(Build.current().isSnapshot()),

/**
* QSTR function
Expand All @@ -375,7 +381,7 @@ public enum Cap {
/**
* Support named parameters for field names.
*/
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES(true),
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES(Build.current().isSnapshot()),

/**
* Fix sorting not allowed on _source and counters.
Expand All @@ -397,45 +403,40 @@ public enum Cap {
*/
FUNCTION_STATS;

private final boolean snapshotOnly;
private final FeatureFlag featureFlag;
private final boolean enabled;

Cap() {
this(false, null);
this.enabled = true;
};

Cap(boolean snapshotOnly) {
this(snapshotOnly, null);
Cap(boolean enabled) {
this.enabled = enabled;
};

Cap(FeatureFlag featureFlag) {
this(false, featureFlag);
}

Cap(boolean snapshotOnly, FeatureFlag featureFlag) {
assert featureFlag == null || snapshotOnly == false;
this.snapshotOnly = snapshotOnly;
this.featureFlag = featureFlag;
this.enabled = featureFlag.isEnabled();
}

public boolean isEnabled() {
if (featureFlag == null) {
return Build.current().isSnapshot() || this.snapshotOnly == false;
}
return featureFlag.isEnabled();
return enabled;
}

public String capabilityName() {
return name().toLowerCase(Locale.ROOT);
}
}

public static final Set<String> CAPABILITIES = capabilities();
public static final Set<String> CAPABILITIES = capabilities(false);

private static Set<String> capabilities() {
/**
* Get a {@link Set} of all capabilities. If the {@code all} parameter is {@code false}
* then only <strong>enabled</strong> capabilities are returned - otherwise <strong>all</strong>
* known capabilities are returned.
*/
public static Set<String> capabilities(boolean all) {
List<String> caps = new ArrayList<>();
for (Cap cap : Cap.values()) {
if (cap.isEnabled()) {
if (all || cap.isEnabled()) {
caps.add(cap.capabilityName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public class Reverse extends UnaryScalarFunction {
file = "string",
tag = "reverseEmoji",
description = "`REVERSE` works with unicode, too! It keeps unicode grapheme clusters together during reversal."
) }
) },
note = """
If Elasticsearch is running with a JDK version less than 20 then this will not properly reverse Grapheme Clusters.
Elastic Cloud the JDK bundled with Elasticsearch all use newer JDKs. But if you've explicitly shifted to an older jdk
then you'll see things like "👍🏽😊" be reversed to "🏽👍😊" instead of the correct "😊👍🏽"."""
)
public Reverse(
Source source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public final void test() throws Throwable {
assertThat(
"Capability is not included in the enabled list capabilities on a snapshot build. Spelling mistake?",
testCase.requiredCapabilities,
everyItem(in(EsqlCapabilities.CAPABILITIES))
everyItem(in(EsqlCapabilities.capabilities(true)))
);
} else {
for (EsqlCapabilities.Cap c : EsqlCapabilities.Cap.values()) {
Expand Down
Loading