Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReferenceAttribute> {
public static ReferenceAttribute randomReferenceAttribute(boolean onlyRepresentable) {
Source source = Source.EMPTY;
String qualifier = randomBoolean() ? null : randomAlphaOfLength(3);
String name = randomAlphaOfLength(5);
Supplier<DataType> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static Iterable<Object[]> 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public static Iterable<Object[]> 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
public class EsFieldTests extends AbstractEsFieldTypeTests<EsField> {
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<String, EsField> properties = randomProperties(maxPropertiesDepth);
boolean aggregatable = randomBoolean();
boolean isAlias = randomBoolean();
Expand Down