GreptimeTeam / GreptimeTeam/promql-parser
Missing experimental functions from Prometheus functions.go (mad_over_time, info, histogram_quantiles, ts_of_*, …)
- Dominant language
- Rust
- Stars
- 104
- Forks
- 29
- Avg merge
- 15h 27m
- Merged PRs (30d)
- 1
Description
## Summary
`promql-parser` 0.9.0 rejects several PromQL functions that exist in Prometheus's current [`promql/parser/functions.go`](https://github.com/prometheus/prometheus/blob/main/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`](https://github.com/prometheus/prometheus/tree/main/promql/promqltest/testdata) (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
```rust
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.