Files
greptimedb/src/sql
dennis zhuang 187facb58f feat(promql): let TQL discover metrics on the native route (#10674)
* feat(promql): let TQL discover metrics on the native route

TQL statements never prepared a metric discovery scope, so the native
route declined nameless and regex `__name__` selectors in TQL
(`metric_discovery_unavailable`) and the legacy planner then rejected
them, while the same query worked over the Prometheus HTTP API.

SQL statement authorization now prepares the scope for the PromQL a
statement evaluates (TQL EVAL/EXPLAIN/ANALYZE and TQL CTEs), keeping
each discovered table that the statement's own permission request may
read, and resolves the statement's table targets from the named tables
plus that scope, as the HTTP path does. The returned context is the one
the statement is planned with.

A TQL CTE that discovers metrics publishes the native answer's columns:
the legacy planner refuses such selectors, so there is no legacy schema
to publish over it.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(frontend): pin TQL discovery to the statement's own permission request

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* refactor(query): plan a metric-discovering TQL relation natively once

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-30 14:56:49 +00:00
..