-
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] Separate EVAL
autocomplete routine
#212996
Conversation
Pinging @elastic/kibana-esql (Team:ESQL) |
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.
This looks nice, I have added some questions to understand better some decisions
@@ -1036,6 +1037,8 @@ describe('autocomplete', () => { | |||
'AND $0', | |||
'NOT', | |||
'OR $0', | |||
', ', |
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.
Why comma and pipe got added here?
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.
"IS NOT N" gets parsed into our AST as a complete "IS NOT NULL" (see #199401). Because the AST is complete, it detects this as a complete expression.
I don't think it will matter to the user, but I will double check.
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.
Ok I guess I do need to fix this
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.
Done in 0e6fc40
I realized this was an existing bug in WHERE
too, so they're both fixed now.
// e.g. CASE(field != /) | ||
// | ||
// So, it is handled as a special branch... | ||
if ( |
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.
Can this branch be moved inside the eval autocomplete as it is an eval function?
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.
I will check... I'm pretty sure you can use it other places.
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.
I do agree that this is not a good long-term home for it but this is actually where it was before. It was just hidden in the generic code. I am doing some thinking about the role of function suggestion routines in relation to the command functions.
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.
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.
Mmmm I see 🤔 Yes leave it there but we need to rethink it in the future
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.
I agree. Consider this refactor in flux...
commandName: 'eval', | ||
}); | ||
|
||
// EVAL-specific stuff |
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.
Don't get this comment here
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.
I got it, these are the code that eval does differently 👍
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.
Done in 0e6fc40
|
||
break; | ||
} | ||
// WHERE-specific stuff |
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.
Same here 🤔
Update: This is where you differentiate where 👍
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.
I'll remove the comment. I think it is confusing—you're already in where/index.ts
—of course it is WHERE-specific
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 and the eval too, I think this is why I got confused in the first place
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.
Done in 0e6fc40
|
||
break; | ||
|
||
case 'empty_expression': |
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.
So I understand that this is a very common code between eval and where and why we decided to move everything in one helper. But we still need to differentiate between where and eval as there are functions that do not exist in eval. I wonder if we can keep the split here and share code only when necessary. Wdyt?
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.
Sure, I'm open to duplicating the contents of this function between WHERE
and EVAL
if that's what you mean?
The reasons I was thinking a shared function with customization through arguments were
- suggestions within an expression (by "expression" I mean some values plus some operators) are not very different between the two commands
- having a shared function will make it easier to extend this functionality to other expressions within ES|QL
For example, ES|QL allows expressions in
- SORT
- STATS ... BY
- STATS ... WHERE
- within function parameters
We don't currently give help in any of the above contexts, with the exception of the first argument in CASE
. We know we want to extend to STATS...WHERE
and we may want to extend to more of these.
Let me know what you want me to do.
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.
There are yes and I understand why you decided to go that way. It is just the fact that there will always be some differences:
- STATS ... WHERE doesnt support full text search
- SORT neither
- EVAL has a functionality that doesnt exist in WHERE etc
- How will this look as the language will evolve? More if else? I don't know, I am mostly wondering if this approach will suit us or we will need to change it in the future
I wasn't really suggesting to duplicate everything. I was just wondering if maybe we can share code but have the differences to be set in the distinct code. So for example:
- search functions and the match operator is a where thingy. Can we set them up in the where code and pass it to the shared one in order to make the shared a bit more generic?
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.
Ok then we are on the same page. I agree that the commands should be able to configure expression suggestion behavior based on context and we can do this better than it is happening now. For example, have the suggestion routines build a set of configuration parameters that they pass to the expression suggestions function
getExpressionSuggestions(... {
suggestFunctions: () => { only suggest functions supported in this context },
preferredExpressionType: 'boolean'...
})
In a similar vein we should definitely
- clean up the "function argument suggestions function" as well—it is littered with special cases and command awareness, etc.,
- possibly put function suggestions within the command routines instead of as its own separate top-level branch
- get the editor marker under control
- remove options and settings and other defunct stuff
But I want to scope this PR to just moving EVAL
stuff to its own place. When I start diving into side-quests in these PRs (for example, removing all command-awareness from all the sub functions in getExpressionSuggestions), they tend to get very unmanageable. I know the file counts aren’t large here, but untangling the logic is very complicated.
So, I agree with your direction and I want to clean up more, but I would rather focus here on first putting per-command boundaries on the craziness. 🤪
Now that we actually know what all this logic does, we can evolve it however we need to with very little refactoring
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.
ok I am fine with it
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.
You'll like what you see when I take care of #209359
@@ -243,6 +245,7 @@ export const commandDefinitions: Array<CommandDefinition<any>> = [ | |||
modes: [], | |||
// Reusing the same validation logic as stats command | |||
validate: statsValidator, | |||
suggest: suggestForStats, |
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.
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.
Thanks... actually what is the status of inlinestats
? I don't see it in our docs...
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.
Inlinestats is paused atm in favor of joins. Let's remove it the suggest here and deal with it when inlinestats is back in the roadmap.
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.
Done in 0e6fc40
src/platform/packages/shared/kbn-esql-validation-autocomplete/src/definitions/types.ts
Show resolved
Hide resolved
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
Unreferenced deprecated APIs
History
|
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.
Looks nice,k thanx for addressing the comments and the brainstorming
@@ -1008,10 +1009,6 @@ describe('autocomplete', () => { | |||
'AND $0', | |||
'NOT', | |||
'OR $0', | |||
// pipe doesn't make sense here, but Monaco will filter it out. |
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.
Nice
Starting backport for target branches: 8.x |
## Summary Part of elastic#195418 Gives `EVAL` autocomplete logic its own home 🏡 ### Expression suggestions function This PR also introduces a semi-generic function for generating suggestions within an expression. This is so that the logic can be shared between `EVAL` and `WHERE`. It also gets us closer to supporting filtering in `STATS` (elastic#195363). To make this happen, I took stock of where we have differences in our expression suggestions between `WHERE` and `EVAL`. In some cases, the differences seemed important. In other cases, I felt ok removing them. #### EVAL | Behavior | Plan | |--------------------------------------------------------------------------|------| | Suggests pipe and comma after complete column names (`column/` or `column /`)| get rid of it because an expression consisting of just a single column name is essentially useless in `EVAL` | | Doesn't suggest fields after an assignment | get rid of it. why act any different than an expression not assigned an alias? | | Suggests assignment operator after new column name (`newColumn /`) | keep it | | Suggests assignment snippet for empty expression | keep it | | Suggests time literal completions after literal number in assignment (`newColumn = 1 /`) | remove it. it doesn't feel that useful and removing it makes it easier to have a generic expression suggestions function. It will still be around in functions and operators (e.g. `1 day + 2 /`). | | Supports multiple expressions | keep it | #### WHERE | Behavior | Plan | |--------------------------------------------------------------------------|------| | Suggests pipe after complete boolean expression (`foo AND bar /`) | keep it, but outside of the expression suggestion function | | Suggests boolean operators to make a boolean expression (`timestamp > "2002" AND doubleField /`) | keep it... maybe we're being too smart but we can always remove it later | ### Other changes - the suggestions for `CASE(foo != /)` used to differ based on the trigger kind. This seemed inadvertent so I removed the difference. - we now add spaces after fields that are inserted in expressions. E.g. `WHERE foo + <insert field><space>`. I'm not sure if this is best or not... ### 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 ### Identify risks - [ ] As with any refactor, there's a possibility this will introduce a regression in the behavior of commands. However, all automated tests are passing and I have tested the behavior manually and can detect no regression. --------- Co-authored-by: Stratoula Kalafateli <[email protected]> Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 74c31fb)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
# Backport This will backport the following commits from `main` to `8.x`: - [[ES|QL] Separate `EVAL` autocomplete routine (#212996)](#212996) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Drew Tate","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-18T12:24:50Z","message":"[ES|QL] Separate `EVAL` autocomplete routine (#212996)\n\n## Summary\n\nPart of https://github.com/elastic/kibana/issues/195418\n\nGives `EVAL` autocomplete logic its own home 🏡\n\n\n### Expression suggestions function\n\nThis PR also introduces a semi-generic function for generating\nsuggestions within an expression. This is so that the logic can be\nshared between `EVAL` and `WHERE`. It also gets us closer to supporting\nfiltering in `STATS` (https://github.com/elastic/kibana/issues/195363).\n\nTo make this happen, I took stock of where we have differences in our\nexpression suggestions between `WHERE` and `EVAL`. In some cases, the\ndifferences seemed important. In other cases, I felt ok removing them.\n\n#### EVAL\n\n| Behavior | Plan |\n\n|--------------------------------------------------------------------------|------|\n| Suggests pipe and comma after complete column names (`column/` or\n`column /`)| get rid of it because an expression consisting of just a\nsingle column name is essentially useless in `EVAL` |\n| Doesn't suggest fields after an assignment | get rid of it. why act\nany different than an expression not assigned an alias? |\n| Suggests assignment operator after new column name (`newColumn /`) |\nkeep it |\n| Suggests assignment snippet for empty expression | keep it |\n| Suggests time literal completions after literal number in assignment\n(`newColumn = 1 /`) | remove it. it doesn't feel that useful and\nremoving it makes it easier to have a generic expression suggestions\nfunction. It will still be around in functions and operators (e.g. `1\nday + 2 /`). |\n| Supports multiple expressions | keep it |\n\n#### WHERE\n\n| Behavior | Plan |\n\n|--------------------------------------------------------------------------|------|\n| Suggests pipe after complete boolean expression (`foo AND bar /`) |\nkeep it, but outside of the expression suggestion function |\n| Suggests boolean operators to make a boolean expression (`timestamp >\n\"2002\" AND doubleField /`) | keep it... maybe we're being too smart but\nwe can always remove it later |\n\n### Other changes\n- the suggestions for `CASE(foo != /)` used to differ based on the\ntrigger kind. This seemed inadvertent so I removed the difference.\n- we now add spaces after fields that are inserted in expressions. E.g.\n`WHERE foo + <insert field><space>`. I'm not sure if this is best or\nnot...\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\n\n### Identify risks\n\n- [ ] As with any refactor, there's a possibility this will introduce a\nregression in the behavior of commands. However, all automated tests are\npassing and I have tested the behavior manually and can detect no\nregression.\n\n---------\n\nCo-authored-by: Stratoula Kalafateli <[email protected]>\nCo-authored-by: Elastic Machine <[email protected]>","sha":"74c31fbc862a1e26871f46802d0f9e9869c3d296","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Feature:ES|QL","Team:ESQL","backport:version","v9.1.0","v8.19.0"],"title":"[ES|QL] Separate `EVAL` autocomplete routine","number":212996,"url":"https://github.com/elastic/kibana/pull/212996","mergeCommit":{"message":"[ES|QL] Separate `EVAL` autocomplete routine (#212996)\n\n## Summary\n\nPart of https://github.com/elastic/kibana/issues/195418\n\nGives `EVAL` autocomplete logic its own home 🏡\n\n\n### Expression suggestions function\n\nThis PR also introduces a semi-generic function for generating\nsuggestions within an expression. This is so that the logic can be\nshared between `EVAL` and `WHERE`. It also gets us closer to supporting\nfiltering in `STATS` (https://github.com/elastic/kibana/issues/195363).\n\nTo make this happen, I took stock of where we have differences in our\nexpression suggestions between `WHERE` and `EVAL`. In some cases, the\ndifferences seemed important. In other cases, I felt ok removing them.\n\n#### EVAL\n\n| Behavior | Plan |\n\n|--------------------------------------------------------------------------|------|\n| Suggests pipe and comma after complete column names (`column/` or\n`column /`)| get rid of it because an expression consisting of just a\nsingle column name is essentially useless in `EVAL` |\n| Doesn't suggest fields after an assignment | get rid of it. why act\nany different than an expression not assigned an alias? |\n| Suggests assignment operator after new column name (`newColumn /`) |\nkeep it |\n| Suggests assignment snippet for empty expression | keep it |\n| Suggests time literal completions after literal number in assignment\n(`newColumn = 1 /`) | remove it. it doesn't feel that useful and\nremoving it makes it easier to have a generic expression suggestions\nfunction. It will still be around in functions and operators (e.g. `1\nday + 2 /`). |\n| Supports multiple expressions | keep it |\n\n#### WHERE\n\n| Behavior | Plan |\n\n|--------------------------------------------------------------------------|------|\n| Suggests pipe after complete boolean expression (`foo AND bar /`) |\nkeep it, but outside of the expression suggestion function |\n| Suggests boolean operators to make a boolean expression (`timestamp >\n\"2002\" AND doubleField /`) | keep it... maybe we're being too smart but\nwe can always remove it later |\n\n### Other changes\n- the suggestions for `CASE(foo != /)` used to differ based on the\ntrigger kind. This seemed inadvertent so I removed the difference.\n- we now add spaces after fields that are inserted in expressions. E.g.\n`WHERE foo + <insert field><space>`. I'm not sure if this is best or\nnot...\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\n\n### Identify risks\n\n- [ ] As with any refactor, there's a possibility this will introduce a\nregression in the behavior of commands. However, all automated tests are\npassing and I have tested the behavior manually and can detect no\nregression.\n\n---------\n\nCo-authored-by: Stratoula Kalafateli <[email protected]>\nCo-authored-by: Elastic Machine <[email protected]>","sha":"74c31fbc862a1e26871f46802d0f9e9869c3d296"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212996","number":212996,"mergeCommit":{"message":"[ES|QL] Separate `EVAL` autocomplete routine (#212996)\n\n## Summary\n\nPart of https://github.com/elastic/kibana/issues/195418\n\nGives `EVAL` autocomplete logic its own home 🏡\n\n\n### Expression suggestions function\n\nThis PR also introduces a semi-generic function for generating\nsuggestions within an expression. This is so that the logic can be\nshared between `EVAL` and `WHERE`. It also gets us closer to supporting\nfiltering in `STATS` (https://github.com/elastic/kibana/issues/195363).\n\nTo make this happen, I took stock of where we have differences in our\nexpression suggestions between `WHERE` and `EVAL`. In some cases, the\ndifferences seemed important. In other cases, I felt ok removing them.\n\n#### EVAL\n\n| Behavior | Plan |\n\n|--------------------------------------------------------------------------|------|\n| Suggests pipe and comma after complete column names (`column/` or\n`column /`)| get rid of it because an expression consisting of just a\nsingle column name is essentially useless in `EVAL` |\n| Doesn't suggest fields after an assignment | get rid of it. why act\nany different than an expression not assigned an alias? |\n| Suggests assignment operator after new column name (`newColumn /`) |\nkeep it |\n| Suggests assignment snippet for empty expression | keep it |\n| Suggests time literal completions after literal number in assignment\n(`newColumn = 1 /`) | remove it. it doesn't feel that useful and\nremoving it makes it easier to have a generic expression suggestions\nfunction. It will still be around in functions and operators (e.g. `1\nday + 2 /`). |\n| Supports multiple expressions | keep it |\n\n#### WHERE\n\n| Behavior | Plan |\n\n|--------------------------------------------------------------------------|------|\n| Suggests pipe after complete boolean expression (`foo AND bar /`) |\nkeep it, but outside of the expression suggestion function |\n| Suggests boolean operators to make a boolean expression (`timestamp >\n\"2002\" AND doubleField /`) | keep it... maybe we're being too smart but\nwe can always remove it later |\n\n### Other changes\n- the suggestions for `CASE(foo != /)` used to differ based on the\ntrigger kind. This seemed inadvertent so I removed the difference.\n- we now add spaces after fields that are inserted in expressions. E.g.\n`WHERE foo + <insert field><space>`. I'm not sure if this is best or\nnot...\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\n\n### Identify risks\n\n- [ ] As with any refactor, there's a possibility this will introduce a\nregression in the behavior of commands. However, all automated tests are\npassing and I have tested the behavior manually and can detect no\nregression.\n\n---------\n\nCo-authored-by: Stratoula Kalafateli <[email protected]>\nCo-authored-by: Elastic Machine <[email protected]>","sha":"74c31fbc862a1e26871f46802d0f9e9869c3d296"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Drew Tate <[email protected]>
## Summary Part of elastic#195418 Gives `EVAL` autocomplete logic its own home 🏡 ### Expression suggestions function This PR also introduces a semi-generic function for generating suggestions within an expression. This is so that the logic can be shared between `EVAL` and `WHERE`. It also gets us closer to supporting filtering in `STATS` (elastic#195363). To make this happen, I took stock of where we have differences in our expression suggestions between `WHERE` and `EVAL`. In some cases, the differences seemed important. In other cases, I felt ok removing them. #### EVAL | Behavior | Plan | |--------------------------------------------------------------------------|------| | Suggests pipe and comma after complete column names (`column/` or `column /`)| get rid of it because an expression consisting of just a single column name is essentially useless in `EVAL` | | Doesn't suggest fields after an assignment | get rid of it. why act any different than an expression not assigned an alias? | | Suggests assignment operator after new column name (`newColumn /`) | keep it | | Suggests assignment snippet for empty expression | keep it | | Suggests time literal completions after literal number in assignment (`newColumn = 1 /`) | remove it. it doesn't feel that useful and removing it makes it easier to have a generic expression suggestions function. It will still be around in functions and operators (e.g. `1 day + 2 /`). | | Supports multiple expressions | keep it | #### WHERE | Behavior | Plan | |--------------------------------------------------------------------------|------| | Suggests pipe after complete boolean expression (`foo AND bar /`) | keep it, but outside of the expression suggestion function | | Suggests boolean operators to make a boolean expression (`timestamp > "2002" AND doubleField /`) | keep it... maybe we're being too smart but we can always remove it later | ### Other changes - the suggestions for `CASE(foo != /)` used to differ based on the trigger kind. This seemed inadvertent so I removed the difference. - we now add spaces after fields that are inserted in expressions. E.g. `WHERE foo + <insert field><space>`. I'm not sure if this is best or not... ### 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 ### Identify risks - [ ] As with any refactor, there's a possibility this will introduce a regression in the behavior of commands. However, all automated tests are passing and I have tested the behavior manually and can detect no regression. --------- Co-authored-by: Stratoula Kalafateli <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
## Summary Part of elastic#195418 Gives `EVAL` autocomplete logic its own home 🏡 ### Expression suggestions function This PR also introduces a semi-generic function for generating suggestions within an expression. This is so that the logic can be shared between `EVAL` and `WHERE`. It also gets us closer to supporting filtering in `STATS` (elastic#195363). To make this happen, I took stock of where we have differences in our expression suggestions between `WHERE` and `EVAL`. In some cases, the differences seemed important. In other cases, I felt ok removing them. #### EVAL | Behavior | Plan | |--------------------------------------------------------------------------|------| | Suggests pipe and comma after complete column names (`column/` or `column /`)| get rid of it because an expression consisting of just a single column name is essentially useless in `EVAL` | | Doesn't suggest fields after an assignment | get rid of it. why act any different than an expression not assigned an alias? | | Suggests assignment operator after new column name (`newColumn /`) | keep it | | Suggests assignment snippet for empty expression | keep it | | Suggests time literal completions after literal number in assignment (`newColumn = 1 /`) | remove it. it doesn't feel that useful and removing it makes it easier to have a generic expression suggestions function. It will still be around in functions and operators (e.g. `1 day + 2 /`). | | Supports multiple expressions | keep it | #### WHERE | Behavior | Plan | |--------------------------------------------------------------------------|------| | Suggests pipe after complete boolean expression (`foo AND bar /`) | keep it, but outside of the expression suggestion function | | Suggests boolean operators to make a boolean expression (`timestamp > "2002" AND doubleField /`) | keep it... maybe we're being too smart but we can always remove it later | ### Other changes - the suggestions for `CASE(foo != /)` used to differ based on the trigger kind. This seemed inadvertent so I removed the difference. - we now add spaces after fields that are inserted in expressions. E.g. `WHERE foo + <insert field><space>`. I'm not sure if this is best or not... ### 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 ### Identify risks - [ ] As with any refactor, there's a possibility this will introduce a regression in the behavior of commands. However, all automated tests are passing and I have tested the behavior manually and can detect no regression. --------- Co-authored-by: Stratoula Kalafateli <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
Summary
Part of #195418
Gives
EVAL
autocomplete logic its own home 🏡Expression suggestions function
This PR also introduces a semi-generic function for generating suggestions within an expression. This is so that the logic can be shared between
EVAL
andWHERE
. It also gets us closer to supporting filtering inSTATS
(#195363).To make this happen, I took stock of where we have differences in our expression suggestions between
WHERE
andEVAL
. In some cases, the differences seemed important. In other cases, I felt ok removing them.EVAL
column/
orcolumn /
)EVAL
newColumn /
)newColumn = 1 /
)1 day + 2 /
).WHERE
foo AND bar /
)timestamp > "2002" AND doubleField /
)Other changes
CASE(foo != /)
used to differ based on the trigger kind. This seemed inadvertent so I removed the difference.WHERE foo + <insert field><space>
. I'm not sure if this is best or not...Checklist
Identify risks