-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ES|QL] Escape keywords in identifier priting #230491
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
Conversation
|
Pinging @elastic/kibana-esql (Team:ESQL) |
💚 Build Succeeded
Metrics [docs]Async chunks
Page load bundle
|
|
Starting backport for target branches: 8.19, 9.1 https://github.com/elastic/kibana/actions/runs/16748013192 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
bartoval
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
|
|
||
| export const SOURCE_COMMANDS = new Set<string>(['FROM', 'ROW', 'SHOW', 'TS', 'EXPLAIN']); | ||
|
|
||
| export const PROCESSING_COMMANDS = new Set<string>([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something but I was wondering if it wouldn't be better to try to have a single source of truth, perhaps using information in our esqlCommandRegistry
example:
export const SOURCE_COMMANDS = .....
export const PROCESSING_COMMANDS = new Set<string>(
esqlCommandRegistry.getAllCommandNames()
.map(name => name.toUpperCase())
.filter(name => !SOURCE_COMMANDS.has(name)) // or just map all commands and remove this line
);
export const COMMANDS = ....;```There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this is a good idea. I was also wondering if we can get this info from ANTLR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can extract the keywords from the lexer, I'll take a look. Loading the whole command registry only for command keywords seems too expensive, and should be handled on the lower-level somewhere in the parser, imo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
## Summary The `LeafPrinter` escapes identifiers only when needed, for example, when they contain special characters. However, it must also escape ES|QL **keywords**, which it did not. Fixes a bug where the `LeafPrinter` would not escape identifiers which match ES|QL keywords. ### Checklist - [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
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary The `LeafPrinter` escapes identifiers only when needed, for example, when they contain special characters. However, it must also escape ES|QL **keywords**, which it did not. Fixes a bug where the `LeafPrinter` would not escape identifiers which match ES|QL keywords. ### Checklist - [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 (cherry picked from commit 04973b1) # Conflicts: # src/platform/packages/shared/kbn-esql-ast/src/parser/constants.ts
## Summary The `LeafPrinter` escapes identifiers only when needed, for example, when they contain special characters. However, it must also escape ES|QL **keywords**, which it did not. Fixes a bug where the `LeafPrinter` would not escape identifiers which match ES|QL keywords. ### Checklist - [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 (cherry picked from commit 04973b1) # Conflicts: # src/platform/packages/shared/kbn-esql-ast/src/parser/constants.ts
|
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
# Backport This will backport the following commits from `main` to `9.1`: - [[ES|QL] Escape keywords in identifier priting (#230491)](#230491) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Vadim Kibana","email":"82822460+vadimkibana@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-08-05T10:53:34Z","message":"[ES|QL] Escape keywords in identifier priting (#230491)\n\n## Summary\n\nThe `LeafPrinter` escapes identifiers only when needed, for example,\nwhen they contain special characters. However, it must also escape ES|QL\n**keywords**, which it did not. Fixes a bug where the `LeafPrinter`\nwould not escape identifiers which match ES|QL keywords.\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"04973b1c8de46f84d47f5946a27be7c425e0f3e8","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","review","release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[ES|QL] Escape keywords in identifier priting","number":230491,"url":"https://github.com/elastic/kibana/pull/230491","mergeCommit":{"message":"[ES|QL] Escape keywords in identifier priting (#230491)\n\n## Summary\n\nThe `LeafPrinter` escapes identifiers only when needed, for example,\nwhen they contain special characters. However, it must also escape ES|QL\n**keywords**, which it did not. Fixes a bug where the `LeafPrinter`\nwould not escape identifiers which match ES|QL keywords.\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"04973b1c8de46f84d47f5946a27be7c425e0f3e8"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/230491","number":230491,"mergeCommit":{"message":"[ES|QL] Escape keywords in identifier priting (#230491)\n\n## Summary\n\nThe `LeafPrinter` escapes identifiers only when needed, for example,\nwhen they contain special characters. However, it must also escape ES|QL\n**keywords**, which it did not. Fixes a bug where the `LeafPrinter`\nwould not escape identifiers which match ES|QL keywords.\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"04973b1c8de46f84d47f5946a27be7c425e0f3e8"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
# Backport This will backport the following commits from `main` to `8.19`: - [[ES|QL] Escape keywords in identifier priting (#230491)](#230491) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Vadim Kibana","email":"82822460+vadimkibana@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-08-05T10:53:34Z","message":"[ES|QL] Escape keywords in identifier priting (#230491)\n\n## Summary\n\nThe `LeafPrinter` escapes identifiers only when needed, for example,\nwhen they contain special characters. However, it must also escape ES|QL\n**keywords**, which it did not. Fixes a bug where the `LeafPrinter`\nwould not escape identifiers which match ES|QL keywords.\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"04973b1c8de46f84d47f5946a27be7c425e0f3e8","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","review","release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[ES|QL] Escape keywords in identifier priting","number":230491,"url":"https://github.com/elastic/kibana/pull/230491","mergeCommit":{"message":"[ES|QL] Escape keywords in identifier priting (#230491)\n\n## Summary\n\nThe `LeafPrinter` escapes identifiers only when needed, for example,\nwhen they contain special characters. However, it must also escape ES|QL\n**keywords**, which it did not. Fixes a bug where the `LeafPrinter`\nwould not escape identifiers which match ES|QL keywords.\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"04973b1c8de46f84d47f5946a27be7c425e0f3e8"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/230491","number":230491,"mergeCommit":{"message":"[ES|QL] Escape keywords in identifier priting (#230491)\n\n## Summary\n\nThe `LeafPrinter` escapes identifiers only when needed, for example,\nwhen they contain special characters. However, it must also escape ES|QL\n**keywords**, which it did not. Fixes a bug where the `LeafPrinter`\nwould not escape identifiers which match ES|QL keywords.\n\n\n### Checklist\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios","sha":"04973b1c8de46f84d47f5946a27be7c425e0f3e8"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
## Summary The `LeafPrinter` escapes identifiers only when needed, for example, when they contain special characters. However, it must also escape ES|QL **keywords**, which it did not. Fixes a bug where the `LeafPrinter` would not escape identifiers which match ES|QL keywords. ### Checklist - [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
Summary
The
LeafPrinterescapes identifiers only when needed, for example, when they contain special characters. However, it must also escape ES|QL keywords, which it did not. Fixes a bug where theLeafPrinterwould not escape identifiers which match ES|QL keywords.Checklist