Conversation
…he heap input The whole-expression heap reads the absorbed aggregate's input, but kept the outer top-k's partition keys, which index that aggregate's output: `topk by(job)(k, sum by(service, job)(rate(x[5m])))` partitioned by `ts` and lost `job`. Resolve the keys by column onto the heap's input, and do not offer the heap when they cannot be resolved. Fixes #639 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zzylol
force-pushed
the
stack/fix-nested-topk-keys
branch
from
October 5, 2026 13:11
1f9a8f1 to
d889c14
Compare
zzylol
changed the base branch from
stack/cleanup-11-docs
to
stack/viewer-vertical-lanes
October 5, 2026 13:11
This was referenced Oct 5, 2026
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.
Stack: #574 → #620 → #618 → #621 → #627 → #625 → #628 → #632 → #634 → #616 → #617 → #622 → #624 → #629 → #630 → #631 → #633 → #635 → #636 → #637 → #638 → #640 → #641
Rebased onto #638. At the chain tip (#641) the full gate passes.
Fixes #639
Problem
For
topk by(job)(k, sum by(service, job)(rate(x[5m]))), Stage 1 builds a whole-expression heap that reads the raw rate rows and absorbs the innersum. That heap kept the outer top-k'sReduction, whose keys are indices into the inner aggregate's output. Read against the rate rows,by(job)becameby(ts), so the result lostjob. The legacy search, removed in #635, remapped these keys.Changes
pass1/logical_candidates.rs:whole_expression_inputnow also returns the outer partitions mapped onto the heap's input. A new helper,partitions_over, matches each key by column (column_ref). It returnsNone, so the heap is not offered, when a key is missing or ambiguous in the input or the keys are given bywithout.realizebuilds theSummaryAggwith these partitions.planner_weighted_topk_binds_at_either_deployment_phase. It now asserts(job, value)pairs at both phases:api: 0.3125, 0.375andbatch: 80, 100.whole_expression_topk_partitions_index_the_heap_input. Every heap in an absorbing candidate partitions byjobin its child's schema. Without the fix, it fails with["ts"].Test plan
cargo fmt --all -- --check: cleancargo clippy --workspace --all-targets -- -D warnings: cleancargo test --workspace: 1282 passed, 0 failed, 13 ignoredexample1_document_is_valid_and_committed_fixture_is_currentpasses, andtools/dag-viewer/examples/planner-layering-example1.jsonis unchanged.🤖 Generated with Claude Code