Skip to content

Commit cf3c7e4

Browse files
ES|QL: fix ENRICH validation for use of wildcards
1 parent 671ecd0 commit cf3c7e4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/ExpressionBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,9 @@ public NamedExpression visitEnrichWithClause(EsqlBaseParser.EnrichWithClauseCont
795795

796796
private NamedExpression enrichFieldName(EsqlBaseParser.QualifiedNamePatternContext ctx) {
797797
return visitQualifiedNamePattern(ctx, ne -> {
798-
if (ne instanceof UnresolvedNamePattern up) {
798+
if (ne instanceof UnresolvedNamePattern || ne instanceof UnresolvedStar) {
799799
var src = ne.source();
800-
throw new ParsingException(src, "Using wildcards [*] in ENRICH WITH projections is not allowed [{}]", up.pattern());
800+
throw new ParsingException(src, "Using wildcards [*] in ENRICH WITH projections is not allowed [{}]", src.text());
801801
}
802802
});
803803
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/parser/StatementParserTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,15 +1082,19 @@ public void testEnrich() {
10821082
);
10831083

10841084
expectError("from a | enrich countries on foo* ", "Using wildcards [*] in ENRICH WITH projections is not allowed [foo*]");
1085+
expectError("from a | enrich countries on * ", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
10851086
expectError("from a | enrich countries on foo with bar*", "Using wildcards [*] in ENRICH WITH projections is not allowed [bar*]");
1087+
expectError("from a | enrich countries on foo with *", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
10861088
expectError(
10871089
"from a | enrich countries on foo with x = bar* ",
10881090
"Using wildcards [*] in ENRICH WITH projections is not allowed [bar*]"
10891091
);
1092+
expectError("from a | enrich countries on foo with x = * ", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
10901093
expectError(
10911094
"from a | enrich countries on foo with x* = bar ",
10921095
"Using wildcards [*] in ENRICH WITH projections is not allowed [x*]"
10931096
);
1097+
expectError("from a | enrich countries on foo with * = bar ", "Using wildcards [*] in ENRICH WITH projections is not allowed [*]");
10941098
expectError(
10951099
"from a | enrich typo:countries on foo",
10961100
"line 1:17: Unrecognized value [typo], ENRICH policy qualifier needs to be one of [_ANY, _COORDINATOR, _REMOTE]"

0 commit comments

Comments
 (0)