Skip to content

promql.rs: range queries don't accelerate nested binary arithmetic #516

Description

@milindsrivastava1997

Context

Discovered while scoping #507 (promql.rs instant vs range query paths duplicated).

build_arm_logical_plan (instant path, asap-query-engine/src/engines/simple_engine/promql.rs) has an Expr::Binary recursion arm, so nested binary expressions like (cpu + mem) * 100 accelerate correctly for instant queries.

build_arm_range_context (range path) has no equivalent Expr::Binary arm. A nested binary sub-expression falls through to the leaf case, fails the structural config lookup, returns None, and the whole range query silently falls back to Prometheus instead of the accelerated store.

Example failing case

// Instant query accelerates fine:
let result = engine.handle_query_promql(
    "quantile(0.5, cpu_usage) / quantile(0.9, cpu_usage)".to_string(),
    QUERY_TIME,
);
assert!(result.is_some()); // passes today

// Same expression over a range silently fails to accelerate:
let result = engine.handle_range_query_promql(
    "quantile(0.5, cpu_usage) / quantile(0.9, cpu_usage)".to_string(),
    START, END, STEP,
);
assert!(result.is_some()); // fails today — falls through to None

Task

Extend range-query binary arithmetic handling to support nested binary expressions, matching instant-query behavior, and add a regression test for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions