[ES|QL] Suggest only aggregation functions for SPARKLINE first argument - approach 1#268454
Closed
momovdg wants to merge 4 commits into
Closed
[ES|QL] Suggest only aggregation functions for SPARKLINE first argument - approach 1#268454momovdg wants to merge 4 commits into
momovdg wants to merge 4 commits into
Conversation
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
3 tasks
momovdg
commented
May 8, 2026
| const results = hints.map( | ||
| (hint) => | ||
| parametersFromHintsResolvers[hint.entityType]?.suggestionResolver?.(hint, ctx.context) ?? [] | ||
| const results = hints.map((hint) => |
Contributor
Author
There was a problem hiding this comment.
some changes related to entityType are added because this property is now optional (based on the functions definitions).
momovdg
commented
May 8, 2026
| ...getFunctionsToIgnoreForStats(command, finalCommandArgIndex) | ||
| ); | ||
|
|
||
| // The "no nested aggregations" rule applies unless the cursor's param |
Contributor
Author
There was a problem hiding this comment.
this part is a little bit strange because now we are allowing nested aggregations (specific to this case only) compared to the initial requirement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves: #265936
Summary
Problem
ES|QL's SPARKLINE function has a special first parameter that must always be an aggregation expression (e.g.
AVG(bytes)). Elasticsearch signals this viahint: { kind: 'aggregation' }on the param definition, but Kibana's autocomplete ignored that hint entirely:Inside
STATS SPARKLINE(|, ...), all scalar functions (SUBSTRING,ABS, etc.) were suggested alongside aggregations, plus every field in the index — none of which are valid input.The existing hint handler (
buildSuggestionsFromHints) only dispatched onhint.entityType(used byinference_endpoint), so akind-only hint was a no-op.Fix
Surfaces the existing
getAllFunctions({ type })filter through the composite-suggestion path, gated onhint.kind:ParameterHint.entityType→ optional, since SPARKLINE's hint has onlykind. Three callers that indexparametersFromHintsResolvers[hint.entityType]are guarded.HINT_KIND_SUGGESTION_CONFIGmap inempty_expression.tstranslateshint.kind→{ functionTypes, suppressFields }. Adding a kind = adding one entry; nothing else changes.buildFieldAndFunctionSuggestionsreadshint.kindand (a) skipsaddFieldswhensuppressFieldsis set, (b) passesfunctionTypestoaddFunctions.functionTypesthreaded throughSuggestionBuilder.addFunctions→getFunctionsSuggestions→getAllFunctions, which already supports type filtering.expectsAggregationopt-out:buildCustomFilteringContextwas adding every AGG name tofunctionsToIgnore(becauseisAggFunctionUsedAlreadysaw SPARKLINE itself in the AST). When the cursor's param hashint.kind === 'aggregation', the "no nested aggregations" rule does not apply — nesting is required, not forbidden.Result for
STATS SPARKLINE(|, ...): only AGG/TIME_SERIES_AGG functions are suggested, no fields. Self-recursion is still prevented (SPARKLINE itself stays in the ignore list).5 production files + 3 caller guards + 1 SPARKLINE-on-STATS unit test.
Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
release_note:*label is applied per the guidelinesbackport:*labels.