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 @@ -66,6 +66,7 @@ public abstract class GenerativeRestTest extends ESRestTestCase implements Query
"The incoming YAML document exceeds the limit:", // still to investigate, but it seems to be specific to the test framework
"Data too large", // Circuit breaker exceptions eg. https://github.com/elastic/elasticsearch/issues/130072
"optimized incorrectly due to missing references", // https://github.com/elastic/elasticsearch/issues/131509
"can't build page out of released blocks", // https://github.com/elastic/elasticsearch/issues/135679

// Awaiting fixes for correctness
"Expecting at most \\[.*\\] columns, got \\[.*\\]", // https://github.com/elastic/elasticsearch/issues/129561
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.xpack.esql.generator.command.pipe.EvalGenerator;
import org.elasticsearch.xpack.esql.generator.command.pipe.ForkGenerator;
import org.elasticsearch.xpack.esql.generator.command.pipe.GrokGenerator;
import org.elasticsearch.xpack.esql.generator.command.pipe.InlineStatsGenerator;
import org.elasticsearch.xpack.esql.generator.command.pipe.KeepGenerator;
import org.elasticsearch.xpack.esql.generator.command.pipe.LimitGenerator;
import org.elasticsearch.xpack.esql.generator.command.pipe.LookupJoinGenerator;
Expand Down Expand Up @@ -67,6 +68,7 @@ public class EsqlQueryGenerator {
ForkGenerator.INSTANCE,
GrokGenerator.INSTANCE,
KeepGenerator.INSTANCE,
InlineStatsGenerator.INSTANCE,
LimitGenerator.INSTANCE,
LookupJoinGenerator.INSTANCE,
MvExpandGenerator.INSTANCE,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

package org.elasticsearch.xpack.esql.generator.command.pipe;

import org.elasticsearch.xpack.esql.generator.Column;
import org.elasticsearch.xpack.esql.generator.command.CommandGenerator;

import java.util.List;

public class InlineStatsGenerator extends StatsGenerator {
public static final String INLINE_STATS = "inline stats";
public static final CommandGenerator INSTANCE = new InlineStatsGenerator();

@Override
public String commandName() {
return INLINE_STATS;
}

@Override
public ValidationResult validateOutput(
List<CommandDescription> previousCommands,
CommandDescription commandDescription,
List<Column> previousColumns,
List<List<Object>> previousOutput,
List<Column> columns,
List<List<Object>> output
) {
if (commandDescription == EMPTY_DESCRIPTION) {
return VALIDATION_OK;
}

int prevCols = previousColumns.size();

if (previousColumns.stream().anyMatch(x -> x.name().equals("<all-fields-projected>"))) {
// known bug https://github.com/elastic/elasticsearch/issues/121741
prevCols--;
}

if (prevCols > columns.size()) {
return new ValidationResult(false, "Expecting at least [" + prevCols + "] columns, got [" + columns.size() + "]");
}
return VALIDATION_OK;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public class StatsGenerator implements CommandGenerator {
public static final String STATS = "stats";
public static final CommandGenerator INSTANCE = new StatsGenerator();

public String commandName() {
return STATS;
}

@Override
public CommandDescription generate(
List<CommandDescription> previousCommands,
Expand All @@ -38,7 +42,9 @@ public CommandDescription generate(
if (nonNull.isEmpty()) {
return EMPTY_DESCRIPTION;
}
StringBuilder cmd = new StringBuilder(" | stats ");
StringBuilder cmd = new StringBuilder(" | ");
cmd.append(commandName());
cmd.append(" ");
int nStats = randomIntBetween(1, 5);
for (int i = 0; i < nStats; i++) {
String name;
Expand All @@ -65,7 +71,7 @@ public CommandDescription generate(
cmd.append(" by " + col);
}
}
return new CommandDescription(STATS, this, cmd.toString(), Map.of());
return new CommandDescription(commandName(), this, cmd.toString(), Map.of());
}

@Override
Expand Down