Skip to content

Commit 88bf493

Browse files
authored
[9.2] [ES|QL] Fixes the autocomplete of timeseries sources after comma (#241402) (#241444)
# Backport This will backport the following commits from `main` to `9.2`: - [[ES|QL] Fixes the autocomplete of timeseries sources after comma (#241402)](#241402) <!--- Backport version: 10.1.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Stratou","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-31T10:29:08Z","message":"[ES|QL] Fixes the autocomplete of timeseries sources after comma (#241402)\n\n## Summary\n\nFixes the suggestions of timeseries (instead of all indices) in TS\ncommand after one selected\n\n<img width=\"580\" height=\"145\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/0964262d-b0f7-43b9-93c5-18cec644bd96\"\n/>\n\n\n### Checklist\n\n- [ ] [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","sha":"3c9fadb499cb1c765d6823d25deaaf530b49ac14","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:ES|QL","Team:ESQL","backport:version","v9.3.0","v9.2.1"],"title":"[ES|QL] Fixes the autocomplete of timeseries sources after comma","number":241402,"url":"https://github.com/elastic/kibana/pull/241402","mergeCommit":{"message":"[ES|QL] Fixes the autocomplete of timeseries sources after comma (#241402)\n\n## Summary\n\nFixes the suggestions of timeseries (instead of all indices) in TS\ncommand after one selected\n\n<img width=\"580\" height=\"145\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/0964262d-b0f7-43b9-93c5-18cec644bd96\"\n/>\n\n\n### Checklist\n\n- [ ] [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","sha":"3c9fadb499cb1c765d6823d25deaaf530b49ac14"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/241402","number":241402,"mergeCommit":{"message":"[ES|QL] Fixes the autocomplete of timeseries sources after comma (#241402)\n\n## Summary\n\nFixes the suggestions of timeseries (instead of all indices) in TS\ncommand after one selected\n\n<img width=\"580\" height=\"145\" alt=\"image\"\nsrc=\"https://github.com/user-attachments/assets/0964262d-b0f7-43b9-93c5-18cec644bd96\"\n/>\n\n\n### Checklist\n\n- [ ] [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","sha":"3c9fadb499cb1c765d6823d25deaaf530b49ac14"}},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
1 parent 097c660 commit 88bf493

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ describe('TS Autocomplete', () => {
6666
]);
6767
});
6868

69+
test('can suggest timeseries after one already selected', async () => {
70+
const suggestions = await suggest('TS timeseries_index, ');
71+
const labels = suggestions.map((s) => s.label);
72+
73+
expect(labels).toEqual(['timeseries_index_with_alias', 'time_series_index']);
74+
});
75+
6976
test('discriminates between indices and aliases', async () => {
7077
const suggestions = await suggest('TS ');
7178
const indices: string[] = suggestions

src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ export async function autocomplete(
6868
// TS something/
6969
// TS something, /
7070
else if (indexes.length) {
71-
const sources = context?.sources ?? [];
71+
const timeSeriesSources =
72+
context?.timeSeriesSources?.map(({ name }) => ({ name, hidden: false })) ?? [];
73+
7274
const additionalSuggestions = await additionalSourcesSuggestions(
7375
innerText,
74-
sources,
76+
timeSeriesSources,
7577
indexes.map(({ name }) => name),
7678
[]
7779
);

0 commit comments

Comments
 (0)