Skip to content

Commit 79e1aed

Browse files
committed
MapExpression improvements.
1 parent 0e83b19 commit 79e1aed

File tree

7 files changed

+597
-460
lines changed

7 files changed

+597
-460
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Literal.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ public static Literal keyword(Source source, String literal) {
193193
return new Literal(source, BytesRefs.toBytesRef(literal), KEYWORD);
194194
}
195195

196+
public static Literal keyword(Source source, Collection<String> literal) {
197+
return new Literal(source, literal.stream().map(BytesRefs::toBytesRef).toList(), KEYWORD);
198+
}
199+
196200
/**
197201
* Not all literal values are currently supported in StreamInput/StreamOutput as generic values.
198202
* This mapper allows for addition of new and interesting values without (yet) adding to StreamInput/Output.

x-pack/plugin/esql/src/main/antlr/parser/Expression.g4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,15 @@ primaryExpression
4949

5050
functionExpression
5151
: functionName LP (ASTERISK | (booleanExpression (COMMA booleanExpression)* (COMMA mapExpression)?))? RP
52+
| functionName LP mapExpression? RP
5253
;
5354

5455
functionName
5556
: identifierOrParameter
5657
;
5758

5859
mapExpression
59-
: LEFT_BRACES entryExpression (COMMA entryExpression)* RIGHT_BRACES
60+
: LEFT_BRACES (entryExpression (COMMA entryExpression)*)? RIGHT_BRACES
6061
;
6162

6263
entryExpression

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)