Skip to content

PromQL: remaining gaps vs Prometheus 3.15 (sort_by_label order, classic histogram_fraction, count type, scalar() parameters) #661

Open

Description

@zzylol

Found by running Prometheus v3.15.0's own PromQL test data (promql/promqltest/testdata/*.test, 2,242 cases) through #540's lowering. The fixable lowering bugs are fixed in #540; these need IR or design work.

Gaps

  • sort_by_label / sort_by_label_desc order. Prometheus compares label values with natural sort (cpu 0, 1, 2, …, 10, …, 100), and breaks ties on the full label set in the same direction as the sort. We sort label values as plain strings and leave ties ascending (functions.test:854, 867, 893, 906, 912). The IR's sort key cannot say "natural order" or "then by the series identity". sort_by_label(v) with no labels is valid PromQL but rejected (range_queries.test:115, 118). Values are right; only the order of an instant result differs.
  • histogram_fraction over classic _bucket series (42 cases, histograms.test:119-304) is supported by Prometheus 3.15 but rejected. feat(promql): lower queries to unified operator and scalar IR #540 now says so explicitly instead of a misleading native-histogram error.
  • count is typed Int64. PromQL counts are floats; an Int64 count in arithmetic or comparisons with float series needs a cast that Prometheus never has (operators.test:18, aggregators.test).
  • Scalar parameters read from a series. round(m, scalar(n)), clamp(m, 0, scalar(n)), clamp_max(m, scalar(m)) fail before compilation with "invalid physical series identity" (with_promql_series_identity, ir/schema_support.rs). Only scalar(vector(…)) and time() parameters work.

Not gaps

  • Prometheus' promql-delayed-name-removal is a feature flag in the 3.15 server; promqltest enables it. Without it, eager __name__ dropping is correct.
  • Native histograms, fill modifiers, dynamic aggregate parameters, step() / range() and the experimental syntax promqltest enables (anchored / smoothed, duration expressions) are rejected on purpose (feat(promql): lower queries to unified operator and scalar IR #540 description).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions