Skip to content

A random-random test for time-series data #132556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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 @@ -50,6 +50,7 @@ public enum FieldType {
TEXT("text"),
IP("ip"),
CONSTANT_KEYWORD("constant_keyword"),
PASSTHROUGH("passthrough"), // For now this field type does not have default generators.
WILDCARD("wildcard");

private final String name;
Expand Down Expand Up @@ -78,6 +79,7 @@ public FieldDataGenerator generator(String fieldName, DataSource dataSource) {
case IP -> new IpFieldDataGenerator(dataSource);
case CONSTANT_KEYWORD -> new ConstantKeywordFieldDataGenerator();
case WILDCARD -> new WildcardFieldDataGenerator(dataSource);
default -> null;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Mapping generate(Template template) {

rawMapping.put("_doc", topLevelMappingParameters);

if (specification.fullyDynamicMapping()) {
if (specification.fullyDynamicMapping() == false) {
// Has to be "true" for fully dynamic mapping
topLevelMappingParameters.remove("dynamic");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public <T extends DataSourceResponse> T get(DataSourceRequest<T> request) {
return response;
}
}

throw new IllegalStateException("Request is not supported by data source");
throw new IllegalStateException(
"Request is not supported by data source. Request: "
+ request.toString()
+ "\n"
+ "Available handlers: "
+ handlers.stream().map(Object::getClass).map(Class::getName).toList().toString()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public DataSourceResponse.LeafMappingParametersGenerator handle(DataSourceReques
case IP -> ipMapping();
case CONSTANT_KEYWORD -> constantKeywordMapping();
case WILDCARD -> wildcardMapping();
default -> throw new IllegalArgumentException("Unsupported field type: " + fieldType);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import org.elasticsearch.datageneration.FieldType;
import org.elasticsearch.test.ESTestCase;

import java.util.Arrays;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import static org.elasticsearch.test.ESTestCase.randomDouble;
import static org.elasticsearch.test.ESTestCase.randomIntBetween;
Expand Down Expand Up @@ -66,13 +68,18 @@ public String generateFieldName() {

// UNSIGNED_LONG is excluded because it is mapped as long
// and values larger than long fail to parse.
private static final Set<FieldType> EXCLUDED_FROM_DYNAMIC_MAPPING = Set.of(FieldType.UNSIGNED_LONG);
private static final Set<FieldType> EXCLUDED_FROM_DYNAMIC_MAPPING = Set.of(FieldType.UNSIGNED_LONG, FieldType.PASSTHROUGH);

@Override
public DataSourceResponse.FieldTypeGenerator handle(DataSourceRequest.FieldTypeGenerator request) {
return new DataSourceResponse.FieldTypeGenerator(
() -> new DataSourceResponse.FieldTypeGenerator.FieldTypeInfo(ESTestCase.randomFrom(FieldType.values()).toString())
);
return new DataSourceResponse.FieldTypeGenerator(() -> {
// All field types minus the excluded ones.
var fieldTypes = Arrays.stream(FieldType.values())
.filter(fieldType -> EXCLUDED_FROM_DYNAMIC_MAPPING.contains(fieldType) == false)
.collect(Collectors.toSet());
var fieldType = ESTestCase.randomFrom(fieldTypes);
return new DataSourceResponse.FieldTypeGenerator.FieldTypeInfo(fieldType.toString());
});
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugin/esql/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ dependencies {
compileOnly project(':modules:lang-painless:spi')
compileOnly project(xpackModule('esql-core'))
compileOnly project(xpackModule('ml'))
compileOnly project(path: xpackModule('mapper-aggregate-metric'))
compileOnly project(path: xpackModule('downsample'))
implementation project(xpackModule('kql'))
implementation project('compute')
implementation project('compute:ann')
Expand Down
Loading