feat: wire QueryExpr algebra pipeline into handle_plan — optimizer, SketchAllocator, PlanSummary (#109 follow-up) - #111
Merged
Conversation
…, direct-emit QueryExpr from parsers - parse_query_expr() in query_parser/mod.rs dispatches to parse_promql_expr / parse_sql_expr which emit QueryExpr directly (no SketchExpr round-trip), preserving HistogramQuantile, PromQLSubquery, BinaryOp-VectorMatch, Sort+Limit, Join, SetOp - handle_plan runs parse_query_expr → QueryOptimizer → SketchAllocator when query_string is present; plan_summary (stage assignments, bandwidth saved, budget demotions) is included in the /api/v1/plan JSON response - Fix: TokenType(u8) match via .id(), AggItem alias conflict, CrossJoin(_) tuple variant, SetOperator::Minus coverage, duplicate SourceSpec import, wc move-before-use Closes #109 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SieDeta
pushed a commit
that referenced
this pull request
Apr 17, 2026
…, direct-emit QueryExpr from parsers (#111) - parse_query_expr() in query_parser/mod.rs dispatches to parse_promql_expr / parse_sql_expr which emit QueryExpr directly (no SketchExpr round-trip), preserving HistogramQuantile, PromQLSubquery, BinaryOp-VectorMatch, Sort+Limit, Join, SetOp - handle_plan runs parse_query_expr → QueryOptimizer → SketchAllocator when query_string is present; plan_summary (stage assignments, bandwidth saved, budget demotions) is included in the /api/v1/plan JSON response - Fix: TokenType(u8) match via .id(), AggItem alias conflict, CrossJoin(_) tuple variant, SetOperator::Minus coverage, duplicate SourceSpec import, wc move-before-use Closes #109 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
4 tasks
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.
Summary
parse_query_expradded toquery_parser/mod.rs— dispatches toparse_promql_expr/parse_sql_exprwhich emitQueryExprdirectly from the AST (no lossySketchExprround-trip), preservingHistogramQuantile,PromQLSubquery, vector-binary-op matching,Sort+Limit,Join, andSetOphandle_plannow runs the full algebra pipeline whenquery_stringis present:parse_query_expr→QueryOptimizer→SketchAllocator→PlanSummary; theplan_summarykey is included in the/api/v1/planJSON response (stage assignments, bandwidth saved, budget demotions, per-node rationale)TokenType(u8)match via.id(),AggItemalias conflict (AlgAggItem),CrossJoin(_)tuple variant,SetOperator::Minuscoverage, duplicateSourceSpecimport,wcmove-before-use inhandle_planPartially addresses #109 (parser bridge gap + PlanSummary; coverage gap tasks remain open)
New response fields (
/api/v1/planwhenquery_stringis supplied){ "plan_summary": { "bandwidth_saved_bytes_per_sec": 12345.6, "agent_memory_bytes": 65536.0, "backend_memory_bytes": 0.0, "has_budget_demotion": false, "node_annotations": [ { "node_kind": "SketchAgg", "stage": "agent", "mode": "sketch", "rationale": "DDSketch quantile at agent", "memory_bytes": 65536.0, "bytes_per_sec": 800.0 }, ... ] } }plan_summaryisnullwhenquery_stringis absent or the parser fails (non-fatal warning logged).Test plan
cargo build— clean (0 errors, 13 expected warnings)cargo test— 285 passed, 0 failedPOST /api/v1/planwithquery_string: "quantile_over_time(0.99, latency[5m])"returnsplan_summarywith at least oneagent-stage sketch nodePOST /api/v1/planwithoutquery_stringreturnsplan_summary: null(no regression)🤖 Generated with Claude Code