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
5 changes: 5 additions & 0 deletions docs/changelog/121911.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 121911
summary: Fix ENRICH validation for use of wildcards
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,9 @@ public NamedExpression visitEnrichWithClause(EsqlBaseParser.EnrichWithClauseCont

private NamedExpression enrichFieldName(EsqlBaseParser.QualifiedNamePatternContext ctx) {
return visitQualifiedNamePattern(ctx, ne -> {
if (ne instanceof UnresolvedNamePattern up) {
if (ne instanceof UnresolvedNamePattern || ne instanceof UnresolvedStar) {
var src = ne.source();
throw new ParsingException(src, "Using wildcards [*] in ENRICH WITH projections is not allowed [{}]", up.pattern());
throw new ParsingException(src, "Using wildcards [*] in ENRICH WITH projections is not allowed, found [{}]", src.text());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,11 @@ public PlanFactory visitEnrichCommand(EsqlBaseParser.EnrichCommandContext ctx) {
: matchField instanceof UnresolvedStar ? WILDCARD
: null;
if (patternString != null) {
throw new ParsingException(source, "Using wildcards [*] in ENRICH WITH projections is not allowed [{}]", patternString);
throw new ParsingException(
source,
"Using wildcards [*] in ENRICH WITH projections is not allowed, found [{}]",
patternString
);
}

List<NamedExpression> keepClauses = visitList(this, ctx.enrichWithClause(), NamedExpression.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1055,15 +1055,28 @@ public void testEnrich() {
processingCommand("enrich _" + mode.name() + ":countries ON country_code")
);

expectError("from a | enrich countries on foo* ", "Using wildcards [*] in ENRICH WITH projections is not allowed [foo*]");
expectError("from a | enrich countries on foo with bar*", "Using wildcards [*] in ENRICH WITH projections is not allowed [bar*]");
expectError("from a | enrich countries on foo* ", "Using wildcards [*] in ENRICH WITH projections is not allowed, found [foo*]");
expectError("from a | enrich countries on * ", "Using wildcards [*] in ENRICH WITH projections is not allowed, found [*]");
expectError(
"from a | enrich countries on foo with bar*",
"Using wildcards [*] in ENRICH WITH projections is not allowed, found [bar*]"
);
expectError("from a | enrich countries on foo with *", "Using wildcards [*] in ENRICH WITH projections is not allowed, found [*]");
expectError(
"from a | enrich countries on foo with x = bar* ",
"Using wildcards [*] in ENRICH WITH projections is not allowed [bar*]"
"Using wildcards [*] in ENRICH WITH projections is not allowed, found [bar*]"
);
expectError(
"from a | enrich countries on foo with x = * ",
"Using wildcards [*] in ENRICH WITH projections is not allowed, found [*]"
);
expectError(
"from a | enrich countries on foo with x* = bar ",
"Using wildcards [*] in ENRICH WITH projections is not allowed [x*]"
"Using wildcards [*] in ENRICH WITH projections is not allowed, found [x*]"
);
expectError(
"from a | enrich countries on foo with * = bar ",
"Using wildcards [*] in ENRICH WITH projections is not allowed, found [*]"
);
expectError(
"from a | enrich typo:countries on foo",
Expand Down Expand Up @@ -1961,7 +1974,7 @@ public void testParamInInvalidPosition() {
expectError(
"from idx1 | " + enrich,
List.of(paramAsPattern("f1", pattern), paramAsIdentifier("f2", "f.2"), paramAsIdentifier("f3", "f.3*")),
"Using wildcards [*] in ENRICH WITH projections is not allowed [" + pattern + "]"
"Using wildcards [*] in ENRICH WITH projections is not allowed, found [" + pattern + "]"
);
expectError(
"from idx1 | " + enrich,
Expand Down