mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-22 03:42:32 +00:00
* fix(promql): keep vector labels when a computed scalar is on the right `metric + time()` or `metric * scalar(other)` planned the join with the scalar side's context, which has no tags, so every series collapsed into one unlabeled series. Use the vector side's context when the right operand is scalar-typed. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): update results for labels kept with a computed scalar on the right v * pi() and v + time() now keep the vector's labels and time index name, as in Prometheus. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): qualify columns of an unnamed operand in vector joins A comparison filter's projection has no table name, so after the join its time index resolved unqualified and was ambiguous when the other operand had the same column. Also keep the empty-metric branch unchanged for scalar left operands. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover comparison filters joined with a scalar Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
44 lines
1.1 KiB
SQL
44 lines
1.1 KiB
SQL
-- A vector combined with a computed scalar on the right keeps the vector's
|
|
-- labels, like a scalar on the left does. Expected results are from Prometheus 3.
|
|
|
|
create table computed_scalar_lhs (
|
|
ts timestamp time index,
|
|
val double,
|
|
host string primary key
|
|
);
|
|
|
|
create table computed_scalar_rhs (
|
|
ts timestamp time index,
|
|
val double,
|
|
host string primary key
|
|
);
|
|
|
|
insert into computed_scalar_lhs values
|
|
(0, 1.0, 'a'),
|
|
(0, 2.0, 'b');
|
|
|
|
insert into computed_scalar_rhs values
|
|
(0, 10.0, 'x');
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (60, 60, '1s') computed_scalar_lhs + time();
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (60, 60, '1s') time() + computed_scalar_lhs;
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (60, 60, '1s') computed_scalar_lhs * scalar(computed_scalar_rhs);
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (60, 60, '1s') computed_scalar_lhs < bool (time() * 2);
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (60, 60, '1s') (time() >= computed_scalar_lhs) ^ scalar(computed_scalar_rhs);
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (60, 60, '1s') scalar(computed_scalar_rhs) * (time() >= computed_scalar_lhs);
|
|
|
|
drop table computed_scalar_lhs;
|
|
|
|
drop table computed_scalar_rhs;
|