mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-18 16:54:09 +00:00
A PromQL response could carry only one metric name for the whole result, derived from the statement. That is wrong whenever the rows of one result come from different metrics: a set operator reports the series of both its operands, so `left_metric or right_metric` returned the right-hand series under the left metric's name, with their own labels and samples intact. Carry the name as a column and declare what that column is: the column metadata key `greptime:metric_name`, the same place `greptime:time_index` declares a column's role. A consumer reads the declaration, not the column name, so a label an operation generates may itself be called `__name__` without being mistaken for one. The native planner adds `__name__` to the output tags of `or` -- the only set operator whose output mixes both operands -- and marks that column. Every other shape that keeps a per-row name already carries it the same way, since a native `__name__` tag always reads the series' own metric-name slot; arithmetic and aggregates drop it, as Prometheus does. The response layer reads the declared column per row instead of prepending the statement's name, keeps it out of the ordinary label set, and treats an empty value as no name, since Prometheus drops empty label values. A result with no declared column behaves exactly as before. Scope: the native route only. The legacy planner carries no per-row name and keeps naming rows from the statement, so its set-operator results are unchanged here. Signed-off-by: discord9 <discord9@163.com>