Skip to content

[ES|QL] MapExpression improvements. #129759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ public static Literal keyword(Source source, String literal) {
return new Literal(source, BytesRefs.toBytesRef(literal), KEYWORD);
}

public static Literal keyword(Source source, Collection<String> literal) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ Make it easier to instantiate multivalued strings literals, especially in tests

return new Literal(source, literal.stream().map(BytesRefs::toBytesRef).toList(), KEYWORD);
}

/**
* Not all literal values are currently supported in StreamInput/StreamOutput as generic values.
* This mapper allows for addition of new and interesting values without (yet) adding to StreamInput/Output.
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugin/esql/src/main/antlr/parser/Expression.g4
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ primaryExpression

functionExpression
: functionName LP (ASTERISK | (booleanExpression (COMMA booleanExpression)* (COMMA mapExpression)?))? RP
| functionName LP mapExpression? RP
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ A small grammar change to allow a function that have only optional params which is currently impossible

my_function({"foo": "bar"})

;

functionName
: identifierOrParameter
;

mapExpression
: LEFT_BRACES entryExpression (COMMA entryExpression)* RIGHT_BRACES
: LEFT_BRACES (entryExpression (COMMA entryExpression)*)? RIGHT_BRACES
;

entryExpression
Expand Down

Large diffs are not rendered by default.

Loading