mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 20:54:08 +00:00
* fix(promql): follow IEEE 754 float semantics in operators and aggregations - Comparisons: Arrow orders floats totally (NaN == NaN, NaN > +Inf); PromQL comparisons with NaN are false except !=. - min/max: skip NaN unless the whole group is NaN. DataFusion's grouped min/max let NaN replace and be replaced by neighbours, so the result depended on input order. - topk/bottomk rank NaN last. - round() rounds ties up and returns NaN for a zero step, like Prometheus. - sqrt() of a negative number is NaN instead of an error. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): round() without a step rounds to integers The planner passed a zero step for single-argument round(), which now yields NaN like Prometheus; pass 1 instead. Found by the compatibility harness. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): apply the sqrt guard to builtin functions and register min/max for plan decoding sqrt resolves through the session's builtin functions, not the UDF branch. Distributed plans are decoded with the serializer's session, which did not know prom_min/prom_max. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover NaN and rounding semantics Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): keep the nested count rewrite for PromQL min/max count(min(x) by (l)) was rewritten by count_nest_aggr only for the builtin min/max names. prom_min/prom_max return NULL for the same groups, so the rewrite stays valid. Update plan snapshots for the IEEE comparison, sqrt, topk and min/max changes. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): register prom_min/prom_max in the function registry Distributed plans split an aggregation into state and merge steps only for functions whose state function exists in FUNCTION_REGISTRY; prom_min and prom_max lived in the promql crate, so min/max stopped being pushed down to datanodes. Move them to common-function and register them before the state functions are derived. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test: update sqlness results for PromQL float semantics Plans and column names now show prom_min/prom_max, the NaN guards of comparisons and sqrt, and the NaN sort key of topk. round() results follow Prometheus' formula. Distributed min/max keep the state/merge split. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): keep column names and NULLs in IEEE comparisons and sqrt Rewriting comparisons as `a op b AND NOT (isnan(a) OR isnan(b))` changed TQL output column names and turned NULL operands into true for `!=` and false for the bool forms. Implement comparisons and sqrt as PromQL UDFs that propagate NULL and report the column name of the expression they replace; prom_min/prom_max report min/max column names the same way. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test: restore column names in sqlness results for PromQL float semantics Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): share the prom_min/prom_max groups accumulator with tests Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): keep distinct names for prom_min/prom_max Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
506 lines
27 KiB
Plaintext
506 lines
27 KiB
Plaintext
-- https://github.com/GreptimeTeam/greptimedb/issues/9390
|
|
-- Tag, field and time index names containing dots or upper case letters must
|
|
-- be resolved as plain column names, not as `relation.column`. `Host` and `host`
|
|
-- hold different values, so reading one for the other changes the output.
|
|
CREATE TABLE "otel.m" (
|
|
"ts.time" TIMESTAMP(3) TIME INDEX,
|
|
"service.name" STRING,
|
|
"Host" STRING,
|
|
host STRING,
|
|
"v.val" DOUBLE,
|
|
PRIMARY KEY ("service.name", "Host", host)
|
|
) PARTITION ON COLUMNS ("service.name") (
|
|
"service.name" < 'b',
|
|
"service.name" >= 'b'
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO "otel.m" VALUES
|
|
(0, 'a', 'h1', 'x', 1),
|
|
(0, 'a', 'h2', 'x', 2),
|
|
(0, 'b', 'h1', 'y', 3),
|
|
(5000, 'a', 'h1', 'x', 4),
|
|
(5000, 'a', 'h2', 'x', 5),
|
|
(5000, 'b', 'h1', 'y', 6),
|
|
(10000, 'a', 'h1', 'x', 8),
|
|
(10000, 'a', 'h2', 'x', 9),
|
|
(10000, 'b', 'h1', 'y', 8);
|
|
|
|
Affected Rows: 9
|
|
|
|
CREATE TABLE "otel.h" (
|
|
"ts.time" TIMESTAMP(3) TIME INDEX,
|
|
"service.name" STRING,
|
|
le STRING,
|
|
"v.val" DOUBLE,
|
|
PRIMARY KEY ("service.name", le)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO "otel.h" VALUES
|
|
(0, 'a', '0.1', 1),
|
|
(0, 'a', '1', 3),
|
|
(0, 'a', '+Inf', 4),
|
|
(10000, 'a', '0.1', 2),
|
|
(10000, 'a', '1', 6),
|
|
(10000, 'a', '+Inf', 10);
|
|
|
|
Affected Rows: 6
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') {"otel.m"} and {"otel.m", "Host"="h1"};
|
|
|
|
+---------------------+--------------+------+------+-------+
|
|
| ts.time | service.name | Host | host | v.val |
|
|
+---------------------+--------------+------+------+-------+
|
|
| 1970-01-01T00:00:00 | a | h1 | x | 1.0 |
|
|
| 1970-01-01T00:00:00 | b | h1 | y | 3.0 |
|
|
| 1970-01-01T00:00:05 | a | h1 | x | 4.0 |
|
|
| 1970-01-01T00:00:05 | b | h1 | y | 6.0 |
|
|
| 1970-01-01T00:00:10 | a | h1 | x | 8.0 |
|
|
| 1970-01-01T00:00:10 | b | h1 | y | 8.0 |
|
|
+---------------------+--------------+------+------+-------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') {"otel.m"} and on("service.name") {"otel.m", "service.name"="b"};
|
|
|
|
+---------------------+--------------+------+------+-------+
|
|
| ts.time | service.name | Host | host | v.val |
|
|
+---------------------+--------------+------+------+-------+
|
|
| 1970-01-01T00:00:00 | b | h1 | y | 3.0 |
|
|
| 1970-01-01T00:00:05 | b | h1 | y | 6.0 |
|
|
| 1970-01-01T00:00:10 | b | h1 | y | 8.0 |
|
|
+---------------------+--------------+------+------+-------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') {"otel.m"} and on(host) {"otel.m", host="y"};
|
|
|
|
+---------------------+--------------+------+------+-------+
|
|
| ts.time | service.name | Host | host | v.val |
|
|
+---------------------+--------------+------+------+-------+
|
|
| 1970-01-01T00:00:00 | b | h1 | y | 3.0 |
|
|
| 1970-01-01T00:00:05 | b | h1 | y | 6.0 |
|
|
| 1970-01-01T00:00:10 | b | h1 | y | 8.0 |
|
|
+---------------------+--------------+------+------+-------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') {"otel.m"} unless {"otel.m", "Host"="h1"};
|
|
|
|
+---------------------+--------------+------+------+-------+
|
|
| ts.time | service.name | Host | host | v.val |
|
|
+---------------------+--------------+------+------+-------+
|
|
| 1970-01-01T00:00:00 | a | h2 | x | 2.0 |
|
|
| 1970-01-01T00:00:05 | a | h2 | x | 5.0 |
|
|
| 1970-01-01T00:00:10 | a | h2 | x | 9.0 |
|
|
+---------------------+--------------+------+------+-------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') {"otel.m"} unless on("service.name") {"otel.m", "service.name"="b"};
|
|
|
|
+---------------------+--------------+------+------+-------+
|
|
| ts.time | service.name | Host | host | v.val |
|
|
+---------------------+--------------+------+------+-------+
|
|
| 1970-01-01T00:00:00 | a | h1 | x | 1.0 |
|
|
| 1970-01-01T00:00:00 | a | h2 | x | 2.0 |
|
|
| 1970-01-01T00:00:05 | a | h1 | x | 4.0 |
|
|
| 1970-01-01T00:00:05 | a | h2 | x | 5.0 |
|
|
| 1970-01-01T00:00:10 | a | h1 | x | 8.0 |
|
|
| 1970-01-01T00:00:10 | a | h2 | x | 9.0 |
|
|
+---------------------+--------------+------+------+-------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') {"otel.m"} or {"otel.m", "Host"="h1"};
|
|
|
|
+---------------------+------+------+--------------+-------+
|
|
| ts.time | Host | host | service.name | v.val |
|
|
+---------------------+------+------+--------------+-------+
|
|
| 1970-01-01T00:00:00 | h1 | x | a | 1.0 |
|
|
| 1970-01-01T00:00:00 | h1 | y | b | 3.0 |
|
|
| 1970-01-01T00:00:00 | h2 | x | a | 2.0 |
|
|
| 1970-01-01T00:00:05 | h1 | x | a | 4.0 |
|
|
| 1970-01-01T00:00:05 | h1 | y | b | 6.0 |
|
|
| 1970-01-01T00:00:05 | h2 | x | a | 5.0 |
|
|
| 1970-01-01T00:00:10 | h1 | x | a | 8.0 |
|
|
| 1970-01-01T00:00:10 | h1 | y | b | 8.0 |
|
|
| 1970-01-01T00:00:10 | h2 | x | a | 9.0 |
|
|
+---------------------+------+------+--------------+-------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') count_values("v.name", {"otel.m"});
|
|
|
|
+---------------------+---------------------+--------+
|
|
| count(otel.m.v.val) | ts.time | v.name |
|
|
+---------------------+---------------------+--------+
|
|
| 1 | 1970-01-01T00:00:00 | 1 |
|
|
| 1 | 1970-01-01T00:00:00 | 2 |
|
|
| 1 | 1970-01-01T00:00:00 | 3 |
|
|
| 1 | 1970-01-01T00:00:05 | 4 |
|
|
| 1 | 1970-01-01T00:00:05 | 5 |
|
|
| 1 | 1970-01-01T00:00:05 | 6 |
|
|
| 1 | 1970-01-01T00:00:10 | 9 |
|
|
| 2 | 1970-01-01T00:00:10 | 8 |
|
|
+---------------------+---------------------+--------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') count_values by ("service.name") ("v.name", {"otel.m"});
|
|
|
|
+---------------------+--------------+---------------------+--------+
|
|
| count(otel.m.v.val) | service.name | ts.time | v.name |
|
|
+---------------------+--------------+---------------------+--------+
|
|
| 1 | a | 1970-01-01T00:00:00 | 1 |
|
|
| 1 | a | 1970-01-01T00:00:00 | 2 |
|
|
| 1 | a | 1970-01-01T00:00:05 | 4 |
|
|
| 1 | a | 1970-01-01T00:00:05 | 5 |
|
|
| 1 | a | 1970-01-01T00:00:10 | 8 |
|
|
| 1 | a | 1970-01-01T00:00:10 | 9 |
|
|
| 1 | b | 1970-01-01T00:00:00 | 3 |
|
|
| 1 | b | 1970-01-01T00:00:05 | 6 |
|
|
| 1 | b | 1970-01-01T00:00:10 | 8 |
|
|
+---------------------+--------------+---------------------+--------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') topk(1, {"otel.m"});
|
|
|
|
+-------+--------------+------+------+---------------------+
|
|
| v.val | service.name | Host | host | ts.time |
|
|
+-------+--------------+------+------+---------------------+
|
|
| 3.0 | b | h1 | y | 1970-01-01T00:00:00 |
|
|
| 6.0 | b | h1 | y | 1970-01-01T00:00:05 |
|
|
| 9.0 | a | h2 | x | 1970-01-01T00:00:10 |
|
|
+-------+--------------+------+------+---------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') bottomk by ("service.name") (1, {"otel.m"});
|
|
|
|
+-------+--------------+------+------+---------------------+
|
|
| v.val | service.name | Host | host | ts.time |
|
|
+-------+--------------+------+------+---------------------+
|
|
| 1.0 | a | h1 | x | 1970-01-01T00:00:00 |
|
|
| 3.0 | b | h1 | y | 1970-01-01T00:00:00 |
|
|
| 4.0 | a | h1 | x | 1970-01-01T00:00:05 |
|
|
| 6.0 | b | h1 | y | 1970-01-01T00:00:05 |
|
|
| 8.0 | a | h1 | x | 1970-01-01T00:00:10 |
|
|
| 8.0 | b | h1 | y | 1970-01-01T00:00:10 |
|
|
+-------+--------------+------+------+---------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') sum by ("service.name") ({"otel.m"});
|
|
|
|
+--------------+---------------------+-------------------+
|
|
| service.name | ts.time | sum(otel.m.v.val) |
|
|
+--------------+---------------------+-------------------+
|
|
| a | 1970-01-01T00:00:00 | 3.0 |
|
|
| a | 1970-01-01T00:00:05 | 9.0 |
|
|
| a | 1970-01-01T00:00:10 | 17.0 |
|
|
| b | 1970-01-01T00:00:00 | 3.0 |
|
|
| b | 1970-01-01T00:00:05 | 6.0 |
|
|
| b | 1970-01-01T00:00:10 | 8.0 |
|
|
+--------------+---------------------+-------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') sum by ("Host") ({"otel.m"});
|
|
|
|
+------+---------------------+-------------------+
|
|
| Host | ts.time | sum(otel.m.v.val) |
|
|
+------+---------------------+-------------------+
|
|
| h1 | 1970-01-01T00:00:00 | 4.0 |
|
|
| h1 | 1970-01-01T00:00:05 | 10.0 |
|
|
| h1 | 1970-01-01T00:00:10 | 16.0 |
|
|
| h2 | 1970-01-01T00:00:00 | 2.0 |
|
|
| h2 | 1970-01-01T00:00:05 | 5.0 |
|
|
| h2 | 1970-01-01T00:00:10 | 9.0 |
|
|
+------+---------------------+-------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') sum by (host) ({"otel.m"});
|
|
|
|
+------+---------------------+-------------------+
|
|
| host | ts.time | sum(otel.m.v.val) |
|
|
+------+---------------------+-------------------+
|
|
| x | 1970-01-01T00:00:00 | 3.0 |
|
|
| x | 1970-01-01T00:00:05 | 9.0 |
|
|
| x | 1970-01-01T00:00:10 | 17.0 |
|
|
| y | 1970-01-01T00:00:00 | 3.0 |
|
|
| y | 1970-01-01T00:00:05 | 6.0 |
|
|
| y | 1970-01-01T00:00:10 | 8.0 |
|
|
+------+---------------------+-------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') sum without ("Host") ({"otel.m"});
|
|
|
|
+------+--------------+---------------------+-------------------+
|
|
| host | service.name | ts.time | sum(otel.m.v.val) |
|
|
+------+--------------+---------------------+-------------------+
|
|
| x | a | 1970-01-01T00:00:00 | 3.0 |
|
|
| x | a | 1970-01-01T00:00:05 | 9.0 |
|
|
| x | a | 1970-01-01T00:00:10 | 17.0 |
|
|
| y | b | 1970-01-01T00:00:00 | 3.0 |
|
|
| y | b | 1970-01-01T00:00:05 | 6.0 |
|
|
| y | b | 1970-01-01T00:00:10 | 8.0 |
|
|
+------+--------------+---------------------+-------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') -{"otel.m"};
|
|
|
|
+--------------+------+------+---------------------+-----------+
|
|
| service.name | Host | host | ts.time | (- v.val) |
|
|
+--------------+------+------+---------------------+-----------+
|
|
| a | h1 | x | 1970-01-01T00:00:00 | -1.0 |
|
|
| a | h1 | x | 1970-01-01T00:00:05 | -4.0 |
|
|
| a | h1 | x | 1970-01-01T00:00:10 | -8.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:00 | -2.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:05 | -5.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:10 | -9.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:00 | -3.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:05 | -6.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:10 | -8.0 |
|
|
+--------------+------+------+---------------------+-----------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') 2 * {"otel.m"};
|
|
|
|
+--------------+------+------+---------------------+--------------------+
|
|
| service.name | Host | host | ts.time | Float64(2) * v.val |
|
|
+--------------+------+------+---------------------+--------------------+
|
|
| a | h1 | x | 1970-01-01T00:00:00 | 2.0 |
|
|
| a | h1 | x | 1970-01-01T00:00:05 | 8.0 |
|
|
| a | h1 | x | 1970-01-01T00:00:10 | 16.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:00 | 4.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:05 | 10.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:10 | 18.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:00 | 6.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:05 | 12.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:10 | 16.0 |
|
|
+--------------+------+------+---------------------+--------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') {"otel.m"} - 1;
|
|
|
|
+--------------+------+------+---------------------+--------------------+
|
|
| service.name | Host | host | ts.time | v.val - Float64(1) |
|
|
+--------------+------+------+---------------------+--------------------+
|
|
| a | h1 | x | 1970-01-01T00:00:00 | 0.0 |
|
|
| a | h1 | x | 1970-01-01T00:00:05 | 3.0 |
|
|
| a | h1 | x | 1970-01-01T00:00:10 | 7.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:00 | 1.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:05 | 4.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:10 | 8.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:00 | 2.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:05 | 5.0 |
|
|
| b | h1 | y | 1970-01-01T00:00:10 | 7.0 |
|
|
+--------------+------+------+---------------------+--------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') timestamp({"otel.m"});
|
|
|
|
+---------------------+-------+--------------+------+------+
|
|
| ts.time | value | service.name | Host | host |
|
|
+---------------------+-------+--------------+------+------+
|
|
| 1970-01-01T00:00:00 | 0.0 | a | h1 | x |
|
|
| 1970-01-01T00:00:00 | 0.0 | a | h2 | x |
|
|
| 1970-01-01T00:00:00 | 0.0 | b | h1 | y |
|
|
| 1970-01-01T00:00:05 | 5.0 | a | h1 | x |
|
|
| 1970-01-01T00:00:05 | 5.0 | a | h2 | x |
|
|
| 1970-01-01T00:00:05 | 5.0 | b | h1 | y |
|
|
| 1970-01-01T00:00:10 | 10.0 | a | h1 | x |
|
|
| 1970-01-01T00:00:10 | 10.0 | a | h2 | x |
|
|
| 1970-01-01T00:00:10 | 10.0 | b | h1 | y |
|
|
+---------------------+-------+--------------+------+------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') minute({"otel.m"});
|
|
|
|
+---------------------+-----------------------------------+--------------+------+------+
|
|
| ts.time | date_part(Utf8("minute"),ts.time) | service.name | Host | host |
|
|
+---------------------+-----------------------------------+--------------+------+------+
|
|
| 1970-01-01T00:00:00 | 0 | a | h1 | x |
|
|
| 1970-01-01T00:00:00 | 0 | a | h2 | x |
|
|
| 1970-01-01T00:00:00 | 0 | b | h1 | y |
|
|
| 1970-01-01T00:00:05 | 0 | a | h1 | x |
|
|
| 1970-01-01T00:00:05 | 0 | a | h2 | x |
|
|
| 1970-01-01T00:00:05 | 0 | b | h1 | y |
|
|
| 1970-01-01T00:00:10 | 0 | a | h1 | x |
|
|
| 1970-01-01T00:00:10 | 0 | a | h2 | x |
|
|
| 1970-01-01T00:00:10 | 0 | b | h1 | y |
|
|
+---------------------+-----------------------------------+--------------+------+------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (5, 10, '5s') sum by ("service.name") (increase({"otel.m"}[10s]));
|
|
|
|
+--------------+---------------------+--------------------------------------------------------------+
|
|
| service.name | ts.time | sum(prom_increase(ts.time_range,v.val,ts.time,Int64(10000))) |
|
|
+--------------+---------------------+--------------------------------------------------------------+
|
|
| a | 1970-01-01T00:00:05 | 9.0 |
|
|
| a | 1970-01-01T00:00:10 | 16.0 |
|
|
| b | 1970-01-01T00:00:05 | 6.0 |
|
|
| b | 1970-01-01T00:00:10 | 4.0 |
|
|
+--------------+---------------------+--------------------------------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') scalar(sum({"otel.m"})) * {"otel.m", "Host"="h2"};
|
|
|
|
+--------------+------+------+---------------------+-------------------------------------------+
|
|
| service.name | Host | host | ts.time | lhs.scalar(sum(otel.m.v.val)) * rhs.v.val |
|
|
+--------------+------+------+---------------------+-------------------------------------------+
|
|
| a | h2 | x | 1970-01-01T00:00:00 | 12.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:05 | 75.0 |
|
|
| a | h2 | x | 1970-01-01T00:00:10 | 225.0 |
|
|
+--------------+------+------+---------------------+-------------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') absent({"otel.m", "service.name"="c"});
|
|
|
|
+---------------------+-------+--------------+
|
|
| ts.time | v.val | service.name |
|
|
+---------------------+-------+--------------+
|
|
| 1970-01-01T00:00:00 | 1.0 | c |
|
|
| 1970-01-01T00:00:05 | 1.0 | c |
|
|
| 1970-01-01T00:00:10 | 1.0 | c |
|
|
+---------------------+-------+--------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
TQL EVAL (0, 10, '5s') histogram_quantile(0.5, {"otel.h"});
|
|
|
|
+---------------------+--------------+-------+
|
|
| ts.time | service.name | v.val |
|
|
+---------------------+--------------+-------+
|
|
| 1970-01-01T00:00:00 | a | 0.55 |
|
|
| 1970-01-01T00:00:05 | a | 0.55 |
|
|
| 1970-01-01T00:00:10 | a | 0.775 |
|
|
+---------------------+--------------+-------+
|
|
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
-- SQLNESS REPLACE (partitioning.*) REDACTED
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
TQL EXPLAIN (0, 10, '5s') {"otel.m"} and {"otel.m", "Host"="h1"};
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| LeftSemi Join: otel.m.Host = otel.m.Host, otel.m.host = otel.m.host, otel.m.service.name = otel.m.service.name, otel.m.ts.time = otel.m.ts.time_|
|
|
|_|_Aggregate: groupBy=[[otel.m.ts.time, otel.m.service.name, otel.m.Host, otel.m.host, otel.m.v.val]], aggr=[[]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Distinct:_|
|
|
|_|_PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[ts.time]_|
|
|
|_|_PromSeriesDivide: tags=["service.name", "Host", "host"]_|
|
|
|_|_Sort: otel.m.service.name ASC NULLS FIRST, otel.m.Host ASC NULLS FIRST, otel.m.host ASC NULLS FIRST, otel.m.ts.time ASC NULLS FIRST_|
|
|
|_|_Filter: otel.m.ts.time >= TimestampMillisecond(-299999, None) AND otel.m.ts.time <= TimestampMillisecond(10000, None)_|
|
|
|_|_TableScan: otel.m, partial_filters=[otel.m.ts.time >= TimestampMillisecond(-299999, None), otel.m.ts.time <= TimestampMillisecond(10000, None)]_|
|
|
|_| ]]_|
|
|
|_|_Projection: otel.m.ts.time, otel.m.service.name, otel.m.Host, otel.m.host_|
|
|
|_|_PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[ts.time]_|
|
|
|_|_PromSeriesDivide: tags=["service.name", "Host", "host"]_|
|
|
|_|_Sort: otel.m.service.name ASC NULLS FIRST, otel.m.Host ASC NULLS FIRST, otel.m.host ASC NULLS FIRST, otel.m.ts.time ASC NULLS FIRST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Filter: otel.m.Host = Utf8("h1") AND otel.m.ts.time >= TimestampMillisecond(-299999, None) AND otel.m.ts.time <= TimestampMillisecond(10000, None)_|
|
|
|_|_TableScan: otel.m, partial_filters=[otel.m.Host = Utf8("h1"), otel.m.ts.time >= TimestampMillisecond(-299999, None), otel.m.ts.time <= TimestampMillisecond(10000, None)] |
|
|
|_| ]]_|
|
|
| physical_plan | HashJoinExec: mode=CollectLeft, join_type=RightSemi, on=[(Host@2, Host@2), (host@3, host@3), (service.name@1, service.name@1), (ts.time@0, ts.time@0)], NullsEqual: true_|
|
|
|_|_CoalescePartitionsExec_|
|
|
|_|_ProjectionExec: expr=[ts.time@0 as ts.time, service.name@1 as service.name, Host@2 as Host, host@3 as host]_|
|
|
|_|_PromInstantManipulateExec: range=[0..10000], lookback=[300000], interval=[5000], time index=[ts.time]_|
|
|
|_|_PromSeriesDivideExec: tags=["service.name", "Host", "host"]_|
|
|
|_|_SortExec: expr=[service.name@1 ASC, Host@2 ASC, host@3 ASC, ts.time@0 ASC], preserve_REDACTED
|
|
|_|_RepartitionExec: REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_AggregateExec: mode=FinalPartitioned, gby=[ts.time@0 as ts.time, service.name@1 as service.name, Host@2 as Host, host@3 as host, v.val@4 as v.val], aggr=[]_|
|
|
|_|_RepartitionExec: REDACTED
|
|
|_|_AggregateExec: mode=Partial, gby=[ts.time@0 as ts.time, service.name@1 as service.name, Host@2 as Host, host@3 as host, v.val@4 as v.val], aggr=[]_|
|
|
|_|_RepartitionExec: REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
-- SQLNESS REPLACE (partitioning.*) REDACTED
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
TQL EXPLAIN (0, 10, '5s') topk(1, {"otel.m"});
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| Projection: otel.m.v.val, otel.m.service.name, otel.m.Host, otel.m.host, otel.m.ts.time_|
|
|
|_|_Sort: otel.m.ts.time ASC NULLS LAST, row_number() PARTITION BY [otel.m.ts.time] ORDER BY [isnan(otel.m.v.val) ASC NULLS FIRST, otel.m.v.val DESC NULLS FIRST, otel.m.service.name DESC NULLS FIRST, otel.m.Host DESC NULLS FIRST, otel.m.host DESC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ASC NULLS LAST_|
|
|
|_|_Filter: CAST(row_number() PARTITION BY [otel.m.ts.time] ORDER BY [isnan(otel.m.v.val) ASC NULLS FIRST, otel.m.v.val DESC NULLS FIRST, otel.m.service.name DESC NULLS FIRST, otel.m.Host DESC NULLS FIRST, otel.m.host DESC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS Float64) <= Float64(1)_|
|
|
|_|_WindowAggr: windowExpr=[[row_number() PARTITION BY [otel.m.ts.time] ORDER BY [isnan(otel.m.v.val) ASC NULLS FIRST, otel.m.v.val DESC NULLS FIRST, otel.m.service.name DESC NULLS FIRST, otel.m.Host DESC NULLS FIRST, otel.m.host DESC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[ts.time]_|
|
|
|_|_PromSeriesDivide: tags=["service.name", "Host", "host"]_|
|
|
|_|_Sort: otel.m.service.name ASC NULLS FIRST, otel.m.Host ASC NULLS FIRST, otel.m.host ASC NULLS FIRST, otel.m.ts.time ASC NULLS FIRST_|
|
|
|_|_Filter: otel.m.ts.time >= TimestampMillisecond(-299999, None) AND otel.m.ts.time <= TimestampMillisecond(10000, None)_|
|
|
|_|_TableScan: otel.m, partial_filters=[otel.m.ts.time >= TimestampMillisecond(-299999, None), otel.m.ts.time <= TimestampMillisecond(10000, None)]_|
|
|
|_| ]]_|
|
|
| physical_plan | ProjectionExec: expr=[v.val@4 as v.val, service.name@1 as service.name, Host@2 as Host, host@3 as host, ts.time@0 as ts.time]_|
|
|
|_|_SortPreservingMergeExec: [ts.time@0 ASC NULLS LAST, row_number() PARTITION BY [otel.m.ts.time] ORDER BY [isnan(otel.m.v.val) ASC NULLS FIRST, otel.m.v.val DESC NULLS FIRST, otel.m.service.name DESC NULLS FIRST, otel.m.Host DESC NULLS FIRST, otel.m.host DESC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@5 ASC NULLS LAST]_|
|
|
|_|_FilterExec: CAST(row_number() PARTITION BY [otel.m.ts.time] ORDER BY [isnan(otel.m.v.val) ASC NULLS FIRST, otel.m.v.val DESC NULLS FIRST, otel.m.service.name DESC NULLS FIRST, otel.m.Host DESC NULLS FIRST, otel.m.host DESC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW@5 AS Float64) <= 1_|
|
|
|_|_BoundedWindowAggExec: wdw=[row_number() PARTITION BY [otel.m.ts.time] ORDER BY [isnan(otel.m.v.val) ASC NULLS FIRST, otel.m.v.val DESC NULLS FIRST, otel.m.service.name DESC NULLS FIRST, otel.m.Host DESC NULLS FIRST, otel.m.host DESC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW: Field { "row_number() PARTITION BY [otel.m.ts.time] ORDER BY [isnan(otel.m.v.val) ASC NULLS FIRST, otel.m.v.val DESC NULLS FIRST, otel.m.service.name DESC NULLS FIRST, otel.m.Host DESC NULLS FIRST, otel.m.host DESC NULLS FIRST] ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW": UInt64 }, frame: ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW], mode=[Sorted] |
|
|
|_|_SortExec: expr=[ts.time@0 ASC NULLS LAST, isnan(v.val@4) ASC, v.val@4 DESC, service.name@1 DESC, Host@2 DESC, host@3 DESC], preserve_REDACTED
|
|
|_|_RepartitionExec: REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
-- SQLNESS REPLACE (partitioning.*) REDACTED
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
TQL EXPLAIN (5, 10, '5s') sum by ("service.name") (increase({"otel.m"}[10s]));
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| MergeSort: otel.m.service.name ASC NULLS LAST, otel.m.ts.time ASC NULLS LAST_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| Sort: otel.m.service.name ASC NULLS LAST, otel.m.ts.time ASC NULLS LAST_|
|
|
|_|_Aggregate: groupBy=[[otel.m.service.name, otel.m.ts.time]], aggr=[[sum(prom_increase(ts.time_range,v.val,ts.time,Int64(10000)))]]_|
|
|
|_|_Filter: prom_increase(ts.time_range,v.val,ts.time,Int64(10000)) IS NOT NULL_|
|
|
|_|_Projection: otel.m.ts.time, prom_increase(ts.time_range, v.val, otel.m.ts.time, Int64(10000)) AS prom_increase(ts.time_range,v.val,ts.time,Int64(10000)), otel.m.service.name, otel.m.Host, otel.m.host |
|
|
|_|_PromRangeManipulate: req range=[5000..10000], interval=[5000], eval range=[10000], time index=[ts.time], values=["v.val"]_|
|
|
|_|_PromSeriesNormalize: offset=[0], time index=[ts.time], filter NaN: [true]_|
|
|
|_|_PromSeriesDivide: tags=["service.name", "Host", "host"]_|
|
|
|_|_Sort: otel.m.service.name ASC NULLS FIRST, otel.m.Host ASC NULLS FIRST, otel.m.host ASC NULLS FIRST, otel.m.ts.time ASC NULLS FIRST_|
|
|
|_|_Filter: otel.m.ts.time >= TimestampMillisecond(-4999, None) AND otel.m.ts.time <= TimestampMillisecond(10000, None)_|
|
|
|_|_TableScan: otel.m, partial_filters=[otel.m.ts.time >= TimestampMillisecond(-4999, None), otel.m.ts.time <= TimestampMillisecond(10000, None)]_|
|
|
|_| ]]_|
|
|
| physical_plan | MergeSortExec: [service.name@0 ASC NULLS LAST, ts.time@1 ASC NULLS LAST]_|
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
-- SQLNESS REPLACE (peers.*) REDACTED
|
|
-- SQLNESS REPLACE (partitioning.*) REDACTED
|
|
-- SQLNESS REPLACE (-+) -
|
|
-- SQLNESS REPLACE (\s\s+) _
|
|
TQL EXPLAIN (0, 10, '5s') histogram_quantile(0.5, {"otel.h"});
|
|
|
|
+-+-+
|
|
| plan_type_| plan_|
|
|
+-+-+
|
|
| logical_plan_| HistogramFold: le=le, field=v.val, quantile=0.5_|
|
|
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
|
|_| PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[ts.time]_|
|
|
|_|_PromSeriesDivide: tags=["service.name", "le"]_|
|
|
|_|_Sort: otel.h.service.name ASC NULLS FIRST, otel.h.le ASC NULLS FIRST, otel.h.ts.time ASC NULLS FIRST_|
|
|
|_|_Filter: otel.h.ts.time >= TimestampMillisecond(-299999, None) AND otel.h.ts.time <= TimestampMillisecond(10000, None)_|
|
|
|_|_TableScan: otel.h, partial_filters=[otel.h.ts.time >= TimestampMillisecond(-299999, None), otel.h.ts.time <= TimestampMillisecond(10000, None)] |
|
|
|_| ]]_|
|
|
| physical_plan | HistogramFoldExec: le=@2, field=@3, quantile=0.5_|
|
|
|_|_RepartitionExec: REDACTED
|
|
|_|_SortExec: expr=[service.name@1 ASC NULLS LAST, ts.time@0 ASC NULLS LAST, TRY_CAST(le@2 AS Float64) ASC NULLS LAST], preserve_REDACTED
|
|
|_|_MergeScanExec: REDACTED
|
|
|_|_|
|
|
+-+-+
|
|
|
|
DROP TABLE "otel.m";
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE "otel.h";
|
|
|
|
Affected Rows: 0
|
|
|