mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-13 23:42:32 +00:00
* fix(promql): return range-vector results for instant queries
An instant query of a range selector or subquery (e.g. `up[5m]`) returned
the internal range arrays, which panicked when the frontend decoded them as
dictionaries. Plan such queries as the selected samples with their own
timestamps, and reject range-vector expressions in range queries like
Prometheus does.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test(promql): keep encode_substrait on a valid range query
A range query of a range-vector expression now fails like in Prometheus.
Wrap the subquery in max_over_time so the case still encodes both
RangeManipulate nodes through substrait.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(promql): plan wrapped range-vector roots and reject a zero subquery step
TQL EXPLAIN, ANALYZE and AS alias wrap the root in an extension, which the
range-vector path did not unwrap. A zero subquery step divided by zero.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test(promql): cover wrapped range-vector roots and a zero subquery step
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(promql): default subquery step and reject range vectors in range queries
A root subquery without a step uses the one-minute default instead of
the query step. The HTTP range query endpoint rejects range-vector
expressions even when start equals end.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test: cover root subquery default step
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* refactor(promql): align root subqueries with subquery_child_window
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(promql): return millisecond timestamps for range-vector results
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* refactor(promql): keep the time index timezone and name its table in errors
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
---------
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
(cherry picked from commit b913be2af7)
Signed-off-by: WenyXu <wenymedia@gmail.com>
50 lines
1.4 KiB
SQL
50 lines
1.4 KiB
SQL
-- An instant query of a range-vector expression returns the selected samples
|
|
-- with their own timestamps. Expected results are from Prometheus 3.
|
|
|
|
create table range_vector_result (
|
|
ts timestamp time index,
|
|
val double,
|
|
host string primary key
|
|
);
|
|
|
|
insert into range_vector_result values
|
|
(0, 1.0, 'a'),
|
|
(10000, 2.0, 'a'),
|
|
(20000, 3.0, 'a'),
|
|
(30000, 4.0, 'a'),
|
|
(0, 10.0, 'b'),
|
|
(20000, 30.0, 'b');
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (30, 30, '1s') range_vector_result[20s];
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (30, 30, '1s') range_vector_result[20s] offset 10s;
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (30, 30, '1s') range_vector_result[15s] @ 20;
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (30, 30, '1s') range_vector_result[30s:10s];
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (30, 30, '1s') range_vector_result[35s:10s] offset 5s;
|
|
|
|
tql eval (35, 35, '1s') range_vector_result[4s:10s];
|
|
|
|
tql eval (0, 30, '10s') range_vector_result[20s];
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (30, 30, '1s') range_vector_result[20s] as v;
|
|
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
-- SQLNESS REPLACE (partitioning.*) REDACTED
|
|
tql explain (30, 30, '1s') range_vector_result[20s];
|
|
|
|
tql eval (30, 30, '1s') range_vector_result[30s:0.0001];
|
|
|
|
-- A subquery without a step uses the one-minute default, not the query step.
|
|
tql eval (300, 300, '1s') vector(1)[5m:];
|
|
|
|
drop table range_vector_result;
|