Skip to content

Commit 5965b27

Browse files
authored
[ES|QL] Fix column info bug in Async Rest Test (elastic#127596)
This commit fixes a bug with the async rest tests where some nodes don't support reporting original types + suggested cast and some do causing a mismatch in resulting column info. Fixes elastic#127537
1 parent 94854b3 commit 5965b27

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,6 @@ tests:
429429
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT
430430
method: test
431431
issue: https://github.com/elastic/elasticsearch/issues/127536
432-
- class: org.elasticsearch.xpack.esql.qa.mixed.MixedClusterEsqlSpecIT
433-
method: test {union_types.MultiIndexSortIpStringEval ASYNC}
434-
issue: https://github.com/elastic/elasticsearch/issues/127537
435432
- class: org.elasticsearch.xpack.inference.action.filter.ShardBulkInferenceActionFilterIT
436433
method: testRestart {p0=false p1=false}
437434
issue: https://github.com/elastic/elasticsearch/issues/127592

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1289,6 +1289,7 @@ public static Map<String, Object> runEsqlAsync(
12891289
String id = (String) json.get("id");
12901290

12911291
var supportsAsyncHeaders = clusterHasCapability("POST", "/_query", List.of(), List.of("async_query_status_headers")).orElse(false);
1292+
var supportsSuggestedCast = clusterHasCapability("POST", "/_query", List.of(), List.of("suggested_cast")).orElse(false);
12921293

12931294
if (id == null) {
12941295
// no id returned from an async call, must have completed immediately and without keep_on_completion
@@ -1334,7 +1335,14 @@ public static Map<String, Object> runEsqlAsync(
13341335

13351336
// assert initial contents, if any, are the same as async get contents
13361337
if (initialColumns != null) {
1337-
assertEquals(initialColumns, result.get("columns"));
1338+
if (supportsSuggestedCast == false) {
1339+
assertEquals(
1340+
removeOriginalTypesAndSuggestedCast(initialColumns),
1341+
removeOriginalTypesAndSuggestedCast(result.get("columns"))
1342+
);
1343+
} else {
1344+
assertEquals(initialColumns, result.get("columns"));
1345+
}
13381346
assertEquals(initialValues, result.get("values"));
13391347
}
13401348

@@ -1343,6 +1351,25 @@ public static Map<String, Object> runEsqlAsync(
13431351
return removeAsyncProperties(result);
13441352
}
13451353

1354+
private static Object removeOriginalTypesAndSuggestedCast(Object response) {
1355+
if (response instanceof ArrayList<?> columns) {
1356+
var newColumns = new ArrayList<>();
1357+
for (var column : columns) {
1358+
if (column instanceof Map<?, ?> columnMap) {
1359+
var newMap = new HashMap<>(columnMap);
1360+
newMap.remove("original_types");
1361+
newMap.remove("suggested_cast");
1362+
newColumns.add(newMap);
1363+
} else {
1364+
newColumns.add(column);
1365+
}
1366+
}
1367+
return newColumns;
1368+
} else {
1369+
return response;
1370+
}
1371+
}
1372+
13461373
public void testAsyncGetWithoutContentType() throws IOException {
13471374
int count = randomIntBetween(0, 100);
13481375
bulkLoadTestData(count);

0 commit comments

Comments
 (0)