Files
greptimedb/src
dennis zhuang 99bf6a8403 feat(promql): add histogram_quantiles and share Go float formatting (#9840)
I hereby agree to the terms of the [GreptimeDB
CLA](https://github.com/GreptimeTeam/.github/blob/main/CLA.md).

## Refer to a related PR or issue link (optional)

Narthex operator task NEW-MAP-FN, remaining part.

## What's changed and what's your intention?

Adds the native kernel for the experimental `histogram_quantiles(v,
label, q...)` from Prometheus v3.15.0.

- `histogram_eval::histogram_quantiles` evaluates `histogram_quantile`
for each `q` with the existing kernel and sets `label` to `q`, formatted
as Prometheus' `labels.FormatOpenMetricsFloat` does. Results that then
share a label set merge through `merge_same_labelset`. A repeated `q`,
or a `label` that overwrites the label telling two histograms apart,
fails at a point both hold, as in Prometheus.
- The Go float formatting from #9799's `count_values` moves to a
`go_format` module, next to `go_sort`. It now offers both
`FormatFloat(v, 'f', -1, 64)` and `FormatOpenMetricsFloat`, which is
Go's shortest `'g'` format: an exponent below 1e-4 and from 1e6 on, at
least two exponent digits, `.0` appended to integers, and hardcoded
`0.0`, `1.0`, `-1.0`. Both share the round-trip-checked shortest digits.

### Tests

- `histogram_eval/quantiles_cases.txt` (37 KB, 30 cases): classic
histograms evaluated by the Prometheus engine with experimental
functions on (promql-compat `narthex-golden-histogram -quantiles`). It
includes repeated quantiles and `job` as the quantile label; 13 cases
end in the label set collision.
- `go_format/open_metrics_cases.txt` (13 KB, 358 values):
`FormatOpenMetricsFloat` outputs for the exponent switch points, the
hardcoded values, powers of two from 2^-30 to 2^30 with neighbours, and
random values (`narthex-golden-formatfloat -openmetrics`). The existing
`'f'` fixture is unchanged.

## PR Checklist
Please convert it to a draft if some of the following conditions are not
met.

- [x] I have written the necessary rustdoc comments.
- [x] I have added the necessary unit tests and integration tests.
- [ ] This PR requires documentation updates.
- [x] API changes are backward compatible.
- [x] Schema or data changes are backward compatible.
- [ ] This PR needs to be backported to release branches, and I have
added the `backport-<target>` labels (e.g. `backport-v1.3` targets
`release/v1.3`).
2026-10-22 14:44:37 +08:00
..