Skip to content

Share the full PromQL pattern list between planner and engine #855

Open

Description

@milindsrivastava1997

Problem

The planner and the query engine must accept the same PromQL shapes. #849 moved the collapsable ONE_TEMPORAL_ONE_SPATIAL and TOPK_OF_SUM builders into promql_utilities::ast_matching::collapsable_patterns. The ONLY_TEMPORAL and ONLY_SPATIAL patterns are still built separately:

  • Planner: asap-planner-rs/src/planner/patterns.rs build_patterns.
  • Engine: asap-query-engine/src/engines/simple_engine/mod.rs, from temporal_pattern_blocks / spatial_pattern_blocks.

So those two lists, and the order the patterns are tried in, can still drift apart.

Fix direction

Move the whole ordered build_patterns() into promql_utilities and call it from both sides. The engine builds its two patterns from a block map, so check that the shared builder yields the same pattern set, e.g. by comparing match results across a corpus of queries before deleting the engine copy.

Related: wasted heaps for topk by (l) (k, sum by (l) (...))

When topk's bucket labels cover all of the inner sum's labels, each bucket holds exactly one series. The query returns every group, yet the planner allocates a CMS plus a heap per bucket value. This is a degenerate shape and low priority; when needed, plan it as an exact sum by (l) instead (planner/labels.rs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions