-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ES|QL] Fix autocomplete with incompatible args #180874
Conversation
Pinging @elastic/kibana-esql (Team:ESQL) |
Awesome—glad to see this. But, you may have to pull in |
Synced with |
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.
The original bug is definitely fixed. Many thanks for that.
I'm not so sure on the new suggestions. On the one hand, I like that they are another indicator of the type of the parameter.
On the other hand, I'm concerned they'll be difficult to interpret.
Take these number suggestions here

Does this mean that those are the only acceptable values? That's what the suggestions often mean, including when the user types mv_sort(field,
and gets asc
and desc
.
Why 10
, 20
, 30
? Are these good choices for bucket
? What about for other functions in the future?

Or here, where did this date come from? Why is it a good suggestion? Does it matter which of the two I pick?
Given this, I would prefer we scope this PR to the bugfix #180730 so we can get that in for 8.14.
We had a similar logic for
This is implementing a similar logic as in formula absolute time shift. But here I've limited to the current time rather than propose any possible shift. I can see how this is a bit more opinionated, but while testing it I found it convenient as a quick placeholder rather than typing the full ISO date manually. |
The problem with removing the suggestions is that without them it feels the autocomplete is broken as nothing will be then suggested for those argument, as with the fix the |
I see what you mean. We suggest for pretty much everything else, so this is more jarring. But is it the end of the world? The user still has the inline documentation. The validation is still correct. I'm not saying that constant suggestions are a bad idea. I'm just saying, why not take them as an enhancement request separate from this bugfix that we want in 8.14? That way, we can have time to evaluate the request, and if we decide to add, we can think through the cases and add them with some polish. I think that there are other solutions to this problem as well. For example, #180528 would also address this, by giving the user a suggestion of the data type, if not the actual values. But, cc @stratoula for a second opinion. |
I've implemented the signature help in the past (another issue here) - it's just 3 lines of code - and it doesn't solve the problem as it's only available for multiline editor (due to #166085 ). |
Synced offline and decided with @stratoula and @dej611 to pursue the |
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.
Works great in the browser but I think the tests are passing by accident.

You can see the problem by adding a conditional breakpoint (statement === 'from a | eval st_intersects(field, )'
) at autocomplete.test.ts:253
.
The expected suggestions should be scoped down to either cartesian or geo points but instead we expect everything. The reason the test passes is that it generates no suggestions []
.
All the assertions are nested in a for
loop on suggestions
so it being empty causes no assertions to be run. That makes the test pass.
We should probably
- update the expected suggestions to be correct
- figure out why the
suggest
fn is returning an empty array - add an array length assertion so that we don't get any more of these quiet failures
Another kind of strange thing (maybe not related to the PR) is that when I add a second comma, I get a list of everything as a suggestion
Screen.Recording.2024-04-18.at.7.59.05.AM.mov
// @TODO: improve this to inherit the constant flag from the outer function | ||
functions: !shouldBeConstant, | ||
fields: !shouldBeConstant, | ||
variables: variablesExcludingCurrentCommandOnes, | ||
literals: shouldBeConstant, |
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.
Leftover?
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.
No, I think it still makes sense to pass it down.
const shouldBeConstant = validSignatures.some(({ params }) => params[argIndex]?.constantOnly); | ||
|
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.
Leftover?
Good catch. Will fix it. |
Addressed all issues raised. |
The bug is in the test, as the passed
It depends on the time frame and how much it would be quick to be defined and added. |
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.
Okay, I will fix the test in another PR. Thanks!
💚 Build Succeeded
Metrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: |
## Summary Fixes elastic#180730 I've improved the autocomplete logic a bit here with the new features from `main`: * the `constantOnly` check has been pushed down rather than depend on an empty string * autosuggestion takes into account the previous argument types now to propose the next one ### 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 eadc173)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…1289) # Backport This will backport the following commits from `main` to `8.14`: - [[ES|QL] Fix autocomplete with incompatible args (#180874)](#180874) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Marco Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-04-22T10:35:29Z","message":"[ES|QL] Fix autocomplete with incompatible args (#180874)\n\n## Summary\r\n\r\nFixes #180730\r\n\r\nI've improved the autocomplete logic a bit here with the new features\r\nfrom `main`:\r\n* the `constantOnly` check has been pushed down rather than depend on an\r\nempty string\r\n* autosuggestion takes into account the previous argument types now to\r\npropose the next one\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"eadc173ba23e44ed30e3dcfdf8b3b01c683b9358","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport:prev-minor","Feature:ES|QL","v8.14.0","Team:ESQL","v8.15.0"],"title":"[ES|QL] Fix autocomplete with incompatible args","number":180874,"url":"https://github.com/elastic/kibana/pull/180874","mergeCommit":{"message":"[ES|QL] Fix autocomplete with incompatible args (#180874)\n\n## Summary\r\n\r\nFixes #180730\r\n\r\nI've improved the autocomplete logic a bit here with the new features\r\nfrom `main`:\r\n* the `constantOnly` check has been pushed down rather than depend on an\r\nempty string\r\n* autosuggestion takes into account the previous argument types now to\r\npropose the next one\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"eadc173ba23e44ed30e3dcfdf8b3b01c683b9358"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/180874","number":180874,"mergeCommit":{"message":"[ES|QL] Fix autocomplete with incompatible args (#180874)\n\n## Summary\r\n\r\nFixes #180730\r\n\r\nI've improved the autocomplete logic a bit here with the new features\r\nfrom `main`:\r\n* the `constantOnly` check has been pushed down rather than depend on an\r\nempty string\r\n* autosuggestion takes into account the previous argument types now to\r\npropose the next one\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"eadc173ba23e44ed30e3dcfdf8b3b01c683b9358"}}]}] BACKPORT--> Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
Summary
Fixes #180730
I've improved the autocomplete logic a bit here with the new features from
main
:constantOnly
check has been pushed down rather than depend on an empty stringChecklist