[ES|QL] Stop ANTLR token monkey-patching in parser#225629
[ES|QL] Stop ANTLR token monkey-patching in parser#225629vadimkibana merged 3 commits intoelastic:mainfrom
Conversation
|
/ci |
|
Pinging @elastic/kibana-esql (Team:ESQL) |
|
Starting backport for target branches: 8.19, 9.1 https://github.com/elastic/kibana/actions/runs/16001261032 |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
|
## Summary A small cleanup in parser code in the ES|QL AST package. We want to show users readable syntax error token names like `[` and `(` (instead of `LP`), however, we should not monkey-patch ANTLR generated files to achieve this. Instead, this PR moves the message improvement code to the validation & autocomplete package, where the messages are actually used. ### 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 750cc7c)
## Summary A small cleanup in parser code in the ES|QL AST package. We want to show users readable syntax error token names like `[` and `(` (instead of `LP`), however, we should not monkey-patch ANTLR generated files to achieve this. Instead, this PR moves the message improvement code to the validation & autocomplete package, where the messages are actually used. ### 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 750cc7c)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…226010) # Backport This will backport the following commits from `main` to `8.19`: - [[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)](#225629) <!--- Backport version: 9.6.6 --> ### 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-07-01T13:50:01Z","message":"[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)\n\n## Summary\n\nA small cleanup in parser code in the ES|QL AST package. We want to show\nusers readable syntax error token names like `[` and `(` (instead of\n`LP`), however, we should not monkey-patch ANTLR generated files to\nachieve this. Instead, this PR moves the message improvement code to the\nvalidation & autocomplete package, where the messages are actually used.\n\n\n### Checklist\n\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":"750cc7c4c1b91f2713b97a27c89e07dadffbb816","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["review","release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[ES|QL] Stop ANTLR token monkey-patching in parser","number":225629,"url":"https://github.com/elastic/kibana/pull/225629","mergeCommit":{"message":"[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)\n\n## Summary\n\nA small cleanup in parser code in the ES|QL AST package. We want to show\nusers readable syntax error token names like `[` and `(` (instead of\n`LP`), however, we should not monkey-patch ANTLR generated files to\nachieve this. Instead, this PR moves the message improvement code to the\nvalidation & autocomplete package, where the messages are actually used.\n\n\n### Checklist\n\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":"750cc7c4c1b91f2713b97a27c89e07dadffbb816"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225629","number":225629,"mergeCommit":{"message":"[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)\n\n## Summary\n\nA small cleanup in parser code in the ES|QL AST package. We want to show\nusers readable syntax error token names like `[` and `(` (instead of\n`LP`), however, we should not monkey-patch ANTLR generated files to\nachieve this. Instead, this PR moves the message improvement code to the\nvalidation & autocomplete package, where the messages are actually used.\n\n\n### Checklist\n\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":"750cc7c4c1b91f2713b97a27c89e07dadffbb816"}}]}] BACKPORT--> Co-authored-by: Vadim Kibana <82822460+vadimkibana@users.noreply.github.com>
…226011) # Backport This will backport the following commits from `main` to `9.1`: - [[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)](#225629) <!--- Backport version: 9.6.6 --> ### 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-07-01T13:50:01Z","message":"[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)\n\n## Summary\n\nA small cleanup in parser code in the ES|QL AST package. We want to show\nusers readable syntax error token names like `[` and `(` (instead of\n`LP`), however, we should not monkey-patch ANTLR generated files to\nachieve this. Instead, this PR moves the message improvement code to the\nvalidation & autocomplete package, where the messages are actually used.\n\n\n### Checklist\n\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":"750cc7c4c1b91f2713b97a27c89e07dadffbb816","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["review","release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0","v9.2.0"],"title":"[ES|QL] Stop ANTLR token monkey-patching in parser","number":225629,"url":"https://github.com/elastic/kibana/pull/225629","mergeCommit":{"message":"[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)\n\n## Summary\n\nA small cleanup in parser code in the ES|QL AST package. We want to show\nusers readable syntax error token names like `[` and `(` (instead of\n`LP`), however, we should not monkey-patch ANTLR generated files to\nachieve this. Instead, this PR moves the message improvement code to the\nvalidation & autocomplete package, where the messages are actually used.\n\n\n### Checklist\n\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":"750cc7c4c1b91f2713b97a27c89e07dadffbb816"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/225629","number":225629,"mergeCommit":{"message":"[ES|QL] Stop ANTLR token monkey-patching in parser (#225629)\n\n## Summary\n\nA small cleanup in parser code in the ES|QL AST package. We want to show\nusers readable syntax error token names like `[` and `(` (instead of\n`LP`), however, we should not monkey-patch ANTLR generated files to\nachieve this. Instead, this PR moves the message improvement code to the\nvalidation & autocomplete package, where the messages are actually used.\n\n\n### Checklist\n\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":"750cc7c4c1b91f2713b97a27c89e07dadffbb816"}}]}] BACKPORT--> Co-authored-by: Vadim Kibana <82822460+vadimkibana@users.noreply.github.com>
|
We lost the literal tokens because of some grammar changes from Elasticsearch. Elasticsearch then added this substitution logic to their parser and I did the same to ours. I preferred it that way because it is fixing the bug at the level it was introduced (the parser). That said, I guess I have no strong objection to moving the substitutions to the validation level But I would like us to not lose the comment with the reference to the Elasticsearch change. That points us to their substitutions which we should probably strive to match. I will reinstate that link in a follow-up PR. |
Follow-on to elastic#225629 (cherry picked from commit 1abf412)
Follow-on to elastic#225629 (cherry picked from commit 1abf412)
## Summary A small cleanup in parser code in the ES|QL AST package. We want to show users readable syntax error token names like `[` and `(` (instead of `LP`), however, we should not monkey-patch ANTLR generated files to achieve this. Instead, this PR moves the message improvement code to the validation & autocomplete package, where the messages are actually used. ### 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
A small cleanup in parser code in the ES|QL AST package. We want to show users readable syntax error token names like
[and((instead ofLP), however, we should not monkey-patch ANTLR generated files to achieve this. Instead, this PR moves the message improvement code to the validation & autocomplete package, where the messages are actually used.Checklist