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/114784.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 114784
summary: "[ES|QL] make named parameter for identifier and pattern snapshot"
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xpack.esql.EsqlTestUtils;
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
Expand Down Expand Up @@ -670,6 +671,10 @@ public void testErrorMessageForArrayValuesInParams() throws IOException {
}

public void testNamedParamsForIdentifierAndIdentifierPatterns() throws IOException {
assumeTrue(
"named parameters for identifiers and patterns require snapshot build",
EsqlCapabilities.Cap.NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES.isEnabled()
);
bulkLoadTestData(10);
// positive
var query = requestObjectBuilder().query(
Expand Down
16 changes: 8 additions & 8 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ mode PROJECT_MODE;
PROJECT_PIPE : PIPE -> type(PIPE), popMode;
PROJECT_DOT: DOT -> type(DOT);
PROJECT_COMMA : COMMA -> type(COMMA);
PROJECT_PARAM : PARAM -> type(PARAM);
PROJECT_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
PROJECT_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
PROJECT_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

fragment UNQUOTED_ID_BODY_WITH_PATTERN
: (LETTER | DIGIT | UNDERSCORE | ASTERISK)
Expand Down Expand Up @@ -340,8 +340,8 @@ RENAME_PIPE : PIPE -> type(PIPE), popMode;
RENAME_ASSIGN : ASSIGN -> type(ASSIGN);
RENAME_COMMA : COMMA -> type(COMMA);
RENAME_DOT: DOT -> type(DOT);
RENAME_PARAM : PARAM -> type(PARAM);
RENAME_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
RENAME_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
RENAME_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

AS : 'as';

Expand Down Expand Up @@ -413,8 +413,8 @@ ENRICH_FIELD_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
;

ENRICH_FIELD_PARAM : PARAM -> type(PARAM);
ENRICH_FIELD_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
ENRICH_FIELD_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
ENRICH_FIELD_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

ENRICH_FIELD_LINE_COMMENT
: LINE_COMMENT -> channel(HIDDEN)
Expand All @@ -431,8 +431,8 @@ ENRICH_FIELD_WS
mode MVEXPAND_MODE;
MVEXPAND_PIPE : PIPE -> type(PIPE), popMode;
MVEXPAND_DOT: DOT -> type(DOT);
MVEXPAND_PARAM : PARAM -> type(PARAM);
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
MVEXPAND_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);

MVEXPAND_QUOTED_IDENTIFIER
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ identifier

identifierPattern
: ID_PATTERN
| parameter
| {this.isDevVersion()}? parameter
;

constant
Expand All @@ -218,7 +218,7 @@ parameter

identifierOrParameter
: identifier
| parameter
| {this.isDevVersion()}? parameter
;

limitCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ public enum Cap {
/**
* Support named parameters for field names.
*/
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES,
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES(true),

/**
* Fix sorting not allowed on _source and counters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ private static QueryParams parseParams(XContentParser p) throws IOException {
String paramName = entry.getKey();
checkParamNameValidity(paramName, errors, loc);

if (entry.getValue() instanceof Map<?, ?> values) {// parameter specified as key:value pairs
if (EsqlCapabilities.Cap.NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES.isEnabled()
&& entry.getValue() instanceof Map<?, ?> values) {// parameter specified as key:value pairs
Map<ParamParsingKey, Object> paramElements = Maps.newMapWithExpectedSize(2);
for (Object keyName : values.keySet()) {
ParamParsingKey paramType = checkParamValueKeysValidity(keyName.toString(), errors, loc);
Expand Down

Large diffs are not rendered by default.

Loading