[ES|QL] Suggest only aggregation functions for SPARKLINE first argument - approach 2#268453
Closed
momovdg wants to merge 5 commits into
Closed
[ES|QL] Suggest only aggregation functions for SPARKLINE first argument - approach 2#268453momovdg wants to merge 5 commits into
momovdg wants to merge 5 commits into
Conversation
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
194797f to
ded68e7
Compare
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.
part of: #265936
Summary
This PR addresses only the autocomplete functionality for the SPARKLINE function.
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
Extends the existing hint dispatcher to also key off
hint.kind. The hint produces an exclusive suggestion set, so fields and other functions are skipped automatically — no flag plumbing needed (compared to this approach #268454):ParameterHint.entityType→ optional, with the three caller-side guards.kindBasedResolversmap inparameters_from_hints.ts, keyed byhint.kind. Adding a kind = adding one resolver entry.aggregationKindResolverusesgetAllFunctions({ type: [AGG, TIME_SERIES_AGG] })then applies the same predicates the standard path uses (location, license, ignored, paramDefinitions return types) and appends,whenhasMoreMandatoryArgs.buildSuggestionsFromHintsextended to fall back from the existingentityTypedispatch to ahint.kinddispatch. Because this path lives insidetryExclusiveSuggestions, returning items short-circuits the composite path → fields are excluded by construction.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.3 production files + 3 caller guards + 1 SPARKLINE unit test + 5 focused unit tests for the new resolver (return-type filter, ignored guard, comma handling, etc.).
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.