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

[ES|QL] separate STATS autocomplete routine #198224

Merged

Conversation

drewdaemon
Copy link
Contributor

@drewdaemon drewdaemon commented Oct 29, 2024

Summary

Part of #195418

This PR moves the STATS completion logic to its own home.

There are also a few changes in behavior. I am open for feedback on any of these.

  • the cursor is automatically advanced after accepting a comma suggestion
  • variables from previous EVAL commands are no longer suggested (e.g. ...| EVAL foo = 1 | STATS /). I'm not sure about this change, but it seemed potentially unintended to suggest variables but no other columns such as field names.
  • a new variable is suggested for new expressions in the BY clause. Formerly, new variables were only suggested in the STATS clause.
  • + and - are no longer suggested after a completed function call within an assignment in the BY clause (e.g. ... | STATS ... BY var1 = BUCKET(dateField, 1 day) /. This behavior was encoded in our tests, but it feels unintended to me, especially since it only applied when the result of the function was assigned to a new variable in the BY clause.

Checklist

@drewdaemon drewdaemon added Feature:ES|QL ES|QL related features in Kibana Team:ESQL ES|QL related features in Kibana release_note:skip Skip the PR/issue when compiling release notes v9.0.0 backport:version Backport to applied version labels v8.17.0 labels Oct 31, 2024
@drewdaemon drewdaemon changed the title [ES|QL] separate STATS and WHERE autocomplete routines [ES|QL] separate STATS autocomplete routine Oct 31, 2024
@drewdaemon drewdaemon marked this pull request as ready for review November 1, 2024 02:40
@drewdaemon drewdaemon requested a review from a team as a code owner November 1, 2024 02:40
@elasticmachine
Copy link
Contributor

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

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.

It looks great and very clean. Just some comments for the changes in the behavior from me and a small bug

Copy link
Contributor

Choose a reason for hiding this comment

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

variables from previous EVAL commands are no longer suggested (e.g. ...| EVAL foo = 1 | STATS /).

I really think we want this. A user will create an eval variable to use it in stats. Is a very common scenario. Think about date buckets or variables with case.

image
  • If I write the variable on my own now, the suggestions seem wrong
image

All the other decisions seem ok to me 👍

Copy link
Contributor Author

@drewdaemon drewdaemon Nov 1, 2024

Choose a reason for hiding this comment

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

Thanks @stratoula

variables from previous EVAL commands are no longer suggested (e.g. ...| EVAL foo = 1 | STATS /).

I really think we want this. A user will create an eval variable to use it in stats. Is a very common scenario. Think about date buckets or variables with case.

Just to make sure I understand—

  • we want only variables (no fields) in STATS /
  • but we want variables and fields in STATS … BY /

Is that what you are saying?

If I write the variable on my own now, the suggestions seem wrong

From what I can see, this is no change in behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

Synced offline, I misunderstood the behavior described. We are good

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 6144 6146 +2
unifiedSearch 359 361 +2
total +4

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.4MB 3.4MB +580.0B

History

@drewdaemon drewdaemon merged commit 7f2b56f into elastic:main Nov 1, 2024
21 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 1, 2024
## Summary

Part of elastic#195418

This PR moves the `STATS` completion logic to its own home.

There are also a few changes in behavior. I am open for feedback on any
of these.
- the cursor is automatically advanced after accepting a comma
suggestion
- variables from previous `EVAL` commands are no longer suggested (e.g.
`...| EVAL foo = 1 | STATS /`). I'm not sure about this change, but it
seemed potentially unintended to suggest variables but no other columns
such as field names.
- a new variable is suggested for new expressions in the `BY` clause.
Formerly, new variables were only suggested in the `STATS` clause.
- `+` and `-` are no longer suggested after a completed function call
within an assignment in the `BY` clause (e.g. `... | STATS ... BY var1 =
BUCKET(dateField, 1 day) /`. This behavior was encoded in our tests, but
it feels unintended to me, especially since it only applied when the
result of the function was assigned to a new variable in the `BY`
clause.

### 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: Stratoula Kalafateli <[email protected]>
(cherry picked from commit 7f2b56f)
@kibanamachine
Copy link
Contributor

💚 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 Nov 1, 2024
… (#198693)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ES|QL] separate &#x60;STATS&#x60; autocomplete routine
(#198224)](#198224)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Drew
Tate","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-01T15:11:05Z","message":"[ES|QL]
separate `STATS` autocomplete routine (#198224)\n\n##
Summary\r\n\r\nPart of
https://github.com/elastic/kibana/issues/195418\r\n\r\nThis PR moves the
`STATS` completion logic to its own home.\r\n\r\nThere are also a few
changes in behavior. I am open for feedback on any\r\nof these.\r\n- the
cursor is automatically advanced after accepting a
comma\r\nsuggestion\r\n- variables from previous `EVAL` commands are no
longer suggested (e.g.\r\n`...| EVAL foo = 1 | STATS /`). I'm not sure
about this change, but it\r\nseemed potentially unintended to suggest
variables but no other columns\r\nsuch as field names.\r\n- a new
variable is suggested for new expressions in the `BY`
clause.\r\nFormerly, new variables were only suggested in the `STATS`
clause.\r\n- `+` and `-` are no longer suggested after a completed
function call\r\nwithin an assignment in the `BY` clause (e.g. `... |
STATS ... BY var1 =\r\nBUCKET(dateField, 1 day) /`. This behavior was
encoded in our tests, but\r\nit feels unintended to me, especially since
it only applied when the\r\nresult of the function was assigned to a new
variable in the `BY`\r\nclause.\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\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<[email protected]>","sha":"7f2b56f0e687d466c20127d358d25a0456e51a03","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Feature:ES|QL","Team:ESQL","backport:version","v8.17.0"],"title":"[ES|QL]
separate `STATS` autocomplete
routine","number":198224,"url":"https://github.com/elastic/kibana/pull/198224","mergeCommit":{"message":"[ES|QL]
separate `STATS` autocomplete routine (#198224)\n\n##
Summary\r\n\r\nPart of
https://github.com/elastic/kibana/issues/195418\r\n\r\nThis PR moves the
`STATS` completion logic to its own home.\r\n\r\nThere are also a few
changes in behavior. I am open for feedback on any\r\nof these.\r\n- the
cursor is automatically advanced after accepting a
comma\r\nsuggestion\r\n- variables from previous `EVAL` commands are no
longer suggested (e.g.\r\n`...| EVAL foo = 1 | STATS /`). I'm not sure
about this change, but it\r\nseemed potentially unintended to suggest
variables but no other columns\r\nsuch as field names.\r\n- a new
variable is suggested for new expressions in the `BY`
clause.\r\nFormerly, new variables were only suggested in the `STATS`
clause.\r\n- `+` and `-` are no longer suggested after a completed
function call\r\nwithin an assignment in the `BY` clause (e.g. `... |
STATS ... BY var1 =\r\nBUCKET(dateField, 1 day) /`. This behavior was
encoded in our tests, but\r\nit feels unintended to me, especially since
it only applied when the\r\nresult of the function was assigned to a new
variable in the `BY`\r\nclause.\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\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<[email protected]>","sha":"7f2b56f0e687d466c20127d358d25a0456e51a03"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/198224","number":198224,"mergeCommit":{"message":"[ES|QL]
separate `STATS` autocomplete routine (#198224)\n\n##
Summary\r\n\r\nPart of
https://github.com/elastic/kibana/issues/195418\r\n\r\nThis PR moves the
`STATS` completion logic to its own home.\r\n\r\nThere are also a few
changes in behavior. I am open for feedback on any\r\nof these.\r\n- the
cursor is automatically advanced after accepting a
comma\r\nsuggestion\r\n- variables from previous `EVAL` commands are no
longer suggested (e.g.\r\n`...| EVAL foo = 1 | STATS /`). I'm not sure
about this change, but it\r\nseemed potentially unintended to suggest
variables but no other columns\r\nsuch as field names.\r\n- a new
variable is suggested for new expressions in the `BY`
clause.\r\nFormerly, new variables were only suggested in the `STATS`
clause.\r\n- `+` and `-` are no longer suggested after a completed
function call\r\nwithin an assignment in the `BY` clause (e.g. `... |
STATS ... BY var1 =\r\nBUCKET(dateField, 1 day) /`. This behavior was
encoded in our tests, but\r\nit feels unintended to me, especially since
it only applied when the\r\nresult of the function was assigned to a new
variable in the `BY`\r\nclause.\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\r\n\r\n---------\r\n\r\nCo-authored-by: Stratoula Kalafateli
<[email protected]>","sha":"7f2b56f0e687d466c20127d358d25a0456e51a03"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Drew Tate <[email protected]>
nreese pushed a commit to nreese/kibana that referenced this pull request Nov 1, 2024
## Summary

Part of elastic#195418

This PR moves the `STATS` completion logic to its own home.

There are also a few changes in behavior. I am open for feedback on any
of these.
- the cursor is automatically advanced after accepting a comma
suggestion
- variables from previous `EVAL` commands are no longer suggested (e.g.
`...| EVAL foo = 1 | STATS /`). I'm not sure about this change, but it
seemed potentially unintended to suggest variables but no other columns
such as field names.
- a new variable is suggested for new expressions in the `BY` clause.
Formerly, new variables were only suggested in the `STATS` clause.
- `+` and `-` are no longer suggested after a completed function call
within an assignment in the `BY` clause (e.g. `... | STATS ... BY var1 =
BUCKET(dateField, 1 day) /`. This behavior was encoded in our tests, but
it feels unintended to me, especially since it only applied when the
result of the function was assigned to a new variable in the `BY`
clause.

### 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: Stratoula Kalafateli <[email protected]>
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 Feature:ES|QL ES|QL related features in Kibana release_note:skip Skip the PR/issue when compiling release notes Team:ESQL ES|QL related features in Kibana v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants