Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit early on autocomplete noops #4431

Merged
merged 2 commits into from
Dec 10, 2024
Merged

Conversation

mdisibio
Copy link
Contributor

@mdisibio mdisibio commented Dec 9, 2024

What this PR does:
This fixes a gap in autocomplete where it's possible to autocomplete an attribute that's already being filtered in the query. This should be a noop but is actually executed.

Example:
/api/v2/search/tag/name/values?query={name="foo"}

Since we already know name must be foo, there is no reason to scan for the autocomplete values.

This PR adds the check to ExecuteTagValues in the engine. This is lower than preferred, ideally we would add this to the query-frontend, but the amount of pipeline reuse, and the location of the loose parsing of query make that non-trivial. But want to get this fix in sooner.

Notes:
It's only valid to exit early when it is the Equal operation, and not any case where the attribute is present in the query. For example these queries are filtering the same tag but can still return a range of values:

  • { .foo =~ "bar.*"}
  • { .foo > 0 }
  • { .foo != nil }

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Member

@mapno mapno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO can be cleared up

@mdisibio mdisibio merged commit 1169973 into grafana:main Dec 10, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants