Skip to content

Commit

Permalink
[8.16] [ES|QL] Fix duplicate autocomplete suggestions for where claus…
Browse files Browse the repository at this point in the history
…e, and suggestions with no space in between (#195771) (#196716)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[ES|QL] Fix duplicate autocomplete suggestions for where clause, and
suggestions with no space in between
(#195771)](#195771)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Quynh Nguyen
(Quinn)","email":"43350163+qn895@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-10-16T19:08:16Z","message":"[ES|QL]
Fix duplicate autocomplete suggestions for where clause, and suggestions
with no space in between (#195771)\n\n## Summary\r\n\r\nFix duplicate
autocomplete suggestions for where clause,
and\r\nhttps://github.com//issues/192596
and\r\nhttps://github.com//issues/192598 with `WHERE`
suggestions\r\nare inserted too far
back\r\n\r\n\r\nhttps://github.com/user-attachments/assets/e28357cd-84b8-4f57-a261-ab25121cd102\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [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- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"35bc785feb358be8d8ef586f81880c9910cefc0b","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","v9.0.0","backport:prev-major","Feature:ES|QL","Team:ESQL","v8.16.0","backport:current-major"],"number":195771,"url":"https://github.com/elastic/kibana/pull/195771","mergeCommit":{"message":"[ES|QL]
Fix duplicate autocomplete suggestions for where clause, and suggestions
with no space in between (#195771)\n\n## Summary\r\n\r\nFix duplicate
autocomplete suggestions for where clause,
and\r\nhttps://github.com//issues/192596
and\r\nhttps://github.com//issues/192598 with `WHERE`
suggestions\r\nare inserted too far
back\r\n\r\n\r\nhttps://github.com/user-attachments/assets/e28357cd-84b8-4f57-a261-ab25121cd102\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [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- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"35bc785feb358be8d8ef586f81880c9910cefc0b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195771","number":195771,"mergeCommit":{"message":"[ES|QL]
Fix duplicate autocomplete suggestions for where clause, and suggestions
with no space in between (#195771)\n\n## Summary\r\n\r\nFix duplicate
autocomplete suggestions for where clause,
and\r\nhttps://github.com//issues/192596
and\r\nhttps://github.com//issues/192598 with `WHERE`
suggestions\r\nare inserted too far
back\r\n\r\n\r\nhttps://github.com/user-attachments/assets/e28357cd-84b8-4f57-a261-ab25121cd102\r\n\r\n\r\n\r\n###
Checklist\r\n\r\nDelete any items that are not applicable to this
PR.\r\n\r\n- [ ] Any text added follows [EUI's
writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\r\nsentence case text and includes
[i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n-
[
]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [ ] [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- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [ ] Any UI touched in this PR is
usable by keyboard only (learn more\r\nabout [keyboard
accessibility](https://webaim.org/techniques/keyboard/))\r\n- [ ] Any UI
touched in this PR does not create any new axe failures\r\n(run axe in
browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n-
[ ] If a plugin configuration key changed, check if it needs to
be\r\nallowlisted in the cloud and added to the
[docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n-
[ ] This renders correctly on smaller devices using a
responsive\r\nlayout. (You can test this [in
your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n-
[ ] This was checked for
[cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n###
Risk Matrix\r\n\r\nDelete this section if it is not applicable to this
PR.\r\n\r\nBefore closing this PR, invite QA, stakeholders, and other
developers to\r\nidentify risks that should be tested prior to the
change/feature\r\nrelease.\r\n\r\nWhen forming the risk matrix, consider
some of the following examples\r\nand how they may potentially impact
the change:\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Multiple Spaces&mdash;unexpected behavior in non-default Kibana
Space.\r\n| Low | High | Integration tests will verify that all features
are still\r\nsupported in non-default Kibana Space and when user
switches between\r\nspaces. |\r\n| Multiple nodes&mdash;Elasticsearch
polling might have race conditions\r\nwhen multiple Kibana nodes are
polling for the same tasks. | High | Low\r\n| Tasks are idempotent, so
executing them multiple times will not result\r\nin logical error, but
will degrade performance. To test for this case we\r\nadd plenty of unit
tests around this logic and document manual testing\r\nprocedure. |\r\n|
Code should gracefully handle cases when feature X or plugin Y
are\r\ndisabled. | Medium | High | Unit tests will verify that any
feature flag\r\nor plugin combination still results in our service
operational. |\r\n| [See more potential
risk\r\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
|\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\nCo-authored-by:
Elastic Machine
<elasticmachine@users.noreply.github.com>","sha":"35bc785feb358be8d8ef586f81880c9910cefc0b"}},{"branch":"8.x","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/196595","number":196595,"state":"MERGED","mergeCommit":{"sha":"18819362f9db4216bb789bb0ac6577dc441aa189","message":"[8.x]
[ES|QL] Fix duplicate autocomplete suggestions for where clause, and
suggestions with no space in between (#195771) (#196595)\n\n#
Backport\n\nThis will backport the following commits from `main` to
`8.x`:\n- [[ES|QL] Fix duplicate autocomplete suggestions for where
clause, and\nsuggestions with no space in
between\n(#195771)](https://github.com/elastic/kibana/pull/195771)\n\n<!---
Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Quynh
Nguyen\n(Quinn)\",\"email\":\"43350163+qn895@users.noreply.github.com\"},\"sourceCommit\":{\"committedDate\":\"2024-10-16T19:08:16Z\",\"message\":\"[ES|QL]\nFix
duplicate autocomplete suggestions for where clause, and
suggestions\nwith no space in between (#195771)\\n\\n##
Summary\\r\\n\\r\\nFix duplicate\nautocomplete suggestions for where
clause,\nand\\r\\nhttps://github.com//issues/192596\nand\\r\\nhttps://github.com//issues/192598
with `WHERE`\nsuggestions\\r\\nare inserted too
far\nback\\r\\n\\r\\n\\r\\nhttps://github.com/user-attachments/assets/e28357cd-84b8-4f57-a261-ab25121cd102\\r\\n\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\nDelete
any items that are not applicable to this\nPR.\\r\\n\\r\\n- [ ] Any text
added follows
[EUI's\nwriting\\r\\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),\nuses\\r\\nsentence
case text and
includes\n[i18n\\r\\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\\r\\n-\n[\n]\\r\\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\\r\\nwas\nadded
for features that require explanation or tutorials\\r\\n- [ ]
[Unit\nor\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n- [ ] Any UI touched in this PR is\nusable by
keyboard only (learn more\\r\\nabout
[keyboard\naccessibility](https://webaim.org/techniques/keyboard/))\\r\\n-
[ ] Any UI\ntouched in this PR does not create any new axe
failures\\r\\n(run axe
in\nbrowser:\\r\\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\\r\\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\\r\\n-\n[
] If a plugin configuration key changed, check if it needs
to\nbe\\r\\nallowlisted in the cloud and added to
the\n[docker\\r\\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\\r\\n-\n[
] This renders correctly on smaller devices using
a\nresponsive\\r\\nlayout. (You can test this
[in\nyour\\r\\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\\r\\n-\n[
] This was checked
for\n[cross-browser\\r\\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\\r\\n\\r\\n\\r\\n###\nRisk
Matrix\\r\\n\\r\\nDelete this section if it is not applicable to
this\nPR.\\r\\n\\r\\nBefore closing this PR, invite QA, stakeholders,
and other\ndevelopers to\\r\\nidentify risks that should be tested prior
to the\nchange/feature\\r\\nrelease.\\r\\n\\r\\nWhen forming the risk
matrix, consider\nsome of the following examples\\r\\nand how they may
potentially impact\nthe change:\\r\\n\\r\\n| Risk | Probability |
Severity |
Mitigation/Notes\n|\\r\\n\\r\\n|---------------------------|-------------|----------|-------------------------|\\r\\n|\nMultiple
Spaces&mdash;unexpected behavior in non-default Kibana\nSpace.\\r\\n|
Low | High | Integration tests will verify that all features\nare
still\\r\\nsupported in non-default Kibana Space and when user\nswitches
between\\r\\nspaces. |\\r\\n| Multiple
nodes&mdash;Elasticsearch\npolling might have race conditions\\r\\nwhen
multiple Kibana nodes are\npolling for the same tasks. | High |
Low\\r\\n| Tasks are idempotent, so\nexecuting them multiple times will
not result\\r\\nin logical error, but\nwill degrade performance. To test
for this case we\\r\\nadd plenty of unit\ntests around this logic and
document manual testing\\r\\nprocedure. |\\r\\n|\nCode should gracefully
handle cases when feature X or plugin Y\nare\\r\\ndisabled. | Medium |
High | Unit tests will verify that any\nfeature flag\\r\\nor plugin
combination still results in our service\noperational. |\\r\\n| [See
more
potential\nrisk\\r\\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n|\\r\\n\\r\\n\\r\\n###
For maintainers\\r\\n\\r\\n- [ ] This was checked for\nbreaking API
changes and
was\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\\r\\n\\r\\nCo-authored-by:\nElastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"35bc785feb358be8d8ef586f81880c9910cefc0b\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.16.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"bug\",\"release_note:fix\",\"v9.0.0\",\"Feature:ES|QL\",\"Team:ESQL\",\"v8.16.0\",\"backport:current-major\"],\"title\":\"[ES|QL]\nFix
duplicate autocomplete suggestions for where clause, and
suggestions\nwith no space
in\nbetween\",\"number\":195771,\"url\":\"https://github.com/elastic/kibana/pull/195771\",\"mergeCommit\":{\"message\":\"[ES|QL]\nFix
duplicate autocomplete suggestions for where clause, and
suggestions\nwith no space in between (#195771)\\n\\n##
Summary\\r\\n\\r\\nFix duplicate\nautocomplete suggestions for where
clause,\nand\\r\\nhttps://github.com//issues/192596\nand\\r\\nhttps://github.com//issues/192598
with `WHERE`\nsuggestions\\r\\nare inserted too
far\nback\\r\\n\\r\\n\\r\\nhttps://github.com/user-attachments/assets/e28357cd-84b8-4f57-a261-ab25121cd102\\r\\n\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\nDelete
any items that are not applicable to this\nPR.\\r\\n\\r\\n- [ ] Any text
added follows
[EUI's\nwriting\\r\\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),\nuses\\r\\nsentence
case text and
includes\n[i18n\\r\\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\\r\\n-\n[\n]\\r\\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\\r\\nwas\nadded
for features that require explanation or tutorials\\r\\n- [ ]
[Unit\nor\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n- [ ] Any UI touched in this PR is\nusable by
keyboard only (learn more\\r\\nabout
[keyboard\naccessibility](https://webaim.org/techniques/keyboard/))\\r\\n-
[ ] Any UI\ntouched in this PR does not create any new axe
failures\\r\\n(run axe
in\nbrowser:\\r\\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\\r\\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\\r\\n-\n[
] If a plugin configuration key changed, check if it needs
to\nbe\\r\\nallowlisted in the cloud and added to
the\n[docker\\r\\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\\r\\n-\n[
] This renders correctly on smaller devices using
a\nresponsive\\r\\nlayout. (You can test this
[in\nyour\\r\\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\\r\\n-\n[
] This was checked
for\n[cross-browser\\r\\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\\r\\n\\r\\n\\r\\n###\nRisk
Matrix\\r\\n\\r\\nDelete this section if it is not applicable to
this\nPR.\\r\\n\\r\\nBefore closing this PR, invite QA, stakeholders,
and other\ndevelopers to\\r\\nidentify risks that should be tested prior
to the\nchange/feature\\r\\nrelease.\\r\\n\\r\\nWhen forming the risk
matrix, consider\nsome of the following examples\\r\\nand how they may
potentially impact\nthe change:\\r\\n\\r\\n| Risk | Probability |
Severity |
Mitigation/Notes\n|\\r\\n\\r\\n|---------------------------|-------------|----------|-------------------------|\\r\\n|\nMultiple
Spaces&mdash;unexpected behavior in non-default Kibana\nSpace.\\r\\n|
Low | High | Integration tests will verify that all features\nare
still\\r\\nsupported in non-default Kibana Space and when user\nswitches
between\\r\\nspaces. |\\r\\n| Multiple
nodes&mdash;Elasticsearch\npolling might have race conditions\\r\\nwhen
multiple Kibana nodes are\npolling for the same tasks. | High |
Low\\r\\n| Tasks are idempotent, so\nexecuting them multiple times will
not result\\r\\nin logical error, but\nwill degrade performance. To test
for this case we\\r\\nadd plenty of unit\ntests around this logic and
document manual testing\\r\\nprocedure. |\\r\\n|\nCode should gracefully
handle cases when feature X or plugin Y\nare\\r\\ndisabled. | Medium |
High | Unit tests will verify that any\nfeature flag\\r\\nor plugin
combination still results in our service\noperational. |\\r\\n| [See
more
potential\nrisk\\r\\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n|\\r\\n\\r\\n\\r\\n###
For maintainers\\r\\n\\r\\n- [ ] This was checked for\nbreaking API
changes and
was\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\\r\\n\\r\\nCo-authored-by:\nElastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"35bc785feb358be8d8ef586f81880c9910cefc0b\"}},\"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/195771\",\"number\":195771,\"mergeCommit\":{\"message\":\"[ES|QL]\nFix
duplicate autocomplete suggestions for where clause, and
suggestions\nwith no space in between (#195771)\\n\\n##
Summary\\r\\n\\r\\nFix duplicate\nautocomplete suggestions for where
clause,\nand\\r\\nhttps://github.com//issues/192596\nand\\r\\nhttps://github.com//issues/192598
with `WHERE`\nsuggestions\\r\\nare inserted too
far\nback\\r\\n\\r\\n\\r\\nhttps://github.com/user-attachments/assets/e28357cd-84b8-4f57-a261-ab25121cd102\\r\\n\\r\\n\\r\\n\\r\\n###\nChecklist\\r\\n\\r\\nDelete
any items that are not applicable to this\nPR.\\r\\n\\r\\n- [ ] Any text
added follows
[EUI's\nwriting\\r\\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),\nuses\\r\\nsentence
case text and
includes\n[i18n\\r\\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\\r\\n-\n[\n]\\r\\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\\r\\nwas\nadded
for features that require explanation or tutorials\\r\\n- [ ]
[Unit\nor\nfunctional\\r\\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\\r\\nwere\nupdated
or added to match the most common scenarios\\r\\n- [ ]
[Flaky\nTest\\r\\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)\nwas\\r\\nused
on any tests changed\\r\\n- [ ] Any UI touched in this PR is\nusable by
keyboard only (learn more\\r\\nabout
[keyboard\naccessibility](https://webaim.org/techniques/keyboard/))\\r\\n-
[ ] Any UI\ntouched in this PR does not create any new axe
failures\\r\\n(run axe
in\nbrowser:\\r\\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\\r\\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\\r\\n-\n[
] If a plugin configuration key changed, check if it needs
to\nbe\\r\\nallowlisted in the cloud and added to
the\n[docker\\r\\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\\r\\n-\n[
] This renders correctly on smaller devices using
a\nresponsive\\r\\nlayout. (You can test this
[in\nyour\\r\\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\\r\\n-\n[
] This was checked
for\n[cross-browser\\r\\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\\r\\n\\r\\n\\r\\n###\nRisk
Matrix\\r\\n\\r\\nDelete this section if it is not applicable to
this\nPR.\\r\\n\\r\\nBefore closing this PR, invite QA, stakeholders,
and other\ndevelopers to\\r\\nidentify risks that should be tested prior
to the\nchange/feature\\r\\nrelease.\\r\\n\\r\\nWhen forming the risk
matrix, consider\nsome of the following examples\\r\\nand how they may
potentially impact\nthe change:\\r\\n\\r\\n| Risk | Probability |
Severity |
Mitigation/Notes\n|\\r\\n\\r\\n|---------------------------|-------------|----------|-------------------------|\\r\\n|\nMultiple
Spaces&mdash;unexpected behavior in non-default Kibana\nSpace.\\r\\n|
Low | High | Integration tests will verify that all features\nare
still\\r\\nsupported in non-default Kibana Space and when user\nswitches
between\\r\\nspaces. |\\r\\n| Multiple
nodes&mdash;Elasticsearch\npolling might have race conditions\\r\\nwhen
multiple Kibana nodes are\npolling for the same tasks. | High |
Low\\r\\n| Tasks are idempotent, so\nexecuting them multiple times will
not result\\r\\nin logical error, but\nwill degrade performance. To test
for this case we\\r\\nadd plenty of unit\ntests around this logic and
document manual testing\\r\\nprocedure. |\\r\\n|\nCode should gracefully
handle cases when feature X or plugin Y\nare\\r\\ndisabled. | Medium |
High | Unit tests will verify that any\nfeature flag\\r\\nor plugin
combination still results in our service\noperational. |\\r\\n| [See
more
potential\nrisk\\r\\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n|\\r\\n\\r\\n\\r\\n###
For maintainers\\r\\n\\r\\n- [ ] This was checked for\nbreaking API
changes and
was\n[labeled\\r\\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\\r\\n\\r\\nCo-authored-by:\nElastic
Machine\n<elasticmachine@users.noreply.github.com>\",\"sha\":\"35bc785feb358be8d8ef586f81880c9910cefc0b\"}},{\"branch\":\"8.x\",\"label\":\"v8.16.0\",\"branchLabelMappingKey\":\"^v8.16.0$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->\n\nCo-authored-by:
Quynh Nguyen (Quinn) <43350163+qn895@users.noreply.github.com>"}}]}]
BACKPORT-->

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
  • Loading branch information
qn895 and stratoula authored Oct 21, 2024
1 parent 89603da commit af90873
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1262,41 +1262,33 @@ describe('autocomplete', () => {
describe('Replacement ranges are attached when needed', () => {
testSuggestions('FROM a | WHERE doubleField IS NOT N/', [
{ text: 'IS NOT NULL', rangeToReplace: { start: 28, end: 35 } },
{ text: 'IS NULL', rangeToReplace: { start: 35, end: 35 } },
{ text: 'IS NULL', rangeToReplace: { start: 36, end: 36 } },
'!= $0',
'< $0',
'<= $0',
'== $0',
'> $0',
'>= $0',
'IN $0',
'AND $0',
'NOT',
'OR $0',
]);
testSuggestions('FROM a | WHERE doubleField IS N/', [
{ text: 'IS NOT NULL', rangeToReplace: { start: 28, end: 31 } },
{ text: 'IS NULL', rangeToReplace: { start: 28, end: 31 } },
{ text: '!= $0', rangeToReplace: { start: 31, end: 31 } },
'< $0',
'<= $0',
{ text: '!= $0', rangeToReplace: { start: 32, end: 32 } },
'== $0',
'> $0',
'>= $0',
'IN $0',
'AND $0',
'NOT',
'OR $0',
]);
testSuggestions('FROM a | EVAL doubleField IS NOT N/', [
{ text: 'IS NOT NULL', rangeToReplace: { start: 27, end: 34 } },
'IS NULL',
'% $0',
'* $0',
'+ $0',
'- $0',
'/ $0',
'!= $0',
'< $0',
'<= $0',
'== $0',
'> $0',
'>= $0',
'IN $0',
'AND $0',
'NOT',
'OR $0',
]);
describe('dot-separated field names', () => {
testSuggestions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,16 @@ function findNewVariable(variables: Map<string, ESQLVariable[]>) {
function workoutBuiltinOptions(
nodeArg: ESQLAstItem,
references: Pick<ReferenceMaps, 'fields' | 'variables'>
): { skipAssign: boolean } {
): { skipAssign: boolean; commandsToInclude?: string[] } {
const commandsToInclude =
(isSingleItem(nodeArg) && nodeArg.text?.toLowerCase().trim().endsWith('null')) ?? false
? ['and', 'or']
: undefined;

// skip assign operator if it's a function or an existing field to avoid promoting shadowing
return {
skipAssign: Boolean(!isColumnItem(nodeArg) || getColumnForASTNode(nodeArg, references)),
commandsToInclude,
};
}

Expand Down Expand Up @@ -447,7 +453,10 @@ function isFunctionArgComplete(
}
const hasCorrectTypes = fnDefinition.signatures.some((def) => {
return arg.args.every((a, index) => {
return def.params[index].type === extractTypeFromASTArg(a, references);
return (
(fnDefinition.name.endsWith('null') && def.params[index].type === 'any') ||
def.params[index].type === extractTypeFromASTArg(a, references)
);
});
});
if (!hasCorrectTypes) {
Expand Down Expand Up @@ -1140,11 +1149,12 @@ async function getBuiltinFunctionNextArgument(
}
return suggestions.map<SuggestionRawDefinition>((s) => {
const overlap = getOverlapRange(queryText, s.text);
const offset = overlap.start === overlap.end ? 1 : 0;
return {
...s,
rangeToReplace: {
start: overlap.start,
end: overlap.end,
start: overlap.start + offset,
end: overlap.end + offset,
},
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export const getBuiltinCompatibleFunctionDefinition = (
option: string | undefined,
argType: FunctionParameterType,
returnTypes?: FunctionReturnType[],
{ skipAssign }: { skipAssign?: boolean } = {}
{ skipAssign, commandsToInclude }: { skipAssign?: boolean; commandsToInclude?: string[] } = {}
): SuggestionRawDefinition[] => {
const compatibleFunctions = [...builtinFunctions, ...getTestFunctions()].filter(
({ name, supportedCommands, supportedOptions, signatures, ignoreAsSuggestion }) =>
(command === 'where' && commandsToInclude ? commandsToInclude.indexOf(name) > -1 : true) &&
!ignoreAsSuggestion &&
(!skipAssign || name !== '=') &&
(option ? supportedOptions?.includes(option) : supportedCommands.includes(command)) &&
Expand Down

0 comments on commit af90873

Please sign in to comment.