diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/DataType.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/DataType.java index f2d0be0af6554..8de4c33e0813d 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/DataType.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/type/DataType.java @@ -47,6 +47,10 @@ * {@link DataType#OBJECT}) * *

Process for adding a new data type

+ * We assume that the data type is already supported in ES indices, but not in + * ES|QL. Types that aren't yet enabled in ES will require some adjustments to + * the process. + *

* Note: it is not expected that all the following steps be done in a single PR. * Use capabilities to gate tests as you go, and use as many PRs as you think * appropriate. New data types are complex, and smaller PRs will make reviews @@ -54,13 +58,14 @@ *

- * There are some additional steps that should be taken when removing the - * feature flag and getting ready for a release: + * There are some additional steps that should be taken when getting ready for a release: * *

- * Snapshot builds treat these as always supported so that we can write tests before actually - * turning on the support for the type. Mixed/multi cluster tests with older nodes have to be - * skipped based on capabilites, as always. + * Snapshot builds treat these as supported starting from the version they were created on, + * so that we can write tests before actually turning on the support for the type. + * Mixed/multi cluster tests with older nodes should be skipped based on SNAPSHOT-only + * capabilites, as always. */ // We used to have a feature-flag based override, so that in-development types could be // turned on for testing in release builds. If needed, it's fine to bring this back, but we // need to make sure that other checks for types being under construction are also overridden. - // Check usage of this constant to be sure. - SupportedVersion UNDER_CONSTRUCTION = new SupportedVersion() { - @Override - public boolean supportedOn(TransportVersion version, boolean currentBuildIsSnapshot) { - return currentBuildIsSnapshot; - } + // Check usage of this method to be sure. + static SupportedVersion underConstruction(TransportVersion createdVersion) { + return new SupportedVersion() { + @Override + public boolean supportedOn(TransportVersion version, boolean currentBuildIsSnapshot) { + return currentBuildIsSnapshot && version.supports(createdVersion); + } - @Override - public String toString() { - return "UnderConstruction"; - } - }; + @Override + public String toString() { + return "UnderConstruction"; + } + + @Override + public boolean underConstruction() { + return true; + } + }; + } /** * Types that are supported starting with the given version. *

- * Snapshot builds treat these as always supported, so that any existing tests using them - * continue to work. Otherwise, we'd have to update bwc tests to skip older versions based - * on a capability check, which can be error-prone and risks turning off an unrelated bwc test. + * Snapshot builds treat these as supported from their created version onward, so that any existing tests + * using them should continue to work. */ - static SupportedVersion supportedSince(TransportVersion supportedVersion) { + static SupportedVersion supportedSince(TransportVersion createdVersion, TransportVersion supportedVersion) { + assert supportedVersion.onOrAfter(createdVersion) : "support for a type cannot be enabled before its initial creation"; return new SupportedVersion() { @Override public boolean supportedOn(TransportVersion version, boolean currentBuildIsSnapshot) { - return version.supports(supportedVersion) || currentBuildIsSnapshot; + return currentBuildIsSnapshot ? version.supports(createdVersion) : version.supports(supportedVersion); } @Override