Skip to content

Missing experimental functions from Prometheus functions.go (mad_over_time, info, histogram_quantiles, ts_of_*, …) #147

@zzylol

Description

@zzylol

Summary

promql-parser 0.9.0 rejects several PromQL functions that exist in Prometheus's current promql/parser/functions.go as unknown function. All are marked Experimental: true upstream, so they appear to be additions made after the 0.9 function table was last synced.

I found these by running Prometheus's own engine test corpus through promql-parser 0.9: I extracted every eval expression from promql/promqltest/testdata/*.test (1823 deduped expressions) and parsed each. 316 fail to parse; the unknown-function failures cluster in functions.test, info.test, and histograms.test.

Functions in Prometheus main but not in promql-parser 0.9

Diff of the two function tables (Prometheus 87 vs promql-parser 76):

Function ArgTypes Variadic Returns Experimental
mad_over_time (matrix) vector yes
first_over_time (matrix) vector yes
ts_of_first_over_time (matrix) vector yes
ts_of_last_over_time (matrix) vector yes
ts_of_max_over_time (matrix) vector yes
ts_of_min_over_time (matrix) vector yes
histogram_quantiles (vector, string, scalar, scalar…) 9 vector yes
info (vector, vector) 1 vector yes
max_of (scalar, scalar) scalar yes
min_of (scalar, scalar) scalar yes
start () scalar yes
end () scalar yes
step () scalar yes
range () scalar yes

Reproduction

use promql_parser::parser;
for q in [
    "mad_over_time(metric[5m])",
    "info(metric, {k=\"v\"})",
    "histogram_quantiles(metric, \"q\", 0.5, 0.9)",
    "ts_of_max_over_time(metric[5m])",
    "max_of(scalar(a), scalar(b))",
] {
    assert!(parser::parse(q).is_err(), "{q} unexpectedly parsed");
}

(promql-parser = "0.9.0")

Happy to send a PR adding the missing function-table entries if that's helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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