Files
greptimedb/tests/cases/standalone/common/promql/histogram_quantile_binary_op.result
Yingwen 9487e2c3ca fix: divide series for subquery output (#8173)
* fix: divide series for subquery output

Signed-off-by: evenyag <realevenyag@gmail.com>

* fix: propagate time index lookup error in prom_call_manipulate

Signed-off-by: evenyag <realevenyag@gmail.com>

---------

Signed-off-by: evenyag <realevenyag@gmail.com>
2026-05-27 07:10:24 +00:00

92 lines
4.6 KiB
Plaintext

-- Reproduce https://github.com/GreptimeTeam/greptimedb/issues/8144
-- Binary comparison/arithmetic applied to a histogram_quantile() result.
create table http_request_duration_seconds_bucket (
ts timestamp time index,
le string,
pod string,
val double,
primary key (pod, le),
);
Affected Rows: 0
insert into http_request_duration_seconds_bucket values
(2900000, "0.01", "pod-a", 10),
(2900000, "0.05", "pod-a", 20),
(2900000, "0.1", "pod-a", 30),
(2900000, "+Inf", "pod-a", 40),
(3000000, "0.01", "pod-a", 20),
(3000000, "0.05", "pod-a", 50),
(3000000, "0.1", "pod-a", 80),
(3000000, "+Inf", "pod-a", 100),
(2900000, "0.01", "pod-b", 5),
(2900000, "0.05", "pod-b", 8),
(2900000, "0.1", "pod-b", 12),
(2900000, "+Inf", "pod-b", 15),
(3000000, "0.01", "pod-b", 10),
(3000000, "0.05", "pod-b", 25),
(3000000, "0.1", "pod-b", 45),
(3000000, "+Inf", "pod-b", 60);
Affected Rows: 16
-- histogram_quantile alone
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') histogram_quantile(0.5, sum by (le, pod) (rate(http_request_duration_seconds_bucket[5m])));
+-------+---------------------+-----------------------------------------------+
| pod | ts | sum(prom_rate(ts_range,val,ts,Int64(300000))) |
+-------+---------------------+-----------------------------------------------+
| pod-a | 1970-01-01T00:50:00 | 0.05 |
| pod-b | 1970-01-01T00:50:00 | 0.062499999999999986 |
+-------+---------------------+-----------------------------------------------+
-- comparison filter
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') histogram_quantile(0.5, sum by (le, pod) (rate(http_request_duration_seconds_bucket[5m]))) >= 0.02;
+-------+---------------------+-----------------------------------------------+
| pod | ts | sum(prom_rate(ts_range,val,ts,Int64(300000))) |
+-------+---------------------+-----------------------------------------------+
| pod-a | 1970-01-01T00:50:00 | 0.05 |
| pod-b | 1970-01-01T00:50:00 | 0.062499999999999986 |
+-------+---------------------+-----------------------------------------------+
-- arithmetic
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') histogram_quantile(0.5, sum by (le, pod) (rate(http_request_duration_seconds_bucket[5m]))) + 0;
+-------+---------------------+------------------------------------------------------------+
| pod | ts | sum(prom_rate(ts_range,val,ts,Int64(300000))) + Float64(0) |
+-------+---------------------+------------------------------------------------------------+
| pod-a | 1970-01-01T00:50:00 | 0.05 |
| pod-b | 1970-01-01T00:50:00 | 0.062499999999999986 |
+-------+---------------------+------------------------------------------------------------+
-- bool modifier
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') histogram_quantile(0.5, sum by (le, pod) (rate(http_request_duration_seconds_bucket[5m]))) >= bool 0.02;
+-------+---------------------+----------------------------------------------------------------+
| pod | ts | sum(prom_rate(ts_range,val,ts,Int64(300000))) >= Float64(0.02) |
+-------+---------------------+----------------------------------------------------------------+
| pod-a | 1970-01-01T00:50:00 | 1.0 |
| pod-b | 1970-01-01T00:50:00 | 1.0 |
+-------+---------------------+----------------------------------------------------------------+
-- subquery
-- SQLNESS SORT_RESULT 3 1
tql eval (3000, 3000, '1s') count_over_time((histogram_quantile(0.5, sum by (le, pod) (rate(http_request_duration_seconds_bucket[5m]))) >= 0.02)[10m:1m]);
+---------------------+------------------------------------------------------------------------------+-------+
| ts | prom_count_over_time(ts_range,sum(prom_rate(ts_range,val,ts,Int64(300000)))) | pod |
+---------------------+------------------------------------------------------------------------------+-------+
| 1970-01-01T00:50:00 | 1.0 | pod-a |
| 1970-01-01T00:50:00 | 1.0 | pod-b |
+---------------------+------------------------------------------------------------------------------+-------+
drop table http_request_duration_seconds_bucket;
Affected Rows: 0