Skip to content

[ES|QL] Update grammars#213006

Merged
drewdaemon merged 41 commits intomainfrom
esql_grammar_sync_1741050179
Mar 18, 2025
Merged

[ES|QL] Update grammars#213006
drewdaemon merged 41 commits intomainfrom
esql_grammar_sync_1741050179

Conversation

@kibanamachine
Copy link
Contributor

@kibanamachine kibanamachine commented Mar 4, 2025

This PR updates the ES|QL grammars (lexer and parser) to match the latest version in Elasticsearch.

@kibanamachine kibanamachine requested a review from a team as a code owner March 4, 2025 01:03
@kibanamachine kibanamachine added release_note:skip Skip the PR/issue when compiling release notes Team:ESQL ES|QL related features in Kibana t// labels Mar 4, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-esql (Team:ESQL)

@drewdaemon drewdaemon added backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Mar 4, 2025
Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Looks great, thanx for working on this. I know it was hard 👏

@stratoula
Copy link
Contributor

The failure in the jest test is very alarming 🤔

@drewdaemon
Copy link
Contributor

drewdaemon commented Mar 18, 2025

@stratoula that test used an invalid query (extra parenthesis).

The parser used be more forgiving of that kind of mistake, so I think the problem with the tested query got missed because it still generated an AST. With the changes here from Elasticsearch, the parser instead throws a "Stack empty" error and gives up, leading to an empty result.

So, it's just a matter of correcting the query in that particular test case.

@stratoula
Copy link
Contributor

Ah great catch! Opening and closing parenthesis are so difficult to follow sometimes

@drewdaemon
Copy link
Contributor

@elasticmachine merge upstream

@drewdaemon drewdaemon enabled auto-merge (squash) March 18, 2025 18:21
@drewdaemon drewdaemon merged commit 681295f into main Mar 18, 2025
9 checks passed
@drewdaemon drewdaemon deleted the esql_grammar_sync_1741050179 branch March 18, 2025 19:25
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
kbnUiSharedDeps-srcJs 3.6MB 3.6MB +7.9KB

History

cc @drewdaemon

@kibanamachine
Copy link
Contributor Author

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/13931820929

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Mar 18, 2025
This PR updates the ES|QL grammars (lexer and parser) to match the
latest version in Elasticsearch.

---------

Co-authored-by: drewdaemon <drew.tate@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
(cherry picked from commit 681295f)
@kibanamachine
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Mar 18, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] Update grammars
(#213006)](#213006)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Kibana
Machine","email":"42973632+kibanamachine@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-03-18T19:25:57Z","message":"[ES|QL]
Update grammars (#213006)\n\nThis PR updates the ES|QL grammars (lexer
and parser) to match the\nlatest version in
Elasticsearch.\n\n---------\n\nCo-authored-by: drewdaemon
<drew.tate@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: Stratoula
Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"681295ff9ee5bb421d974452aa023284f4152d33","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL]
Update
grammars","number":213006,"url":"https://github.com/elastic/kibana/pull/213006","mergeCommit":{"message":"[ES|QL]
Update grammars (#213006)\n\nThis PR updates the ES|QL grammars (lexer
and parser) to match the\nlatest version in
Elasticsearch.\n\n---------\n\nCo-authored-by: drewdaemon
<drew.tate@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: Stratoula
Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"681295ff9ee5bb421d974452aa023284f4152d33"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/213006","number":213006,"mergeCommit":{"message":"[ES|QL]
Update grammars (#213006)\n\nThis PR updates the ES|QL grammars (lexer
and parser) to match the\nlatest version in
Elasticsearch.\n\n---------\n\nCo-authored-by: drewdaemon
<drew.tate@elastic.co>\nCo-authored-by: Elastic Machine
<elasticmachine@users.noreply.github.com>\nCo-authored-by: Stratoula
Kalafateli
<efstratia.kalafateli@elastic.co>","sha":"681295ff9ee5bb421d974452aa023284f4152d33"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
clintandrewhall pushed a commit to clintandrewhall/kibana that referenced this pull request Mar 20, 2025
This PR updates the ES|QL grammars (lexer and parser) to match the
latest version in Elasticsearch.

---------

Co-authored-by: drewdaemon <drew.tate@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
This PR updates the ES|QL grammars (lexer and parser) to match the
latest version in Elasticsearch.

---------

Co-authored-by: drewdaemon <drew.tate@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
JoseLuisGJ pushed a commit to JoseLuisGJ/kibana that referenced this pull request Mar 24, 2025
This PR updates the ES|QL grammars (lexer and parser) to match the
latest version in Elasticsearch.

---------

Co-authored-by: drewdaemon <drew.tate@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
cqliu1 pushed a commit to cqliu1/kibana that referenced this pull request Mar 31, 2025
This PR updates the ES|QL grammars (lexer and parser) to match the
latest version in Elasticsearch.

---------

Co-authored-by: drewdaemon <drew.tate@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
@sddonne sddonne mentioned this pull request May 23, 2025
28 tasks
sddonne added a commit that referenced this pull request May 30, 2025
## Summary

Part of #215092

## Considerations
### `RRF` may change in the future
@ioanatia has stated that the command may change in the future as it's
not fully implemented yet.

### Licence check
Will be addressed at #216791



https://github.com/user-attachments/assets/759470a2-4afa-4d20-adbf-cb3001895e95


## New command support checklist
### AST support
- [x] Make sure that the new command is in the local Kibana grammar
definition. The ANTLR lexer and parser files are updated every Monday
from the source definition of the language at Elasticsearch (via a
manually merged, automatically generated
[PR](#213006)).
- [x] Create a factory for generating the new node. The new node should
satisfy the `ESQLCommand<Name>` interface. If the syntax of your command
cannot be decomposed only in parameters, you can hold extra information
by extending the `ESQLCommand` interface. I.E., check the Rerank
command.
- [x] While ANTLR is parsing the text query, we create our own AST by
using `onExit` listeners at
`kbn-esql-ast/src/parser/esql_ast_builder_listener.ts`. Implement the
`onExit<COMMAND_NAME>` method based on the interface autogenerated by
ANTLR and push the new node into the AST.
- [x] Create unit tests checking that the correct AST nodes are
generated when parsing your command.
- [x] Add a dedicated [visitor
callback](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-ast/src/visitor/README.md)
for the new command.
- [x] Verify that the `Walker` API can visit the new node.
- [x] Verify that the `Synth` API can construct the new node.

### Validating that the command works well when prettifying the query
- [x] Validate that the prettifier works correctly.
- [ ] Adjust the basic pretty printer and the wrapping pretty printer if
needed.
- [x] Add unit tests validating that the queries are correctly formatted
(even if no adjustment has been done).


### Creating the command definition
- [x] Add the definition of the new command at
`kbn-esql-validation-autocomplete/src/definitions/commands.ts`.

### Adding the corresponding client-side validations
- [x] Add a custom validation if needed.
- [x] Add tests checking the behavior of the validation following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#the-new-way).


### Adding the autocomplete suggestions
- [x] Add the suggestions to be shown when **positioned at** the new
command.
- [x] Create a new folder at
`kbn-esql-validation-autocomplete/src/autocomplete/commands` for your
command.
- [x] Export a `suggest` function that should return an array of
suggestions and set it up into the command definition.
- [ ] Optionally, we must filter or incorporate fields suggestions after
a command is executed, this is supported by adding the
`fieldsSuggestionsAfter` method to the command definition. Read this
documentation to understand how it works.
- [x] If the new command must be suggested only in particular
situations, modify the corresponding suggestions to make it possible.
- [x] Add tests following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#automated-testing).


### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Drew Tate <drewctate@gmail.com>
sddonne added a commit to sddonne/kibana that referenced this pull request May 30, 2025
## Summary

Part of elastic#215092

## Considerations
### `RRF` may change in the future
@ioanatia has stated that the command may change in the future as it's
not fully implemented yet.

### Licence check
Will be addressed at elastic#216791

https://github.com/user-attachments/assets/759470a2-4afa-4d20-adbf-cb3001895e95

## New command support checklist
### AST support
- [x] Make sure that the new command is in the local Kibana grammar
definition. The ANTLR lexer and parser files are updated every Monday
from the source definition of the language at Elasticsearch (via a
manually merged, automatically generated
[PR](elastic#213006)).
- [x] Create a factory for generating the new node. The new node should
satisfy the `ESQLCommand<Name>` interface. If the syntax of your command
cannot be decomposed only in parameters, you can hold extra information
by extending the `ESQLCommand` interface. I.E., check the Rerank
command.
- [x] While ANTLR is parsing the text query, we create our own AST by
using `onExit` listeners at
`kbn-esql-ast/src/parser/esql_ast_builder_listener.ts`. Implement the
`onExit<COMMAND_NAME>` method based on the interface autogenerated by
ANTLR and push the new node into the AST.
- [x] Create unit tests checking that the correct AST nodes are
generated when parsing your command.
- [x] Add a dedicated [visitor
callback](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-ast/src/visitor/README.md)
for the new command.
- [x] Verify that the `Walker` API can visit the new node.
- [x] Verify that the `Synth` API can construct the new node.

### Validating that the command works well when prettifying the query
- [x] Validate that the prettifier works correctly.
- [ ] Adjust the basic pretty printer and the wrapping pretty printer if
needed.
- [x] Add unit tests validating that the queries are correctly formatted
(even if no adjustment has been done).

### Creating the command definition
- [x] Add the definition of the new command at
`kbn-esql-validation-autocomplete/src/definitions/commands.ts`.

### Adding the corresponding client-side validations
- [x] Add a custom validation if needed.
- [x] Add tests checking the behavior of the validation following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#the-new-way).

### Adding the autocomplete suggestions
- [x] Add the suggestions to be shown when **positioned at** the new
command.
- [x] Create a new folder at
`kbn-esql-validation-autocomplete/src/autocomplete/commands` for your
command.
- [x] Export a `suggest` function that should return an array of
suggestions and set it up into the command definition.
- [ ] Optionally, we must filter or incorporate fields suggestions after
a command is executed, this is supported by adding the
`fieldsSuggestionsAfter` method to the command definition. Read this
documentation to understand how it works.
- [x] If the new command must be suggested only in particular
situations, modify the corresponding suggestions to make it possible.
- [x] Add tests following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#automated-testing).

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Drew Tate <drewctate@gmail.com>
(cherry picked from commit 0794030)

# Conflicts:
#	src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/commands.ts
sddonne added a commit to sddonne/kibana that referenced this pull request May 30, 2025
## Summary

Part of elastic#215092

## Considerations
### `RRF` may change in the future
@ioanatia has stated that the command may change in the future as it's
not fully implemented yet.

### Licence check
Will be addressed at elastic#216791

https://github.com/user-attachments/assets/759470a2-4afa-4d20-adbf-cb3001895e95

## New command support checklist
### AST support
- [x] Make sure that the new command is in the local Kibana grammar
definition. The ANTLR lexer and parser files are updated every Monday
from the source definition of the language at Elasticsearch (via a
manually merged, automatically generated
[PR](elastic#213006)).
- [x] Create a factory for generating the new node. The new node should
satisfy the `ESQLCommand<Name>` interface. If the syntax of your command
cannot be decomposed only in parameters, you can hold extra information
by extending the `ESQLCommand` interface. I.E., check the Rerank
command.
- [x] While ANTLR is parsing the text query, we create our own AST by
using `onExit` listeners at
`kbn-esql-ast/src/parser/esql_ast_builder_listener.ts`. Implement the
`onExit<COMMAND_NAME>` method based on the interface autogenerated by
ANTLR and push the new node into the AST.
- [x] Create unit tests checking that the correct AST nodes are
generated when parsing your command.
- [x] Add a dedicated [visitor
callback](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-ast/src/visitor/README.md)
for the new command.
- [x] Verify that the `Walker` API can visit the new node.
- [x] Verify that the `Synth` API can construct the new node.

### Validating that the command works well when prettifying the query
- [x] Validate that the prettifier works correctly.
- [ ] Adjust the basic pretty printer and the wrapping pretty printer if
needed.
- [x] Add unit tests validating that the queries are correctly formatted
(even if no adjustment has been done).

### Creating the command definition
- [x] Add the definition of the new command at
`kbn-esql-validation-autocomplete/src/definitions/commands.ts`.

### Adding the corresponding client-side validations
- [x] Add a custom validation if needed.
- [x] Add tests checking the behavior of the validation following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#the-new-way).

### Adding the autocomplete suggestions
- [x] Add the suggestions to be shown when **positioned at** the new
command.
- [x] Create a new folder at
`kbn-esql-validation-autocomplete/src/autocomplete/commands` for your
command.
- [x] Export a `suggest` function that should return an array of
suggestions and set it up into the command definition.
- [ ] Optionally, we must filter or incorporate fields suggestions after
a command is executed, this is supported by adding the
`fieldsSuggestionsAfter` method to the command definition. Read this
documentation to understand how it works.
- [x] If the new command must be suggested only in particular
situations, modify the corresponding suggestions to make it possible.
- [x] Add tests following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#automated-testing).

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Drew Tate <drewctate@gmail.com>
(cherry picked from commit 0794030)

# Conflicts:
#	src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/commands.ts
sddonne added a commit to sddonne/kibana that referenced this pull request Jun 2, 2025
## Summary

Part of elastic#215092

## Considerations
### `RRF` may change in the future
@ioanatia has stated that the command may change in the future as it's
not fully implemented yet.

### Licence check
Will be addressed at elastic#216791

https://github.com/user-attachments/assets/759470a2-4afa-4d20-adbf-cb3001895e95

## New command support checklist
### AST support
- [x] Make sure that the new command is in the local Kibana grammar
definition. The ANTLR lexer and parser files are updated every Monday
from the source definition of the language at Elasticsearch (via a
manually merged, automatically generated
[PR](elastic#213006)).
- [x] Create a factory for generating the new node. The new node should
satisfy the `ESQLCommand<Name>` interface. If the syntax of your command
cannot be decomposed only in parameters, you can hold extra information
by extending the `ESQLCommand` interface. I.E., check the Rerank
command.
- [x] While ANTLR is parsing the text query, we create our own AST by
using `onExit` listeners at
`kbn-esql-ast/src/parser/esql_ast_builder_listener.ts`. Implement the
`onExit<COMMAND_NAME>` method based on the interface autogenerated by
ANTLR and push the new node into the AST.
- [x] Create unit tests checking that the correct AST nodes are
generated when parsing your command.
- [x] Add a dedicated [visitor
callback](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-ast/src/visitor/README.md)
for the new command.
- [x] Verify that the `Walker` API can visit the new node.
- [x] Verify that the `Synth` API can construct the new node.

### Validating that the command works well when prettifying the query
- [x] Validate that the prettifier works correctly.
- [ ] Adjust the basic pretty printer and the wrapping pretty printer if
needed.
- [x] Add unit tests validating that the queries are correctly formatted
(even if no adjustment has been done).

### Creating the command definition
- [x] Add the definition of the new command at
`kbn-esql-validation-autocomplete/src/definitions/commands.ts`.

### Adding the corresponding client-side validations
- [x] Add a custom validation if needed.
- [x] Add tests checking the behavior of the validation following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#the-new-way).

### Adding the autocomplete suggestions
- [x] Add the suggestions to be shown when **positioned at** the new
command.
- [x] Create a new folder at
`kbn-esql-validation-autocomplete/src/autocomplete/commands` for your
command.
- [x] Export a `suggest` function that should return an array of
suggestions and set it up into the command definition.
- [ ] Optionally, we must filter or incorporate fields suggestions after
a command is executed, this is supported by adding the
`fieldsSuggestionsAfter` method to the command definition. Read this
documentation to understand how it works.
- [x] If the new command must be suggested only in particular
situations, modify the corresponding suggestions to make it possible.
- [x] Add tests following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#automated-testing).

### Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Drew Tate <drewctate@gmail.com>
(cherry picked from commit 0794030)
zacharyparikh pushed a commit to zacharyparikh/kibana that referenced this pull request Jun 4, 2025
## Summary

Part of elastic#215092

## Considerations
### `RRF` may change in the future
@ioanatia has stated that the command may change in the future as it's
not fully implemented yet.

### Licence check
Will be addressed at elastic#216791



https://github.com/user-attachments/assets/759470a2-4afa-4d20-adbf-cb3001895e95


## New command support checklist
### AST support
- [x] Make sure that the new command is in the local Kibana grammar
definition. The ANTLR lexer and parser files are updated every Monday
from the source definition of the language at Elasticsearch (via a
manually merged, automatically generated
[PR](elastic#213006)).
- [x] Create a factory for generating the new node. The new node should
satisfy the `ESQLCommand<Name>` interface. If the syntax of your command
cannot be decomposed only in parameters, you can hold extra information
by extending the `ESQLCommand` interface. I.E., check the Rerank
command.
- [x] While ANTLR is parsing the text query, we create our own AST by
using `onExit` listeners at
`kbn-esql-ast/src/parser/esql_ast_builder_listener.ts`. Implement the
`onExit<COMMAND_NAME>` method based on the interface autogenerated by
ANTLR and push the new node into the AST.
- [x] Create unit tests checking that the correct AST nodes are
generated when parsing your command.
- [x] Add a dedicated [visitor
callback](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-ast/src/visitor/README.md)
for the new command.
- [x] Verify that the `Walker` API can visit the new node.
- [x] Verify that the `Synth` API can construct the new node.

### Validating that the command works well when prettifying the query
- [x] Validate that the prettifier works correctly.
- [ ] Adjust the basic pretty printer and the wrapping pretty printer if
needed.
- [x] Add unit tests validating that the queries are correctly formatted
(even if no adjustment has been done).


### Creating the command definition
- [x] Add the definition of the new command at
`kbn-esql-validation-autocomplete/src/definitions/commands.ts`.

### Adding the corresponding client-side validations
- [x] Add a custom validation if needed.
- [x] Add tests checking the behavior of the validation following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#the-new-way).


### Adding the autocomplete suggestions
- [x] Add the suggestions to be shown when **positioned at** the new
command.
- [x] Create a new folder at
`kbn-esql-validation-autocomplete/src/autocomplete/commands` for your
command.
- [x] Export a `suggest` function that should return an array of
suggestions and set it up into the command definition.
- [ ] Optionally, we must filter or incorporate fields suggestions after
a command is executed, this is supported by adding the
`fieldsSuggestionsAfter` method to the command definition. Read this
documentation to understand how it works.
- [x] If the new command must be suggested only in particular
situations, modify the corresponding suggestions to make it possible.
- [x] Add tests following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#automated-testing).


### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Drew Tate <drewctate@gmail.com>
nickpeihl pushed a commit to nickpeihl/kibana that referenced this pull request Jun 12, 2025
## Summary

Part of elastic#215092

## Considerations
### `RRF` may change in the future
@ioanatia has stated that the command may change in the future as it's
not fully implemented yet.

### Licence check
Will be addressed at elastic#216791



https://github.com/user-attachments/assets/759470a2-4afa-4d20-adbf-cb3001895e95


## New command support checklist
### AST support
- [x] Make sure that the new command is in the local Kibana grammar
definition. The ANTLR lexer and parser files are updated every Monday
from the source definition of the language at Elasticsearch (via a
manually merged, automatically generated
[PR](elastic#213006)).
- [x] Create a factory for generating the new node. The new node should
satisfy the `ESQLCommand<Name>` interface. If the syntax of your command
cannot be decomposed only in parameters, you can hold extra information
by extending the `ESQLCommand` interface. I.E., check the Rerank
command.
- [x] While ANTLR is parsing the text query, we create our own AST by
using `onExit` listeners at
`kbn-esql-ast/src/parser/esql_ast_builder_listener.ts`. Implement the
`onExit<COMMAND_NAME>` method based on the interface autogenerated by
ANTLR and push the new node into the AST.
- [x] Create unit tests checking that the correct AST nodes are
generated when parsing your command.
- [x] Add a dedicated [visitor
callback](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-ast/src/visitor/README.md)
for the new command.
- [x] Verify that the `Walker` API can visit the new node.
- [x] Verify that the `Synth` API can construct the new node.

### Validating that the command works well when prettifying the query
- [x] Validate that the prettifier works correctly.
- [ ] Adjust the basic pretty printer and the wrapping pretty printer if
needed.
- [x] Add unit tests validating that the queries are correctly formatted
(even if no adjustment has been done).


### Creating the command definition
- [x] Add the definition of the new command at
`kbn-esql-validation-autocomplete/src/definitions/commands.ts`.

### Adding the corresponding client-side validations
- [x] Add a custom validation if needed.
- [x] Add tests checking the behavior of the validation following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#the-new-way).


### Adding the autocomplete suggestions
- [x] Add the suggestions to be shown when **positioned at** the new
command.
- [x] Create a new folder at
`kbn-esql-validation-autocomplete/src/autocomplete/commands` for your
command.
- [x] Export a `suggest` function that should return an array of
suggestions and set it up into the command definition.
- [ ] Optionally, we must filter or incorporate fields suggestions after
a command is executed, this is supported by adding the
`fieldsSuggestionsAfter` method to the command definition. Read this
documentation to understand how it works.
- [x] If the new command must be suggested only in particular
situations, modify the corresponding suggestions to make it possible.
- [x] Add tests following this
[guide](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-esql-validation-autocomplete/README.md#automated-testing).


### Checklist

Check the PR satisfies following conditions. 

Reviewers should verify this PR satisfies this list as well.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.

- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Co-authored-by: Drew Tate <drewctate@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:ESQL ES|QL related features in Kibana t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants