Files
greptimedb/src/query
discord9 6106a6ea08 refactor(promql): unify semantic label resolution and label rewrites
Converge the ordinary-label and __name__ paths that had forked during the
rebase:

- resolve_label_col() is the single label-to-column entry: __name__ reads
  the marked identity column, ordinary labels resolve like before but can
  no longer hit the marked column by its physical name, and a missing
  label is absent for every caller (label functions, aggregation, sort).
- label_replace keeps one algorithm for every destination: read source
  (missing as ""), match anchored regex, expand captures (empty -> NULL),
  keep the old destination value when unmatched. Ordinary destinations may
  overwrite existing labels again (#9385 semantics); collapsing series is
  refused by the existing runtime label-set check instead of a plan-time
  InvalidDestinationLabelName.
- write_destination_label() is the single destination-column entry for
  label_replace and label_join, so writing an empty label has one
  representation and a zero-source label_join on __name__ removes the
  identity instead of projecting an unmarked physical __name__ column.
- drop_metric_name() now asserts a unique label set per evaluation
  timestamp when dropping the identity of a union that may ignore it
  (abs(a or on(__name__) b)), reusing assert_unique_match_group; TQL
  strip_metric_name_column() stays free of PromQL series checks.
- sort_by_label(..., "__name__") on input without a name sorts by a
  missing label instead of failing with field_not_found.

Production code is a net reduction (-38 lines); the removed ordinary-label
regex branch, the overwrite tri-state and the duplicated destination
construction are replaced by the three shared entries.

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
2026-10-12 11:13:07 +08:00
..