Skip to content

Commit 482f5f1

Browse files
authored
[ES|QL] Modify GenerativeMetrics test and unmute (#136932)
This commit modifies the GenerativeMetrics test to avoid certain illegal queries, adds a few more allowed error messages, and unmutes the test in general.
1 parent 5467344 commit 482f5f1

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
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.mixed.MixedClusterEsqlSpecIT
430430
method: test {csv-spec:stats.CountDistinctWithConditions}
431431
issue: https://github.com/elastic/elasticsearch/issues/134993
432-
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeMetricsIT
433-
method: test
434-
issue: https://github.com/elastic/elasticsearch/issues/135055
435432
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
436433
method: testLookupExplosionBigString
437434
issue: https://github.com/elastic/elasticsearch/issues/135122

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public abstract class GenerativeRestTest extends ESRestTestCase implements Query
8181
"time-series.*the first aggregation.*is not allowed",
8282
"count_star .* can't be used with TS command",
8383
"time_series aggregate.* can only be used with the TS command",
84-
"implicit time-series aggregation function .* doesn't support type .*"
84+
"implicit time-series aggregation function .* doesn't support type .*",
85+
"INLINE STATS .* can only be used after STATS when used with TS command",
86+
"cannot group by a metric field .* in a time-series aggregation"
8587
);
8688

8789
public static final Set<Pattern> ALLOWED_ERROR_PATTERNS = ALLOWED_ERRORS.stream()

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/generator/EsqlQueryGenerator.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -133,28 +133,24 @@ public static void generatePipeline(
133133
if (executor.currentSchema().isEmpty()) {
134134
break;
135135
}
136-
boolean commandAllowed = false;
137-
while (commandAllowed == false) {
138-
commandGenerator = isTimeSeries && canGenerateTimeSeries
139-
? randomMetricsPipeCommandGenerator()
140-
: randomPipeCommandGenerator();
141-
if (isTimeSeries == false) {
142-
commandAllowed = true;
143-
} else {
144-
if (commandGenerator.equals(TimeSeriesStatsGenerator.INSTANCE) || commandGenerator.equals(StatsGenerator.INSTANCE)) {
145-
if (canGenerateTimeSeries) {
146-
canGenerateTimeSeries = false;
147-
commandAllowed = true;
148-
}
149-
} else if (commandGenerator.equals(RenameGenerator.INSTANCE)) {
150-
// https://github.com/elastic/elasticsearch/issues/134994
151-
canGenerateTimeSeries = false;
152-
commandAllowed = true;
153-
} else {
154-
commandAllowed = true;
136+
commandGenerator = isTimeSeries && canGenerateTimeSeries ? randomMetricsPipeCommandGenerator() : randomPipeCommandGenerator();
137+
if (isTimeSeries) {
138+
if (commandGenerator.equals(ForkGenerator.INSTANCE)) {
139+
// don't fork with TS command until this is resolved: https://github.com/elastic/elasticsearch/issues/136927
140+
continue;
141+
}
142+
if (commandGenerator.equals(TimeSeriesStatsGenerator.INSTANCE) || commandGenerator.equals(StatsGenerator.INSTANCE)) {
143+
if (canGenerateTimeSeries == false) {
144+
// Don't generate multiple stats commands in a single query for TS
145+
continue;
155146
}
147+
canGenerateTimeSeries = false;
148+
} else if (commandGenerator.equals(RenameGenerator.INSTANCE)) {
149+
// don't allow stats after a rename until this is resolved: https://github.com/elastic/elasticsearch/issues/134994
150+
canGenerateTimeSeries = false;
156151
}
157152
}
153+
158154
desc = commandGenerator.generate(executor.previousCommands(), executor.currentSchema(), schema, queryExecutor);
159155
if (desc == CommandGenerator.EMPTY_DESCRIPTION) {
160156
continue;

0 commit comments

Comments
 (0)