Skip to content

Commit b8334bb

Browse files
authored
Swap ESQL features for capabilities (#120050)
Remove assumed features in ESQL added before 8.18, define replacement capabilities instead
1 parent ca4ea21 commit b8334bb

File tree

8 files changed

+113
-173
lines changed

8 files changed

+113
-173
lines changed

x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.elasticsearch.xpack.esql.qa.mixed;
99

1010
import org.elasticsearch.Version;
11-
import org.elasticsearch.features.NodeFeature;
1211
import org.elasticsearch.test.cluster.ElasticsearchCluster;
1312
import org.elasticsearch.test.rest.TestFeatureService;
1413
import org.elasticsearch.xpack.esql.CsvSpecReader.CsvTestCase;
@@ -22,7 +21,6 @@
2221

2322
import static org.elasticsearch.xpack.esql.CsvTestUtils.isEnabled;
2423
import static org.elasticsearch.xpack.esql.action.EsqlCapabilities.Cap.JOIN_LOOKUP_V10;
25-
import static org.elasticsearch.xpack.esql.qa.rest.EsqlSpecTestCase.Mode.ASYNC;
2624

2725
public class MixedClusterEsqlSpecIT extends EsqlSpecTestCase {
2826
@ClassRule
@@ -49,10 +47,6 @@ protected static boolean oldClusterHasFeature(String featureId) {
4947
return oldClusterTestFeatureService.clusterHasFeature(featureId);
5048
}
5149

52-
protected static boolean oldClusterHasFeature(NodeFeature feature) {
53-
return oldClusterHasFeature(feature.id());
54-
}
55-
5650
@AfterClass
5751
public static void cleanUp() {
5852
oldClusterTestFeatureService = null;
@@ -74,14 +68,6 @@ public MixedClusterEsqlSpecIT(
7468
protected void shouldSkipTest(String testName) throws IOException {
7569
super.shouldSkipTest(testName);
7670
assumeTrue("Test " + testName + " is skipped on " + bwcVersion, isEnabled(testName, instructions, bwcVersion));
77-
if (mode == ASYNC) {
78-
assumeTrue("Async is not supported on " + bwcVersion, supportsAsync());
79-
}
80-
}
81-
82-
@Override
83-
protected boolean supportsAsync() {
84-
return oldClusterHasFeature(ASYNC_QUERY_FEATURE_ID);
8571
}
8672

8773
@Override

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@
7575
@TimeoutSuite(millis = 30 * TimeUnits.MINUTE)
7676
public abstract class EsqlSpecTestCase extends ESRestTestCase {
7777

78-
// To avoid referencing the main module, we replicate EsqlFeatures.ASYNC_QUERY.id() here
79-
protected static final String ASYNC_QUERY_FEATURE_ID = "esql.async_query";
80-
8178
private static final Logger LOGGER = LogManager.getLogger(EsqlSpecTestCase.class);
8279
private final String fileName;
8380
private final String groupName;
@@ -140,10 +137,6 @@ public void setup() throws IOException {
140137
}
141138
}
142139

143-
protected boolean supportsAsync() {
144-
return clusterHasFeature(ASYNC_QUERY_FEATURE_ID); // the Async API was introduced in 8.13.0
145-
}
146-
147140
@AfterClass
148141
public static void wipeTestData() throws IOException {
149142
try {
@@ -281,7 +274,6 @@ protected boolean deduplicateExactWarnings() {
281274

282275
private Map<String, Object> runEsql(RequestObjectBuilder requestObject, AssertWarnings assertWarnings) throws IOException {
283276
if (mode == Mode.ASYNC) {
284-
assert supportsAsync();
285277
return RestEsqlTestCase.runEsqlAsync(requestObject, assertWarnings);
286278
} else {
287279
return RestEsqlTestCase.runEsqlSync(requestObject, assertWarnings);

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

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,113 @@
2727
*/
2828
public class EsqlCapabilities {
2929
public enum Cap {
30+
/**
31+
* Introduction of {@code MV_SORT}, {@code MV_SLICE}, and {@code MV_ZIP}.
32+
* Added in #106095.
33+
*/
34+
MV_SORT,
35+
36+
/**
37+
* When we disabled some broken optimizations around {@code nullable}.
38+
* Fixed in #105691.
39+
*/
40+
DISABLE_NULLABLE_OPTS,
41+
42+
/**
43+
* Introduction of {@code ST_X} and {@code ST_Y}. Added in #105768.
44+
*/
45+
ST_X_Y,
46+
47+
/**
48+
* Changed precision of {@code geo_point} and {@code cartesian_point} fields, by loading from source into WKB. Done in #103691.
49+
*/
50+
SPATIAL_POINTS_FROM_SOURCE,
51+
52+
/**
53+
* Support for loading {@code geo_shape} and {@code cartesian_shape} fields. Done in #104269.
54+
*/
55+
SPATIAL_SHAPES,
56+
57+
/**
58+
* Support for spatial aggregation {@code ST_CENTROID}. Done in #104269.
59+
*/
60+
ST_CENTROID_AGG,
61+
62+
/**
63+
* Support for spatial aggregation {@code ST_INTERSECTS}. Done in #104907.
64+
*/
65+
ST_INTERSECTS,
66+
67+
/**
68+
* Support for spatial aggregation {@code ST_CONTAINS} and {@code ST_WITHIN}. Done in #106503.
69+
*/
70+
ST_CONTAINS_WITHIN,
71+
72+
/**
73+
* Support for spatial aggregation {@code ST_DISJOINT}. Done in #107007.
74+
*/
75+
ST_DISJOINT,
76+
77+
/**
78+
* The introduction of the {@code VALUES} agg.
79+
*/
80+
AGG_VALUES,
81+
82+
/**
83+
* Does ESQL support async queries.
84+
*/
85+
ASYNC_QUERY,
86+
87+
/**
88+
* Does ESQL support FROM OPTIONS?
89+
*/
90+
@Deprecated
91+
FROM_OPTIONS,
92+
93+
/**
94+
* Cast string literals to a desired data type.
95+
*/
96+
STRING_LITERAL_AUTO_CASTING,
97+
98+
/**
99+
* Base64 encoding and decoding functions.
100+
*/
101+
BASE64_DECODE_ENCODE,
102+
103+
/**
104+
* Support for the :: casting operator
105+
*/
106+
CASTING_OPERATOR,
107+
108+
/**
109+
* Blocks can be labelled with {@link org.elasticsearch.compute.data.Block.MvOrdering#SORTED_ASCENDING} for optimizations.
110+
*/
111+
MV_ORDERING_SORTED_ASCENDING,
112+
113+
/**
114+
* Support for metrics counter fields
115+
*/
116+
METRICS_COUNTER_FIELDS,
117+
118+
/**
119+
* Cast string literals to a desired data type for IN predicate and more types for BinaryComparison.
120+
*/
121+
STRING_LITERAL_AUTO_CASTING_EXTENDED,
122+
123+
/**
124+
* Support for metadata fields.
125+
*/
126+
METADATA_FIELDS,
127+
128+
/**
129+
* Support for timespan units abbreviations
130+
*/
131+
TIMESPAN_ABBREVIATIONS,
132+
133+
/**
134+
* Support metrics counter types
135+
*/
136+
COUNTER_TYPES,
30137

31138
/**
32139
* Support for function {@code BIT_LENGTH}. Done in #115792

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

Lines changed: 2 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -24,163 +24,24 @@
2424
* examples below are *just* used for that. Don't make more of those - add them
2525
* to {@link EsqlCapabilities} instead.
2626
* <p>
27-
* NOTE: You can't remove a feature now and probably never will be able to.
27+
* NOTE: You can only remove features on major version boundaries.
2828
* Only add more of these if you need a fast CPU level check.
2929
* </p>
3030
*/
3131
public class EsqlFeatures implements FeatureSpecification {
32-
/**
33-
* Introduction of {@code MV_SORT}, {@code MV_SLICE}, and {@code MV_ZIP}.
34-
* Added in #106095.
35-
*/
36-
private static final NodeFeature MV_SORT = new NodeFeature("esql.mv_sort", true);
37-
38-
/**
39-
* When we disabled some broken optimizations around {@code nullable}.
40-
* Fixed in #105691.
41-
*/
42-
private static final NodeFeature DISABLE_NULLABLE_OPTS = new NodeFeature("esql.disable_nullable_opts", true);
43-
44-
/**
45-
* Introduction of {@code ST_X} and {@code ST_Y}. Added in #105768.
46-
*/
47-
private static final NodeFeature ST_X_Y = new NodeFeature("esql.st_x_y", true);
48-
49-
/**
50-
* Changed precision of {@code geo_point} and {@code cartesian_point} fields, by loading from source into WKB. Done in #103691.
51-
*/
52-
private static final NodeFeature SPATIAL_POINTS_FROM_SOURCE = new NodeFeature("esql.spatial_points_from_source", true);
53-
54-
/**
55-
* Support for loading {@code geo_shape} and {@code cartesian_shape} fields. Done in #104269.
56-
*/
57-
private static final NodeFeature SPATIAL_SHAPES = new NodeFeature("esql.spatial_shapes", true);
58-
59-
/**
60-
* Support for spatial aggregation {@code ST_CENTROID}. Done in #104269.
61-
*/
62-
private static final NodeFeature ST_CENTROID_AGG = new NodeFeature("esql.st_centroid_agg", true);
63-
64-
/**
65-
* Support for spatial aggregation {@code ST_INTERSECTS}. Done in #104907.
66-
*/
67-
private static final NodeFeature ST_INTERSECTS = new NodeFeature("esql.st_intersects", true);
68-
69-
/**
70-
* Support for spatial aggregation {@code ST_CONTAINS} and {@code ST_WITHIN}. Done in #106503.
71-
*/
72-
private static final NodeFeature ST_CONTAINS_WITHIN = new NodeFeature("esql.st_contains_within", true);
73-
74-
/**
75-
* Support for spatial aggregation {@code ST_DISJOINT}. Done in #107007.
76-
*/
77-
private static final NodeFeature ST_DISJOINT = new NodeFeature("esql.st_disjoint", true);
78-
79-
/**
80-
* The introduction of the {@code VALUES} agg.
81-
*/
82-
private static final NodeFeature AGG_VALUES = new NodeFeature("esql.agg_values", true);
83-
84-
/**
85-
* Does ESQL support async queries.
86-
*/
87-
public static final NodeFeature ASYNC_QUERY = new NodeFeature("esql.async_query", true);
88-
89-
/**
90-
* Does ESQL support FROM OPTIONS?
91-
*/
92-
@Deprecated
93-
public static final NodeFeature FROM_OPTIONS = new NodeFeature("esql.from_options", true);
94-
95-
/**
96-
* Cast string literals to a desired data type.
97-
*/
98-
public static final NodeFeature STRING_LITERAL_AUTO_CASTING = new NodeFeature("esql.string_literal_auto_casting", true);
99-
100-
/**
101-
* Base64 encoding and decoding functions.
102-
*/
103-
public static final NodeFeature BASE64_DECODE_ENCODE = new NodeFeature("esql.base64_decode_encode", true);
104-
105-
/**
106-
* Support for the :: casting operator
107-
*/
108-
public static final NodeFeature CASTING_OPERATOR = new NodeFeature("esql.casting_operator", true);
109-
110-
/**
111-
* Blocks can be labelled with {@link org.elasticsearch.compute.data.Block.MvOrdering#SORTED_ASCENDING} for optimizations.
112-
*/
113-
public static final NodeFeature MV_ORDERING_SORTED_ASCENDING = new NodeFeature("esql.mv_ordering_sorted_ascending", true);
114-
115-
/**
116-
* Support for metrics counter fields
117-
*/
118-
public static final NodeFeature METRICS_COUNTER_FIELDS = new NodeFeature("esql.metrics_counter_fields", true);
119-
120-
/**
121-
* Cast string literals to a desired data type for IN predicate and more types for BinaryComparison.
122-
*/
123-
public static final NodeFeature STRING_LITERAL_AUTO_CASTING_EXTENDED = new NodeFeature(
124-
"esql.string_literal_auto_casting_extended",
125-
true
126-
);
127-
128-
/**
129-
* Support for metadata fields.
130-
*/
131-
public static final NodeFeature METADATA_FIELDS = new NodeFeature("esql.metadata_fields", true);
132-
133-
/**
134-
* Support for timespan units abbreviations
135-
*/
136-
public static final NodeFeature TIMESPAN_ABBREVIATIONS = new NodeFeature("esql.timespan_abbreviations", true);
137-
138-
/**
139-
* Support metrics counter types
140-
*/
141-
public static final NodeFeature COUNTER_TYPES = new NodeFeature("esql.counter_types", true);
142-
14332
/**
14433
* Support metrics syntax
14534
*/
14635
public static final NodeFeature METRICS_SYNTAX = new NodeFeature("esql.metrics_syntax");
14736

148-
/**
149-
* Internal resolve_fields API for ES|QL
150-
*/
151-
public static final NodeFeature RESOLVE_FIELDS_API = new NodeFeature("esql.resolve_fields_api", true);
152-
15337
private Set<NodeFeature> snapshotBuildFeatures() {
15438
assert Build.current().isSnapshot() : Build.current();
15539
return Set.of(METRICS_SYNTAX);
15640
}
15741

15842
@Override
15943
public Set<NodeFeature> getFeatures() {
160-
Set<NodeFeature> features = Set.of(
161-
ASYNC_QUERY,
162-
AGG_VALUES,
163-
BASE64_DECODE_ENCODE,
164-
MV_SORT,
165-
DISABLE_NULLABLE_OPTS,
166-
ST_X_Y,
167-
FROM_OPTIONS,
168-
SPATIAL_POINTS_FROM_SOURCE,
169-
SPATIAL_SHAPES,
170-
ST_CENTROID_AGG,
171-
ST_INTERSECTS,
172-
ST_CONTAINS_WITHIN,
173-
ST_DISJOINT,
174-
STRING_LITERAL_AUTO_CASTING,
175-
CASTING_OPERATOR,
176-
MV_ORDERING_SORTED_ASCENDING,
177-
METRICS_COUNTER_FIELDS,
178-
STRING_LITERAL_AUTO_CASTING_EXTENDED,
179-
METADATA_FIELDS,
180-
TIMESPAN_ABBREVIATIONS,
181-
COUNTER_TYPES,
182-
RESOLVE_FIELDS_API
183-
);
44+
Set<NodeFeature> features = Set.of();
18445
if (Build.current().isSnapshot()) {
18546
return Collections.unmodifiableSet(Sets.union(features, snapshotBuildFeatures()));
18647
} else {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,10 @@ public final void test() throws Throwable {
241241
* The csv tests support all but a few features. The unsupported features
242242
* are tested in integration tests.
243243
*/
244-
assumeFalse("metadata fields aren't supported", testCase.requiredCapabilities.contains(cap(EsqlFeatures.METADATA_FIELDS)));
244+
assumeFalse(
245+
"metadata fields aren't supported",
246+
testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.METADATA_FIELDS.capabilityName())
247+
);
245248
assumeFalse(
246249
"enrich can't load fields in csv tests",
247250
testCase.requiredCapabilities.contains(EsqlCapabilities.Cap.ENRICH_LOAD.capabilityName())

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/100_bug_fix.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,6 @@
257257

258258
---
259259
"mv_dedupe from index #104745":
260-
- requires:
261-
cluster_features: ["esql.mv_ordering_sorted_ascending"]
262-
reason: "fixed by introducing a sorted, non-deduplicated MvOrdering"
263260
- do:
264261
indices.create:
265262
index: idx_with_multivalues

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/40_tsdb.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
setup:
22
- requires:
3-
cluster_features: ["esql.metrics_counter_fields"]
4-
reason: "require metrics counter fields"
53
test_runner_features: allowed_warnings_regex
64
- do:
75
indices.create:

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/80_text.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,6 @@ setup:
574574

575575
---
576576
"values function":
577-
- requires:
578-
cluster_features: esql.agg_values
579-
reason: "values is available in 8.14+"
580-
581577
- do:
582578
esql.query:
583579
body:

0 commit comments

Comments
 (0)