Skip to content

Commit 55572ea

Browse files
committed
[ES|QL] Fixes the autocomplete of timeseries sources after comma (elastic#241402)
## Summary Fixes the suggestions of timeseries (instead of all indices) in TS command after one selected <img width="580" height="145" alt="image" src="https://github.com/user-attachments/assets/0964262d-b0f7-43b9-93c5-18cec644bd96" /> ### Checklist - [ ] [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 (cherry picked from commit 3c9fadb) # Conflicts: # src/platform/packages/shared/kbn-esql-ast/src/commands_registry/commands/timeseries/autocomplete.ts
1 parent 9de3416 commit 55572ea

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)