Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -795,9 +795,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 [{}]", src.text());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new ParsingException(src, "Using wildcards [*] in ENRICH WITH projections is not allowed [{}]", src.text());
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 @@ -1082,15 +1082,19 @@ public void testEnrich() {
);

expectError("from a | enrich countries on foo* ", "Using wildcards [*] in ENRICH WITH projections is not allowed [foo*]");
expectError("from a | enrich countries on * ", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
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 with *", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
expectError(
"from a | enrich countries on foo with x = bar* ",
"Using wildcards [*] in ENRICH WITH projections is not allowed [bar*]"
);
expectError("from a | enrich countries on foo with x = * ", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
expectError(
"from a | enrich countries on foo with x* = bar ",
"Using wildcards [*] in ENRICH WITH projections is not allowed [x*]"
);
expectError("from a | enrich countries on foo with * = bar ", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
expectError(
"from a | enrich typo:countries on foo",
"line 1:17: Unrecognized value [typo], ENRICH policy qualifier needs to be one of [_ANY, _COORDINATOR, _REMOTE]"
Expand Down