Skip to content

Commit 4d9fc84

Browse files
authored
ESQL: Fix release tests (#137298)
New field type isn't serializable outside of snapshot.
1 parent 52feb00 commit 4d9fc84

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private MatchConfig randomMatchConfig() {
5252
// Implement logic to create a random MatchConfig instance
5353
String name = randomAlphaOfLengthBetween(1, 100);
5454
int channel = randomInt();
55-
DataType type = randomFrom(DataType.types());
55+
DataType type = randomValueOtherThanMany(t -> false == t.supportedVersion().supportedLocally(), () -> randomFrom(DataType.types()));
5656
return new MatchConfig(name, channel, type);
5757
}
5858

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/MetadataAttributeTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ protected MetadataAttribute createTestInstance() {
2323
public static MetadataAttribute randomMetadataAttribute() {
2424
Source source = Source.EMPTY;
2525
String name = randomAlphaOfLength(5);
26-
DataType type = randomFrom(DataType.types());
26+
DataType type = randomValueOtherThanMany(t -> false == t.supportedVersion().supportedLocally(), () -> randomFrom(DataType.types()));
2727
Nullability nullability = randomFrom(Nullability.values());
2828
boolean synthetic = randomBoolean();
2929
boolean searchable = randomBoolean();

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/ReferenceAttributeTests.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@
1414
import org.elasticsearch.xpack.esql.core.type.DataType;
1515
import org.elasticsearch.xpack.esql.expression.AbstractNamedExpressionSerializationTests;
1616

17+
import java.util.function.Supplier;
18+
1719
public class ReferenceAttributeTests extends AbstractNamedExpressionSerializationTests<ReferenceAttribute> {
1820
public static ReferenceAttribute randomReferenceAttribute(boolean onlyRepresentable) {
1921
Source source = Source.EMPTY;
2022
String qualifier = randomBoolean() ? null : randomAlphaOfLength(3);
2123
String name = randomAlphaOfLength(5);
24+
Supplier<DataType> randomType = () -> randomValueOtherThanMany(
25+
t -> false == t.supportedVersion().supportedLocally(),
26+
() -> randomFrom(DataType.types())
27+
);
2228
DataType type = onlyRepresentable
23-
? randomValueOtherThanMany(t -> false == DataType.isRepresentable(t), () -> randomFrom(DataType.types()))
24-
: randomFrom(DataType.types());
29+
? randomValueOtherThanMany(t -> false == DataType.isRepresentable(t), randomType)
30+
: randomType.get();
2531
Nullability nullability = randomFrom(Nullability.values());
2632
boolean synthetic = randomBoolean();
2733
return new ReferenceAttribute(source, qualifier, name, type, nullability, new NameId(), synthetic);

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNotNullTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public static Iterable<Object[]> parameters() {
3737
if ((false == type.isCounter() && false == DataType.isRepresentable(type)) || type == DataType.TSID_DATA_TYPE) {
3838
continue;
3939
}
40+
if (type.supportedVersion().supportedLocally() == false) {
41+
continue;
42+
}
4043
if (type != DataType.NULL) {
4144
suppliers.add(
4245
new TestCaseSupplier(

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/nulls/IsNullTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public static Iterable<Object[]> parameters() {
3939
if ((false == type.isCounter() && false == DataType.isRepresentable(type)) || type == DataType.TSID_DATA_TYPE) {
4040
continue;
4141
}
42+
if (type.supportedVersion().supportedLocally() == false) {
43+
continue;
44+
}
4245
if (type != DataType.NULL) {
4346
suppliers.add(
4447
new TestCaseSupplier(

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
public class EsFieldTests extends AbstractEsFieldTypeTests<EsField> {
1616
public static EsField randomEsField(int maxPropertiesDepth) {
1717
String name = randomAlphaOfLength(4);
18-
DataType esDataType = randomFrom(DataType.types());
18+
DataType esDataType = randomValueOtherThanMany(
19+
t -> false == t.supportedVersion().supportedLocally(),
20+
() -> randomFrom(DataType.types())
21+
);
1922
Map<String, EsField> properties = randomProperties(maxPropertiesDepth);
2023
boolean aggregatable = randomBoolean();
2124
boolean isAlias = randomBoolean();

0 commit comments

Comments
 (0)