Skip to content

fix: Implement approx-topk function on querier - #17816

Merged
benclive merged 2 commits into
mainfrom
implement-approx-topk-on-querier
May 27, 2025
Merged

fix: Implement approx-topk function on querier#17816
benclive merged 2 commits into
mainfrom
implement-approx-topk-on-querier

Conversation

@benclive

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
Implements the approx_topk function on the querier directly, so it no longer requires the query-frontend to re-write it via the ShardMapper.

  • It is implemented using count_min_sketch as a sharded query is, but I added a step evaluator to process the samples instead of using the Downstreamer & Accumulator.
  • This fixes a panic when an approx_topk query is not sharded (e.g. it's within the minShardingLookback, or when there aren't any shards within the data) and the raw query is simply forwarded to the querier.

Tested locally to double check it works as expected.
image

@benclive
benclive requested a review from a team as a code owner May 23, 2025 18:26

@cyriltovena cyriltovena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@benclive
benclive merged commit 7ca7c3b into main May 27, 2025
@benclive
benclive deleted the implement-approx-topk-on-querier branch May 27, 2025 09:57
felix0102 pushed a commit to felix0102/loki that referenced this pull request Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants