Skip to content

Commit 472e913

Browse files
ES|QL: Fix generative tests - exclude unsupported fields (#132708) (#132791)
1 parent 6389a62 commit 472e913

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/EsqlQueryGenerator.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838

3939
public class EsqlQueryGenerator {
4040

41-
public record Column(String name, String type) {}
41+
public static final String COLUMN_NAME = "name";
42+
public static final String COLUMN_TYPE = "type";
43+
public static final String COLUMN_ORIGINAL_TYPES = "original_types";
44+
45+
public record Column(String name, String type, List<String> originalTypes) {}
4246

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

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

296301
public static String unquote(String colName) {

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/generative/GenerativeRestTest.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.ENRICH_POLICIES;
3030
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.availableDatasetsForEs;
3131
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;
32+
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_NAME;
33+
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_ORIGINAL_TYPES;
34+
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_TYPE;
3235

3336
public abstract class GenerativeRestTest extends ESRestTestCase {
3437

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

196199
@SuppressWarnings("unchecked")
197-
private List<EsqlQueryGenerator.Column> outputSchema(Map<String, Object> a) {
198-
List<Map<String, String>> cols = (List<Map<String, String>>) a.get("columns");
200+
private static List<EsqlQueryGenerator.Column> outputSchema(Map<String, Object> a) {
201+
List<Map<String, ?>> cols = (List<Map<String, ?>>) a.get("columns");
199202
if (cols == null) {
200203
return null;
201204
}
202-
return cols.stream().map(x -> new EsqlQueryGenerator.Column(x.get("name"), x.get("type"))).collect(Collectors.toList());
205+
return cols.stream()
206+
.map(x -> new EsqlQueryGenerator.Column((String) x.get(COLUMN_NAME), (String) x.get(COLUMN_TYPE), originalTypes(x)))
207+
.collect(Collectors.toList());
208+
}
209+
210+
@SuppressWarnings("unchecked")
211+
private static List<String> originalTypes(Map<String, ?> x) {
212+
List<String> originalTypes = (List<String>) x.get(COLUMN_ORIGINAL_TYPES);
213+
if (originalTypes == null) {
214+
return List.of();
215+
}
216+
return originalTypes;
203217
}
204218

205219
private List<String> availableIndices() throws IOException {

0 commit comments

Comments
 (0)