Skip to content

Commit 23066a3

Browse files
ES|QL: Fix generative tests - exclude unsupported fields (#132708)
1 parent f8b2b3b commit 23066a3

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
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

@@ -330,7 +334,8 @@ public static boolean fieldCanBeUsed(Column field) {
330334
// this is a known pathological case, no need to test it for now
331335
|| field.name().equals("<no-fields>")
332336
// no dense vectors for now, they are not supported in most commands
333-
|| field.type().contains("vector")) == false;
337+
|| field.type().contains("vector")
338+
|| field.originalTypes.stream().anyMatch(x -> x.contains("vector"))) == false;
334339
}
335340

336341
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: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.ENRICH_POLICIES;
3333
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.availableDatasetsForEs;
3434
import static org.elasticsearch.xpack.esql.CsvTestsDataLoader.loadDataSetIntoEs;
35+
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_NAME;
36+
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_ORIGINAL_TYPES;
37+
import static org.elasticsearch.xpack.esql.qa.rest.generative.EsqlQueryGenerator.COLUMN_TYPE;
3538

3639
public abstract class GenerativeRestTest extends ESRestTestCase {
3740

@@ -212,11 +215,22 @@ public static EsqlQueryGenerator.QueryExecuted execute(String command, int depth
212215

213216
@SuppressWarnings("unchecked")
214217
private static List<EsqlQueryGenerator.Column> outputSchema(Map<String, Object> a) {
215-
List<Map<String, String>> cols = (List<Map<String, String>>) a.get("columns");
218+
List<Map<String, ?>> cols = (List<Map<String, ?>>) a.get("columns");
216219
if (cols == null) {
217220
return null;
218221
}
219-
return cols.stream().map(x -> new EsqlQueryGenerator.Column(x.get("name"), x.get("type"))).collect(Collectors.toList());
222+
return cols.stream()
223+
.map(x -> new EsqlQueryGenerator.Column((String) x.get(COLUMN_NAME), (String) x.get(COLUMN_TYPE), originalTypes(x)))
224+
.collect(Collectors.toList());
225+
}
226+
227+
@SuppressWarnings("unchecked")
228+
private static List<String> originalTypes(Map<String, ?> x) {
229+
List<String> originalTypes = (List<String>) x.get(COLUMN_ORIGINAL_TYPES);
230+
if (originalTypes == null) {
231+
return List.of();
232+
}
233+
return originalTypes;
220234
}
221235

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

0 commit comments

Comments
 (0)