From 20caae314035a493fce31c2b9da6034e4976b461 Mon Sep 17 00:00:00 2001 From: Lantao Jin Date: Fri, 10 Oct 2025 11:08:20 +0800 Subject: [PATCH 1/2] Fix missing keywordsCanBeId Signed-off-by: Lantao Jin --- .../rest-api-spec/test/issues/4481.yml | 59 +++++++++++++++++++ ppl/src/main/antlr/OpenSearchPPLLexer.g4 | 5 -- ppl/src/main/antlr/OpenSearchPPLParser.g4 | 11 +++- 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml diff --git a/integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml b/integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml new file mode 100644 index 00000000000..c824bf8db13 --- /dev/null +++ b/integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml @@ -0,0 +1,59 @@ +"Fix missing keywordsCanBeID": + - skip: + features: + - headers + - allowed_warnings + - do: + indices.create: + index: log-test + body: + mappings: + properties: + "as": + properties: + "by": + properties: + "on": + properties: + "limit": + properties: + "datamodel": + properties: + "overwrite": + properties: + "sed": + properties: + "label": + properties: + "aggregation": + properties: + "brain": + properties: + "simple_pattern": + properties: + "max_match": + properties: + "offset_field": + properties: + "to": + properties: + "millisecond": + type: integer + + - do: + bulk: + index: log-test + refresh: true + body: + - '{"index": {}}' + - '{"as": {"by": {"on": {"limit": {"datamodel": {"overwrite": {"sed": {"label": {"aggregation": {"brain": {"simple_pattern": {"max_match": {"offset_field": {"to": {"millisecond": 1 } } } } } } } } } } } } } } }' + + - do: + headers: + Content-Type: 'application/json' + ppl: + body: + query: source=log-test | fields as.by.on.limit.datamodel.overwrite.sed.label.aggregation.brain.simple_pattern.max_match.offset_field.to.millisecond + + - match: { total: 1 } + - length: { datarows: 1 } diff --git a/ppl/src/main/antlr/OpenSearchPPLLexer.g4 b/ppl/src/main/antlr/OpenSearchPPLLexer.g4 index 30ba0f7013d..55cfa5e08b2 100644 --- a/ppl/src/main/antlr/OpenSearchPPLLexer.g4 +++ b/ppl/src/main/antlr/OpenSearchPPLLexer.g4 @@ -17,7 +17,6 @@ EXPLAIN: 'EXPLAIN'; FROM: 'FROM'; WHERE: 'WHERE'; FIELDS: 'FIELDS'; -FIELD: 'FIELD'; TABLE: 'TABLE'; // Alias for FIELDS command RENAME: 'RENAME'; STATS: 'STATS'; @@ -170,7 +169,6 @@ HOUR_OF_DAY: 'HOUR_OF_DAY'; HOUR_SECOND: 'HOUR_SECOND'; INTERVAL: 'INTERVAL'; MICROSECOND: 'MICROSECOND'; -MILLISECOND: 'MILLISECOND'; MINUTE: 'MINUTE'; MINUTE_MICROSECOND: 'MINUTE_MICROSECOND'; MINUTE_OF_DAY: 'MINUTE_OF_DAY'; @@ -188,9 +186,7 @@ YEAR: 'YEAR'; YEAR_MONTH: 'YEAR_MONTH'; // DATASET TYPES -DATAMODEL: 'DATAMODEL'; LOOKUP: 'LOOKUP'; -SAVEDSEARCH: 'SAVEDSEARCH'; // CONVERTED DATA TYPES INT: 'INT'; @@ -398,7 +394,6 @@ SUBSTRING: 'SUBSTRING'; LTRIM: 'LTRIM'; RTRIM: 'RTRIM'; TRIM: 'TRIM'; -TO: 'TO'; LOWER: 'LOWER'; UPPER: 'UPPER'; CONCAT: 'CONCAT'; diff --git a/ppl/src/main/antlr/OpenSearchPPLParser.g4 b/ppl/src/main/antlr/OpenSearchPPLParser.g4 index 4cfa1288de7..6a9be14d7bc 100644 --- a/ppl/src/main/antlr/OpenSearchPPLParser.g4 +++ b/ppl/src/main/antlr/OpenSearchPPLParser.g4 @@ -1467,7 +1467,16 @@ searchableKeyWord | PATH | INPUT | OUTPUT - + | AS + | BY + | ON + | LIMIT + | OVERWRITE + | SED + | MAX_MATCH + | OFFSET_FIELD + | patternMethod + | patternMode // AGGREGATIONS AND WINDOW | statsFunctionName | windowFunctionName From d7abcfb54b6736e387bfb2cb4c5e6c5f53d9dc95 Mon Sep 17 00:00:00 2001 From: Lantao Jin Date: Fri, 10 Oct 2025 11:30:13 +0800 Subject: [PATCH 2/2] revert partially Signed-off-by: Lantao Jin --- .../resources/rest-api-spec/test/issues/4481.yml | 6 +++--- ppl/src/main/antlr/OpenSearchPPLLexer.g4 | 1 + ppl/src/main/antlr/OpenSearchPPLParser.g4 | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml b/integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml index c824bf8db13..5dceb720c3b 100644 --- a/integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml +++ b/integ-test/src/yamlRestTest/resources/rest-api-spec/test/issues/4481.yml @@ -11,7 +11,7 @@ properties: "as": properties: - "by": + "field": properties: "on": properties: @@ -46,14 +46,14 @@ refresh: true body: - '{"index": {}}' - - '{"as": {"by": {"on": {"limit": {"datamodel": {"overwrite": {"sed": {"label": {"aggregation": {"brain": {"simple_pattern": {"max_match": {"offset_field": {"to": {"millisecond": 1 } } } } } } } } } } } } } } }' + - '{"as": {"field": {"on": {"limit": {"datamodel": {"overwrite": {"sed": {"label": {"aggregation": {"brain": {"simple_pattern": {"max_match": {"offset_field": {"to": {"millisecond": 1 } } } } } } } } } } } } } } }' - do: headers: Content-Type: 'application/json' ppl: body: - query: source=log-test | fields as.by.on.limit.datamodel.overwrite.sed.label.aggregation.brain.simple_pattern.max_match.offset_field.to.millisecond + query: source=log-test | fields as.field.on.limit.datamodel.overwrite.sed.label.aggregation.brain.simple_pattern.max_match.offset_field.to.millisecond - match: { total: 1 } - length: { datarows: 1 } diff --git a/ppl/src/main/antlr/OpenSearchPPLLexer.g4 b/ppl/src/main/antlr/OpenSearchPPLLexer.g4 index 55cfa5e08b2..ba1e4960bb2 100644 --- a/ppl/src/main/antlr/OpenSearchPPLLexer.g4 +++ b/ppl/src/main/antlr/OpenSearchPPLLexer.g4 @@ -17,6 +17,7 @@ EXPLAIN: 'EXPLAIN'; FROM: 'FROM'; WHERE: 'WHERE'; FIELDS: 'FIELDS'; +FIELD: 'FIELD'; TABLE: 'TABLE'; // Alias for FIELDS command RENAME: 'RENAME'; STATS: 'STATS'; diff --git a/ppl/src/main/antlr/OpenSearchPPLParser.g4 b/ppl/src/main/antlr/OpenSearchPPLParser.g4 index 6a9be14d7bc..2e03314c5f7 100644 --- a/ppl/src/main/antlr/OpenSearchPPLParser.g4 +++ b/ppl/src/main/antlr/OpenSearchPPLParser.g4 @@ -1468,10 +1468,10 @@ searchableKeyWord | INPUT | OUTPUT | AS - | BY | ON | LIMIT | OVERWRITE + | FIELD | SED | MAX_MATCH | OFFSET_FIELD