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
6 changes: 0 additions & 6 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,6 @@ tests:
- class: org.elasticsearch.xpack.esql.tree.EsqlNodeSubclassTests
method: testTransform {class org.elasticsearch.xpack.esql.plan.logical.MMR}
issue: https://github.com/elastic/elasticsearch/issues/142674
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT
method: test
issue: https://github.com/elastic/elasticsearch/issues/142426
- class: org.elasticsearch.xpack.esql.qa.multi_node.FieldExtractorIT
method: testTsIndexConflictingTypes {null}
issue: https://github.com/elastic/elasticsearch/issues/142410
Expand All @@ -443,9 +440,6 @@ tests:
- class: org.elasticsearch.index.reindex.ReindexResumeIT
method: testLocalResumeReindexFromScroll_slicedAuto
issue: https://github.com/elastic/elasticsearch/issues/142749
- class: org.elasticsearch.xpack.esql.qa.multi_node.GenerativeIT
method: test
issue: https://github.com/elastic/elasticsearch/issues/142426

# Examples:
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static org.elasticsearch.xpack.esql.generator.EsqlQueryGenerator.COLUMN_ORIGINAL_TYPES;
import static org.elasticsearch.xpack.esql.generator.EsqlQueryGenerator.COLUMN_TYPE;
import static org.elasticsearch.xpack.esql.generator.command.pipe.KeepGenerator.UNMAPPED_FIELD_NAMES;
import static org.elasticsearch.xpack.esql.generator.command.source.FromGenerator.SET_UNMAPPED_FIELDS_PREFIX;

public abstract class GenerativeRestTest extends ESRestTestCase implements QueryExecutor {

Expand Down Expand Up @@ -80,7 +81,9 @@ public abstract class GenerativeRestTest extends ESRestTestCase implements Query
"illegal data type \\[datetime\\]", // https://github.com/elastic/elasticsearch/issues/142137
"Expected to replace a single StubRelation in the plan, but none found", // https://github.com/elastic/elasticsearch/issues/142219
"blocks is empty", // https://github.com/elastic/elasticsearch/issues/142473
"Overflow to represent absolute value of Integer.MIN_VALUE", // https://github.com/elastic/elasticsearch/issues/142642
"Overflow to represent absolute value of .*.MIN_VALUE", // https://github.com/elastic/elasticsearch/issues/142642
"illegal query_string option \\[boost\\]", // https://github.com/elastic/elasticsearch/issues/142758
"found value \\[.*\\] type \\[unsupported\\]", // https://github.com/elastic/elasticsearch/issues/142761

// Awaiting fixes for correctness
"Expecting at most \\[.*\\] columns, got \\[.*\\]", // https://github.com/elastic/elasticsearch/issues/129561
Expand Down Expand Up @@ -261,7 +264,7 @@ protected CommandGenerator sourceCommand() {
return EsqlQueryGenerator.sourceCommand();
}

private static CommandGenerator.ValidationResult checkResults(
protected static CommandGenerator.ValidationResult checkResults(
List<CommandGenerator.CommandDescription> previousCommands,
CommandGenerator commandGenerator,
CommandGenerator.CommandDescription commandDescription,
Expand All @@ -288,12 +291,15 @@ private static CommandGenerator.ValidationResult checkResults(
if (isFirstLastSameFieldError(outputValidation.errorMessage(), result.query())) {
return outputValidation;
}
if (isForkOptimizationBugWithUnmappedFields(outputValidation.errorMessage(), result.query())) {
return outputValidation;
}
fail("query: " + result.query() + "\nerror: " + outputValidation.errorMessage());
}
return outputValidation;
}

private void checkException(QueryExecuted query) {
protected void checkException(QueryExecuted query) {
for (Pattern allowedError : ALLOWED_ERROR_PATTERNS) {
if (isAllowedError(query.exception().getMessage(), allowedError)) {
return;
Expand All @@ -305,6 +311,9 @@ private void checkException(QueryExecuted query) {
if (isFirstLastSameFieldError(query.exception().getMessage(), query.query())) {
return;
}
if (isForkOptimizationBugWithUnmappedFields(query.exception().getMessage(), query.query())) {
return;
}
fail("query: " + query.query() + "\nexception: " + query.exception().getMessage());
}

Expand Down Expand Up @@ -389,6 +398,20 @@ private static boolean isFirstLastSameFieldError(String errorMessage, String que
return false;
}

private static final Pattern FORK_OPTIMIZED_INCORRECTLY_PATTERN = Pattern.compile(
".*Plan \\[.*\\] optimized incorrectly due to missing references \\[_fork.*",
Pattern.DOTALL
);

/**
* When {@code SET unmapped_fields="nullify"} is used, the _fork reference can go missing
* during plan optimization.
* See <a href="https://github.com/elastic/elasticsearch/issues/142762">#142762</a>
*/
static boolean isForkOptimizationBugWithUnmappedFields(String errorMessage, String query) {
return query.startsWith(SET_UNMAPPED_FIELDS_PREFIX) && FORK_OPTIMIZED_INCORRECTLY_PATTERN.matcher(errorMessage).matches();
}

@Override
@SuppressWarnings("unchecked")
public QueryExecuted execute(String query, int depth) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class EsqlQueryGenerator {
/**
* These are downstream commands, ie. that cannot appear as the first command in a query
*/
static List<CommandGenerator> PIPE_COMMANDS = List.of(
public static List<CommandGenerator> PIPE_COMMANDS = List.of(
ChangePointGenerator.INSTANCE,
DissectGenerator.INSTANCE,
DropGenerator.INSTANCE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class FromGenerator implements CommandGenerator {
*/
public static final String UNMAPPED_FIELDS_ENABLED = "unmappedFieldsEnabled";

public static final String SET_UNMAPPED_FIELDS_PREFIX = "SET unmapped_fields=\"nullify\";";

@Override
public CommandDescription generate(
List<CommandDescription> previousCommands,
Expand All @@ -38,7 +40,7 @@ public CommandDescription generate(
boolean useUnmappedFields = shouldAddUnmappedFieldWithProbabilityIncrease(3);
StringBuilder result = new StringBuilder();
if (useUnmappedFields) {
result.append("SET unmapped_fields=\"nullify\";");
result.append(SET_UNMAPPED_FIELDS_PREFIX);
}
result.append("from ");
int items = randomIntBetween(1, 3);
Expand Down