Skip to content

Commit f629d74

Browse files
[ES|QL] Make named parameter for identifier and pattern available only under snapshot (#114784) (#114953)
* make named parameter for identifier and pattern snapshot (cherry picked from commit 2748a96)
1 parent d875c7d commit f629d74

File tree

13 files changed

+1005
-818
lines changed

13 files changed

+1005
-818
lines changed

docs/changelog/114784.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 114784
2+
summary: "[ES|QL] make named parameter for identifier and pattern snapshot"
3+
area: ES|QL
4+
type: bug
5+
issues: []

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.elasticsearch.xcontent.XContentBuilder;
3333
import org.elasticsearch.xcontent.XContentType;
3434
import org.elasticsearch.xpack.esql.EsqlTestUtils;
35+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
3536
import org.junit.After;
3637
import org.junit.Assert;
3738
import org.junit.Before;
@@ -670,6 +671,10 @@ public void testErrorMessageForArrayValuesInParams() throws IOException {
670671
}
671672

672673
public void testNamedParamsForIdentifierAndIdentifierPatterns() throws IOException {
674+
assumeTrue(
675+
"named parameters for identifiers and patterns require snapshot build",
676+
EsqlCapabilities.Cap.NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES.isEnabled()
677+
);
673678
bulkLoadTestData(10);
674679
// positive
675680
var query = requestObjectBuilder().query(

x-pack/plugin/esql/src/main/antlr/EsqlBaseLexer.g4

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ mode PROJECT_MODE;
305305
PROJECT_PIPE : PIPE -> type(PIPE), popMode;
306306
PROJECT_DOT: DOT -> type(DOT);
307307
PROJECT_COMMA : COMMA -> type(COMMA);
308-
PROJECT_PARAM : PARAM -> type(PARAM);
309-
PROJECT_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
308+
PROJECT_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
309+
PROJECT_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
310310
311311
fragment UNQUOTED_ID_BODY_WITH_PATTERN
312312
: (LETTER | DIGIT | UNDERSCORE | ASTERISK)
@@ -340,8 +340,8 @@ RENAME_PIPE : PIPE -> type(PIPE), popMode;
340340
RENAME_ASSIGN : ASSIGN -> type(ASSIGN);
341341
RENAME_COMMA : COMMA -> type(COMMA);
342342
RENAME_DOT: DOT -> type(DOT);
343-
RENAME_PARAM : PARAM -> type(PARAM);
344-
RENAME_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
343+
RENAME_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
344+
RENAME_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
345345
346346
AS : 'as';
347347
@@ -413,8 +413,8 @@ ENRICH_FIELD_QUOTED_IDENTIFIER
413413
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)
414414
;
415415

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

419419
ENRICH_FIELD_LINE_COMMENT
420420
: LINE_COMMENT -> channel(HIDDEN)
@@ -431,8 +431,8 @@ ENRICH_FIELD_WS
431431
mode MVEXPAND_MODE;
432432
MVEXPAND_PIPE : PIPE -> type(PIPE), popMode;
433433
MVEXPAND_DOT: DOT -> type(DOT);
434-
MVEXPAND_PARAM : PARAM -> type(PARAM);
435-
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
434+
MVEXPAND_PARAM : {this.isDevVersion()}? PARAM -> type(PARAM);
435+
MVEXPAND_NAMED_OR_POSITIONAL_PARAM : {this.isDevVersion()}? NAMED_OR_POSITIONAL_PARAM -> type(NAMED_OR_POSITIONAL_PARAM);
436436

437437
MVEXPAND_QUOTED_IDENTIFIER
438438
: QUOTED_IDENTIFIER -> type(QUOTED_IDENTIFIER)

x-pack/plugin/esql/src/main/antlr/EsqlBaseParser.g4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ identifier
195195

196196
identifierPattern
197197
: ID_PATTERN
198-
| parameter
198+
| {this.isDevVersion()}? parameter
199199
;
200200

201201
constant
@@ -218,7 +218,7 @@ parameter
218218

219219
identifierOrParameter
220220
: identifier
221-
| parameter
221+
| {this.isDevVersion()}? parameter
222222
;
223223

224224
limitCommand

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public enum Cap {
375375
/**
376376
* Support named parameters for field names.
377377
*/
378-
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES,
378+
NAMED_PARAMETER_FOR_FIELD_AND_FUNCTION_NAMES(true),
379379

380380
/**
381381
* Fix sorting not allowed on _source and counters.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/RequestXContent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ private static QueryParams parseParams(XContentParser p) throws IOException {
184184
String paramName = entry.getKey();
185185
checkParamNameValidity(paramName, errors, loc);
186186

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

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/EsqlBaseLexer.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)