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 @@ -38,7 +38,11 @@

public class EsqlQueryGenerator {

public record Column(String name, String type) {}
public static final String COLUMN_NAME = "name";
public static final String COLUMN_TYPE = "type";
public static final String COLUMN_ORIGINAL_TYPES = "original_types";

public record Column(String name, String type, List<String> originalTypes) {}

public record QueryExecuted(String query, int depth, List<Column> outputSchema, List<List<Object>> result, Exception exception) {}

Expand Down Expand Up @@ -290,7 +294,8 @@ public static boolean fieldCanBeUsed(Column field) {
// this is a known pathological case, no need to test it for now
|| field.name().equals("<no-fields>")
// no dense vectors for now, they are not supported in most commands
|| field.type().contains("vector")) == false;
|| field.type().contains("vector")
|| field.originalTypes.stream().anyMatch(x -> x.contains("vector"))) == false;
}

public static String unquote(String colName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.ENRICH_POLICIES;
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.availableDatasetsForEs;
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_NAME;
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_ORIGINAL_TYPES;
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_TYPE;

public abstract class GenerativeRestTest extends ESRestTestCase {

Expand Down Expand Up @@ -194,12 +197,23 @@ private EsqlQueryGenerator.QueryExecuted execute(String command, int depth) {
}

@SuppressWarnings("unchecked")
private List<EsqlQueryGenerator.Column> outputSchema(Map<String, Object> a) {
List<Map<String, String>> cols = (List<Map<String, String>>) a.get("columns");
private static List<EsqlQueryGenerator.Column> outputSchema(Map<String, Object> a) {
List<Map<String, ?>> cols = (List<Map<String, ?>>) a.get("columns");
if (cols == null) {
return null;
}
return cols.stream().map(x -> new EsqlQueryGenerator.Column(x.get("name"), x.get("type"))).collect(Collectors.toList());
return cols.stream()
.map(x -> new EsqlQueryGenerator.Column((String) x.get(COLUMN_NAME), (String) x.get(COLUMN_TYPE), originalTypes(x)))
.collect(Collectors.toList());
}

@SuppressWarnings("unchecked")
private static List<String> originalTypes(Map<String, ?> x) {
List<String> originalTypes = (List<String>) x.get(COLUMN_ORIGINAL_TYPES);
if (originalTypes == null) {
return List.of();
}
return originalTypes;
}

private List<String> availableIndices() throws IOException {
Expand Down