Skip to content

refactor(query-engine): dedup instant/range PromQL arm-building and parsing in promql.rs#517

Merged
milindsrivastava1997 merged 1 commit into
mainfrom
507-promqlrs-instant-vs-range-query-paths-duplicated
Jul 8, 2026
Merged

refactor(query-engine): dedup instant/range PromQL arm-building and parsing in promql.rs#517
milindsrivastava1997 merged 1 commit into
mainfrom
507-promqlrs-instant-vs-range-query-paths-duplicated

Conversation

@milindsrivastava1997

Copy link
Copy Markdown
Contributor

High-level overview of the refactor (asap-query-engine/src/engines/simple_engine/promql.rs):

  1. detect_scalar_arm — new free function extracting the scalar-vs-vector detection logic that was byte-for-byte duplicated in handle_binary_expr_promql and handle_binary_expr_range_promql.
  2. resolve_arm_leaf_context — new shared method extracting the Paren-unwrap recursion + structural config lookup + base QueryExecutionContext build that was duplicated between build_arm_logical_plan (instant) and build_arm_range_context (range). Each builder keeps its
    own arm-combination logic on top (DataFusion plan join vs. sample-level timestamp join) since those genuinely differ.
  3. Parse-once wiring — added private build_query_execution_context_from_parsed and build_range_query_execution_context_from_parsed, taking an already-parsed AST. The public String-taking functions became thin wrappers (unchanged signatures, so none of the ~15 test
    call sites needed touching). handle_query_promql/handle_range_query_promql now parse the query exactly once and pass that AST straight through, instead of parsing again inside the context builders they call.
  4. New tests (range_query_arithmetic_tests.rs) — added vector-vector and scalar range-query arithmetic coverage, since nothing previously exercised handle_range_query_promql's binary path at all.

@milindsrivastava1997 milindsrivastava1997 linked an issue Jul 8, 2026 that may be closed by this pull request
@milindsrivastava1997 milindsrivastava1997 merged commit a420865 into main Jul 8, 2026
8 checks passed
@milindsrivastava1997 milindsrivastava1997 deleted the 507-promqlrs-instant-vs-range-query-paths-duplicated branch July 8, 2026 18:37
zaoxing added a commit that referenced this pull request Jul 11, 2026
…t-correction

Resolve conflicts from main's promql.rs dedup + QueryPatternType removal
(#511/#515/#517/#518) against the rate()/increase() counter-reset correction +
extrapolation work:

- promql.rs: keep main's refactored build_query_kwargs_promql signature
  (&Statistic, match_result); thread `timestamps` through it and retain the
  Rate|Increase range-boundary arm; drop now-unused imports (QueryPatternType,
  get_is_collapsable, AggregationOperator, PromQLFunction,
  get_spatial_aggregation_output_labels, get_statistics_to_compute).
- simple_engine/mod.rs: keep RANGE_*_MS_KWARG imports (per-step range boundaries),
  drop removed QueryPatternType.
- tests: keep the single-pop Increase extrapolation test (arroyo serde now makes
  it deserializable) over main's obsolete not_implemented assertion; keep all new
  rate/increase test modules alongside main's range_query_arithmetic_tests.

Verified: workspace builds; 560 lib tests pass (0 failures); fmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

promql.rs: instant vs range query paths duplicated

1 participant