Skip to content
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

[8.15] [ES|QL] Improve support for Invoke completion trigger kind (#188877) #189438

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

drewdaemon
Copy link
Contributor

Backport

This will backport the following commits from main to 8.15:

Questions ?

Please refer to the Backport tool documentation

…#188877)

## Summary

Resolve elastic#188677

This PR extends our support for Monaco's "Invoke" completion trigger
kind
([ref](https://microsoft.github.io/monaco-editor/typedoc/enums/languages.CompletionTriggerKind.html)).

What this means for the user is that suggestions are now shown when the
user types a character in a word even if the suggestion menu isn't
already open. This situation often occurs when the user is editing a
query. For example, they may follow a flow like this:

1. `FROM my-index | LIMIT 10<cursor-here>`
2. `FROM <cursor-here> | LIMIT 10` (deleted the index name)
3. `FROM k<cursor-here> | LIMIT 10` (types the first character of the
index name)

Previously, they wouldn't get any help. Now, we show the list of
suggestions.

The following table shows the cases that I considered as well as the
ones that are now fixed. I also added test coverage, even for cases that
worked before to prevent subtle regressions.

| | Before | After |

|------------------------------|------------------------------------------|-----------------------|
| Source command | ✅ | ✅ |
| Pipe command | ❌ | ✅ |
| Function argument | ✅ | ✅ |
| FROM source | ❌ | ✅ |
| FROM source METADATA | ✅ | ✅ |
| FROM source METADATA field | ❌ (for `_`) | ✅ |
| EVAL argument | ✅ | ✅ |
| DISSECT field | ✅ | ✅ |
| DISSECT field pattern | ❌ | ❌ |
| DROP field | ✅ | ✅ |
| DROP field1, field2 | ❌ | ✅ |
| ENRICH policy | ✅ | ✅ |
| ENRICH policy ON | ✅ | ✅ |
| ENRICH policy ON field | ✅ | ✅ |
| ENRICH policy WITH | ✅ | ✅ |
| ENRICH policy WITH field | ✅ | ✅ |
| GROK field | ✅ | ✅ |
| GROK field pattern | ❌ | ❌ |
| KEEP field | ✅ | ✅ |
| KEEP field1, field2 | ❌ | ✅ |
| LIMIT number | ❌ | ❌ |
| MV_EXPAND field | ✅ | ✅ |
| RENAME field | ✅ | ✅ |
| RENAME field AS | ❌ | ✅ |
| RENAME field AS var0 | ✅ | ✅ |
| SORT field | ✅ | ✅ |
| SORT field order | ✅ | ✅ |
| SORT field order nulls-order | ✅ | ✅ |
| STATS argument | ✅ | ✅ |
| STATS argument BY | ✅ | ✅ |
| STATS argument BY expression | ✅ | ✅ |
| WHERE argument | ✅ | ✅ |
| WHERE argument comparison    | ✅  | ✅                     |

As I worked, I encountered a couple small bugs which I also fixed.

### Escaping field values in `ENRICH`

**Before**

https://github.com/user-attachments/assets/88f2bf35-a703-4cf4-8d45-a24452a1b59d

**After**

https://github.com/user-attachments/assets/69ad0770-f158-44fb-be8d-66b497c7f7f7

### Suggesting variable assignment in `ENRICH ... WITH`
**Before**

https://github.com/user-attachments/assets/fec47b6d-eae5-44e8-b739-9b2eecc7458b

**After**

https://github.com/user-attachments/assets/dff5afe1-37e7-470b-bb9c-edb5ac87e76d

### 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

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit c77cd80)

# Conflicts:
#	packages/kbn-esql-validation-autocomplete/src/autocomplete/__tests__/autocomplete.command.stats.test.ts
#	packages/kbn-esql-validation-autocomplete/src/autocomplete/autocomplete.test.ts
@kibana-ci
Copy link
Collaborator

💚 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.2MB 3.2MB +253.0B

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@drewdaemon drewdaemon merged commit b8b6489 into elastic:8.15 Jul 29, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants