diff --git a/server/src/main/java/org/elasticsearch/TransportVersions.java b/server/src/main/java/org/elasticsearch/TransportVersions.java index 3c256823f9e5a..1abb8177e5d74 100644 --- a/server/src/main/java/org/elasticsearch/TransportVersions.java +++ b/server/src/main/java/org/elasticsearch/TransportVersions.java @@ -353,8 +353,6 @@ static TransportVersion def(int id) { public static final TransportVersion ML_INFERENCE_LLAMA_ADDED = def(9_125_0_00); public static final TransportVersion SHARD_WRITE_LOAD_IN_CLUSTER_INFO = def(9_126_0_00); public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS = def(9_127_0_00); - public static final TransportVersion ALLOCATION_DECISION_NOT_PREFERRED = def(9_145_0_00); - public static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = def(9_146_0_00); public static final TransportVersion PROJECT_RESERVED_STATE_MOVE_TO_REGISTRY = def(9_147_0_00); /* diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java index 441909e08a73c..40c9f8c5b4c85 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/Decision.java @@ -9,7 +9,7 @@ package org.elasticsearch.cluster.routing.allocation.decider; -import org.elasticsearch.TransportVersions; +import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; @@ -115,8 +115,12 @@ enum Type implements Writeable { NOT_PREFERRED, YES; + private static final TransportVersion ALLOCATION_DECISION_NOT_PREFERRED = TransportVersion.fromName( + "allocation_decision_not_preferred" + ); + public static Type readFrom(StreamInput in) throws IOException { - if (in.getTransportVersion().onOrAfter(TransportVersions.ALLOCATION_DECISION_NOT_PREFERRED)) { + if (in.getTransportVersion().supports(ALLOCATION_DECISION_NOT_PREFERRED)) { return in.readEnum(Type.class); } else { int i = in.readVInt(); @@ -138,7 +142,7 @@ public static Type min(Type a, Type b) { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getTransportVersion().onOrAfter(TransportVersions.ALLOCATION_DECISION_NOT_PREFERRED)) { + if (out.getTransportVersion().supports(ALLOCATION_DECISION_NOT_PREFERRED)) { out.writeEnum(this); } else { out.writeVInt(switch (this) { diff --git a/server/src/main/resources/transport/definitions/referable/allocation_decision_not_preferred.csv b/server/src/main/resources/transport/definitions/referable/allocation_decision_not_preferred.csv new file mode 100644 index 0000000000000..80b815cdb9d47 --- /dev/null +++ b/server/src/main/resources/transport/definitions/referable/allocation_decision_not_preferred.csv @@ -0,0 +1 @@ +9145000 diff --git a/server/src/main/resources/transport/definitions/referable/esql_qualifiers_in_attributes.csv b/server/src/main/resources/transport/definitions/referable/esql_qualifiers_in_attributes.csv new file mode 100644 index 0000000000000..af1799c5601ca --- /dev/null +++ b/server/src/main/resources/transport/definitions/referable/esql_qualifiers_in_attributes.csv @@ -0,0 +1 @@ +9146000 diff --git a/server/src/main/resources/transport/upper_bounds/9.2.csv b/server/src/main/resources/transport/upper_bounds/9.2.csv index 4ae9cd056fcb3..0902d8ba12101 100644 --- a/server/src/main/resources/transport/upper_bounds/9.2.csv +++ b/server/src/main/resources/transport/upper_bounds/9.2.csv @@ -1 +1 @@ -esql_lookup_operator_emitted_rows,9144000 +esql_qualifiers_in_attributes,9146000 diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 40e679b743e99..3c8bdb1c95992 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -18,7 +18,6 @@ import java.util.Objects; import static java.util.Collections.emptyList; -import static org.elasticsearch.TransportVersions.ESQL_QUALIFIERS_IN_ATTRIBUTES; /** * {@link Expression}s that can be materialized and describe properties of the derived table. @@ -38,6 +37,8 @@ public abstract class Attribute extends NamedExpression { */ protected static final String SYNTHETIC_ATTRIBUTE_NAME_PREFIX = "$$"; + private static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = TransportVersion.fromName("esql_qualifiers_in_attributes"); + // can the attr be null private final Nullability nullability; private final String qualifier; @@ -204,7 +205,7 @@ public static boolean dataTypeEquals(List left, List right public abstract boolean isDimension(); protected void checkAndSerializeQualifier(PlanStreamOutput out, TransportVersion version) throws IOException { - if (version.onOrAfter(ESQL_QUALIFIERS_IN_ATTRIBUTES)) { + if (version.supports(ESQL_QUALIFIERS_IN_ATTRIBUTES)) { out.writeOptionalCachedString(qualifier()); } else if (qualifier() != null) { // Non-null qualifier means the query specifically defined one. Old nodes don't know what to do with it and just writing @@ -215,7 +216,7 @@ protected void checkAndSerializeQualifier(PlanStreamOutput out, TransportVersion } protected static String readQualifier(PlanStreamInput in, TransportVersion version) throws IOException { - if (version.onOrAfter(ESQL_QUALIFIERS_IN_ATTRIBUTES)) { + if (version.supports(ESQL_QUALIFIERS_IN_ATTRIBUTES)) { return in.readOptionalCachedString(); } return null; diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/ReferenceAttribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/ReferenceAttribute.java index aeca8120d5187..2cb9cdd3b23c1 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/ReferenceAttribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/ReferenceAttribute.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.esql.core.expression; +import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -18,8 +19,6 @@ import java.io.IOException; -import static org.elasticsearch.TransportVersions.ESQL_QUALIFIERS_IN_ATTRIBUTES; - /** * Attribute based on a reference to an expression. */ @@ -30,6 +29,8 @@ public class ReferenceAttribute extends TypedAttribute { ReferenceAttribute::readFrom ); + private static final TransportVersion ESQL_QUALIFIERS_IN_ATTRIBUTES = TransportVersion.fromName("esql_qualifiers_in_attributes"); + @Deprecated /** * Only used for tests @@ -61,7 +62,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(name()); dataType().writeTo(out); checkAndSerializeQualifier((PlanStreamOutput) out, out.getTransportVersion()); - if (out.getTransportVersion().before(ESQL_QUALIFIERS_IN_ATTRIBUTES)) { + if (out.getTransportVersion().supports(ESQL_QUALIFIERS_IN_ATTRIBUTES) == false) { // We used to always serialize a null qualifier here, so do the same for bwc. out.writeOptionalString(null); } @@ -89,7 +90,7 @@ private static ReferenceAttribute innerReadFrom(StreamInput in) throws IOExcepti String name = in.readString(); DataType dataType = DataType.readFrom(in); String qualifier = readQualifier((PlanStreamInput) in, in.getTransportVersion()); - if (in.getTransportVersion().before(ESQL_QUALIFIERS_IN_ATTRIBUTES)) { + if (in.getTransportVersion().supports(ESQL_QUALIFIERS_IN_ATTRIBUTES) == false) { in.readOptionalString(); } Nullability nullability = in.readEnum(Nullability.class);