Skip to content

Commit 4fca9fa

Browse files
authored
ESQL: Rename SupportedVersion methods (#137013) (#137044)
1 parent f718bb1 commit 4fca9fa

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/DataType.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
* Ensure the capabilities for this type are always enabled.</li>
122122
* <li>
123123
* Mark the type with a new transport version via
124-
* {@link Builder#supportedOn(TransportVersion)}. This will enable the type on
124+
* {@link Builder#supportedSince(TransportVersion)}. This will enable the type on
125125
* non-SNAPSHOT builds as long as all nodes in the cluster (and remote clusters)
126126
* support it.</li>
127127
* <li>
@@ -296,9 +296,13 @@ public enum DataType implements Writeable {
296296
// NOTE: If INDEX_SOURCE somehow gets backported to a version that doesn't actually support these types, we'll be missing validation for
297297
// mixed/multi clusters with remotes that don't support these types. This is low-ish risk because these types require specific
298298
// geo functions to turn up in the query, and those types aren't available before 9.2.0 either.
299-
GEOHASH(builder().esType("geohash").typeName("GEOHASH").estimatedSize(Long.BYTES).supportedOn(DataTypesTransportVersions.INDEX_SOURCE)),
300-
GEOTILE(builder().esType("geotile").typeName("GEOTILE").estimatedSize(Long.BYTES).supportedOn(DataTypesTransportVersions.INDEX_SOURCE)),
301-
GEOHEX(builder().esType("geohex").typeName("GEOHEX").estimatedSize(Long.BYTES).supportedOn(DataTypesTransportVersions.INDEX_SOURCE)),
299+
GEOHASH(
300+
builder().esType("geohash").typeName("GEOHASH").estimatedSize(Long.BYTES).supportedSince(DataTypesTransportVersions.INDEX_SOURCE)
301+
),
302+
GEOTILE(
303+
builder().esType("geotile").typeName("GEOTILE").estimatedSize(Long.BYTES).supportedSince(DataTypesTransportVersions.INDEX_SOURCE)
304+
),
305+
GEOHEX(builder().esType("geohex").typeName("GEOHEX").estimatedSize(Long.BYTES).supportedSince(DataTypesTransportVersions.INDEX_SOURCE)),
302306

303307
/**
304308
* Fields with this type represent a Lucene doc id. This field is a bit magic in that:
@@ -322,7 +326,7 @@ public enum DataType implements Writeable {
322326
// mixed/multi clusters with remotes that don't support these types. This is low-ish risk because _tsid requires specifically being
323327
// used in `FROM idx METADATA _tsid` or in the `TS` command, which both weren't available before 9.2.0.
324328
TSID_DATA_TYPE(
325-
builder().esType("_tsid").estimatedSize(Long.BYTES * 2).docValues().supportedOn(DataTypesTransportVersions.INDEX_SOURCE)
329+
builder().esType("_tsid").estimatedSize(Long.BYTES * 2).docValues().supportedSince(DataTypesTransportVersions.INDEX_SOURCE)
326330
),
327331
/**
328332
* Fields with this type are the partial result of running a non-time-series aggregation
@@ -333,13 +337,13 @@ public enum DataType implements Writeable {
333337
AGGREGATE_METRIC_DOUBLE(
334338
builder().esType("aggregate_metric_double")
335339
.estimatedSize(Double.BYTES * 3 + Integer.BYTES)
336-
.supportedOn(DataTypesTransportVersions.ESQL_AGGREGATE_METRIC_DOUBLE_CREATED_VERSION)
340+
.supportedSince(DataTypesTransportVersions.ESQL_AGGREGATE_METRIC_DOUBLE_CREATED_VERSION)
337341
),
338342
/**
339343
* Fields with this type are dense vectors, represented as an array of float values.
340344
*/
341345
DENSE_VECTOR(
342-
builder().esType("dense_vector").estimatedSize(4096).supportedOn(DataTypesTransportVersions.ESQL_DENSE_VECTOR_CREATED_VERSION)
346+
builder().esType("dense_vector").estimatedSize(4096).supportedSince(DataTypesTransportVersions.ESQL_DENSE_VECTOR_CREATED_VERSION)
343347
);
344348

345349
public static final Set<DataType> UNDER_CONSTRUCTION = Arrays.stream(DataType.values())
@@ -744,7 +748,7 @@ public DataType counter() {
744748

745749
@Override
746750
public void writeTo(StreamOutput out) throws IOException {
747-
if (supportedVersion.supports(out.getTransportVersion()) == false) {
751+
if (supportedVersion.supportedOn(out.getTransportVersion()) == false) {
748752
/*
749753
* TODO when we implement version aware planning flip this to an IllegalStateException
750754
* so we throw a 500 error. It'll be our bug then. Right now it's a sign that the user
@@ -955,8 +959,8 @@ Builder counter(DataType counter) {
955959
* <p>
956960
* Generally, we should add a dedicated transport version when a type is enabled on release builds.
957961
*/
958-
Builder supportedOn(TransportVersion supportedVersion) {
959-
this.supportedVersion = SupportedVersion.supportedOn(supportedVersion);
962+
Builder supportedSince(TransportVersion supportedVersion) {
963+
this.supportedVersion = SupportedVersion.supportedSince(supportedVersion);
960964
return this;
961965
}
962966

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/SupportedVersion.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
import org.elasticsearch.TransportVersion;
1212

1313
public interface SupportedVersion {
14-
boolean supports(TransportVersion version);
14+
boolean supportedOn(TransportVersion version);
1515

1616
default boolean supportedLocally() {
17-
return supports(TransportVersion.current());
17+
return supportedOn(TransportVersion.current());
1818
}
1919

2020
SupportedVersion SUPPORTED_ON_ALL_NODES = new SupportedVersion() {
2121
@Override
22-
public boolean supports(TransportVersion version) {
22+
public boolean supportedOn(TransportVersion version) {
2323
return true;
2424
}
2525

@@ -56,7 +56,7 @@ public String toString() {
5656
// Check usage of this constant to be sure.
5757
SupportedVersion UNDER_CONSTRUCTION = new SupportedVersion() {
5858
@Override
59-
public boolean supports(TransportVersion version) {
59+
public boolean supportedOn(TransportVersion version) {
6060
return Build.current().isSnapshot();
6161
}
6262

@@ -73,10 +73,10 @@ public String toString() {
7373
* continue to work. Otherwise, we'd have to update bwc tests to skip older versions based
7474
* on a capability check, which can be error-prone and risks turning off an unrelated bwc test.
7575
*/
76-
static SupportedVersion supportedOn(TransportVersion supportedVersion) {
76+
static SupportedVersion supportedSince(TransportVersion supportedVersion) {
7777
return new SupportedVersion() {
7878
@Override
79-
public boolean supports(TransportVersion version) {
79+
public boolean supportedOn(TransportVersion version) {
8080
return version.supports(supportedVersion) || Build.current().isSnapshot();
8181
}
8282

0 commit comments

Comments
 (0)