From 9f1d97e3eff8edee858ad7e73f799cb6d1203202 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 28 Oct 2025 19:09:43 -0400 Subject: [PATCH] ESQL: Fix release tests New field type isn't serializable outside of snapshot. --- .../esql/enrich/MatchConfigSerializationTests.java | 2 +- .../expression/function/MetadataAttributeTests.java | 2 +- .../expression/function/ReferenceAttributeTests.java | 10 ++++++++-- .../function/scalar/nulls/IsNotNullTests.java | 3 +++ .../expression/function/scalar/nulls/IsNullTests.java | 3 +++ .../elasticsearch/xpack/esql/type/EsFieldTests.java | 5 ++++- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/MatchConfigSerializationTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/MatchConfigSerializationTests.java index 00ee70b670d42..ce9924a4b320e 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/MatchConfigSerializationTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/enrich/MatchConfigSerializationTests.java @@ -52,7 +52,7 @@ private MatchConfig randomMatchConfig() { // Implement logic to create a random MatchConfig instance String name = randomAlphaOfLengthBetween(1, 100); int channel = randomInt(); - DataType type = randomFrom(DataType.types()); + DataType type = randomValueOtherThanMany(t -> false == t.supportedVersion().supportedLocally(), () -> randomFrom(DataType.types())); return new MatchConfig(name, channel, type); } diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java index b983856eb50af..e3702c4a1d4ab 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java @@ -23,7 +23,7 @@ protected MetadataAttribute createTestInstance() { public static MetadataAttribute randomMetadataAttribute() { Source source = Source.EMPTY; String name = randomAlphaOfLength(5); - DataType type = randomFrom(DataType.types()); + DataType type = randomValueOtherThanMany(t -> false == t.supportedVersion().supportedLocally(), () -> randomFrom(DataType.types())); Nullability nullability = randomFrom(Nullability.values()); boolean synthetic = randomBoolean(); boolean searchable = randomBoolean(); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java index 04d0ca5427117..34c8722f49fe8 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java @@ -14,14 +14,20 @@ import org.elasticsearch.xpack.esql.core.type.DataType; import org.elasticsearch.xpack.esql.expression.AbstractNamedExpressionSerializationTests; +import java.util.function.Supplier; + public class ReferenceAttributeTests extends AbstractNamedExpressionSerializationTests { public static ReferenceAttribute randomReferenceAttribute(boolean onlyRepresentable) { Source source = Source.EMPTY; String qualifier = randomBoolean() ? null : randomAlphaOfLength(3); String name = randomAlphaOfLength(5); + Supplier randomType = () -> randomValueOtherThanMany( + t -> false == t.supportedVersion().supportedLocally(), + () -> randomFrom(DataType.types()) + ); DataType type = onlyRepresentable - ? randomValueOtherThanMany(t -> false == DataType.isRepresentable(t), () -> randomFrom(DataType.types())) - : randomFrom(DataType.types()); + ? randomValueOtherThanMany(t -> false == DataType.isRepresentable(t), randomType) + : randomType.get(); Nullability nullability = randomFrom(Nullability.values()); boolean synthetic = randomBoolean(); return new ReferenceAttribute(source, qualifier, name, type, nullability, new NameId(), synthetic); diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullTests.java index 1c570af525690..a7077d466bdee 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullTests.java @@ -37,6 +37,9 @@ public static Iterable parameters() { if ((false == type.isCounter() && false == DataType.isRepresentable(type)) || type == DataType.TSID_DATA_TYPE) { continue; } + if (type.supportedVersion().supportedLocally() == false) { + continue; + } if (type != DataType.NULL) { suppliers.add( new TestCaseSupplier( diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullTests.java index 59a0404909a31..bfa541b7e3ff6 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullTests.java @@ -39,6 +39,9 @@ public static Iterable parameters() { if ((false == type.isCounter() && false == DataType.isRepresentable(type)) || type == DataType.TSID_DATA_TYPE) { continue; } + if (type.supportedVersion().supportedLocally() == false) { + continue; + } if (type != DataType.NULL) { suppliers.add( new TestCaseSupplier( diff --git a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java index bac69261f24b5..f29d97520b3b3 100644 --- a/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java +++ b/x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/type/EsFieldTests.java @@ -15,7 +15,10 @@ public class EsFieldTests extends AbstractEsFieldTypeTests { public static EsField randomEsField(int maxPropertiesDepth) { String name = randomAlphaOfLength(4); - DataType esDataType = randomFrom(DataType.types()); + DataType esDataType = randomValueOtherThanMany( + t -> false == t.supportedVersion().supportedLocally(), + () -> randomFrom(DataType.types()) + ); Map properties = randomProperties(maxPropertiesDepth); boolean aggregatable = randomBoolean(); boolean isAlias = randomBoolean();