mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 04:12:55 +00:00
fix(promql): handle field column projection with correct qualifier (#6183)
* fix(promql): handle field column projection with correct qualifier * test: add sqlness tests
This commit is contained in:
64
tests/cases/standalone/common/promql/or_operation.result
Normal file
64
tests/cases/standalone/common/promql/or_operation.result
Normal file
@@ -0,0 +1,64 @@
|
||||
create table http_requests (
|
||||
ts timestamp time index,
|
||||
job string,
|
||||
instance string,
|
||||
env string,
|
||||
greptime_value double,
|
||||
primary key (job, instance, env)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into http_requests values
|
||||
(3000000, "api", "0", "production", 100),
|
||||
(3000000, "api", "0", "production", 200),
|
||||
(3000000, "api", "0", "canary", 300),
|
||||
(3000000, "api", "0", "canary", 400),
|
||||
(3000000, "app", "2", "production", 500),
|
||||
(3000000, "app", "2", "production", 600),
|
||||
(3000000, "app", "2", "canary", 700),
|
||||
(3000000, "app", "2", "canary", 800);
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="api",instance="0",env="production"} + 5;
|
||||
|
||||
+-----+----------+------------+---------------------+-----------------------------+
|
||||
| job | instance | env | ts | greptime_value + Float64(5) |
|
||||
+-----+----------+------------+---------------------+-----------------------------+
|
||||
| api | 0 | production | 1970-01-01T00:50:00 | 205.0 |
|
||||
+-----+----------+------------+---------------------+-----------------------------+
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="web",instance="1",env="production"} * 5;
|
||||
|
||||
++
|
||||
++
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="web",instance="1",env="production"} * 5 or http_requests{job="api",instance="0",env="production"} + 5;
|
||||
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
| ts | env | greptime_value * Float64(5) | instance | job |
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
| 1970-01-01T00:50:00 | production | 205.0 | 0 | api |
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="api",instance="0",env="production"} + 5 or http_requests{job="web",instance="1",env="production"} * 5;
|
||||
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
| ts | env | greptime_value + Float64(5) | instance | job |
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
| 1970-01-01T00:50:00 | production | 205.0 | 0 | api |
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="web",instance="1",env="production"} * 5 or http_requests{job="web",instance="2",env="production"} * 3 or http_requests{job="api",instance="0",env="production"} + 5;
|
||||
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
| ts | env | greptime_value * Float64(5) | instance | job |
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
| 1970-01-01T00:50:00 | production | 205.0 | 0 | api |
|
||||
+---------------------+------------+-----------------------------+----------+-----+
|
||||
|
||||
drop table http_requests;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
30
tests/cases/standalone/common/promql/or_operation.sql
Normal file
30
tests/cases/standalone/common/promql/or_operation.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
create table http_requests (
|
||||
ts timestamp time index,
|
||||
job string,
|
||||
instance string,
|
||||
env string,
|
||||
greptime_value double,
|
||||
primary key (job, instance, env)
|
||||
);
|
||||
|
||||
insert into http_requests values
|
||||
(3000000, "api", "0", "production", 100),
|
||||
(3000000, "api", "0", "production", 200),
|
||||
(3000000, "api", "0", "canary", 300),
|
||||
(3000000, "api", "0", "canary", 400),
|
||||
(3000000, "app", "2", "production", 500),
|
||||
(3000000, "app", "2", "production", 600),
|
||||
(3000000, "app", "2", "canary", 700),
|
||||
(3000000, "app", "2", "canary", 800);
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="api",instance="0",env="production"} + 5;
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="web",instance="1",env="production"} * 5;
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="web",instance="1",env="production"} * 5 or http_requests{job="api",instance="0",env="production"} + 5;
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="api",instance="0",env="production"} + 5 or http_requests{job="web",instance="1",env="production"} * 5;
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="web",instance="1",env="production"} * 5 or http_requests{job="web",instance="2",env="production"} * 3 or http_requests{job="api",instance="0",env="production"} + 5;
|
||||
|
||||
drop table http_requests;
|
||||
Reference in New Issue
Block a user