mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-29 14:14:13 +00:00
test(sqlness): run the native route against its own partial corpus
Expected results for the native PromQL route live in tests/narthex-native-results, a partial corpus of its own: only the cases whose native plan or diagnostics differ from the mainline expectation are recorded there, and each .sql links back to tests/cases when the statements are identical. tests/cases stays identical to the mainline, which is what the sqlness runs that never select the native route read. The sqlness runner learns --enable-native-promql, which renders the server option and attaches the request hint together so a run cannot ask for one half. This squashes the branch: the intermediate recordings it went through are not history worth keeping, and the tree it ends with is what the job reads. Signed-off-by: discord9 <discord9@163.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# Copyright 2023 Greptime Team
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
name: Narthex Native CI (nightly)
|
||||
|
||||
# GitHub runs a `schedule` trigger only from the repository's default branch, so a schedule declared
|
||||
# in a workflow that exists only on `narthex` would never fire. This file belongs on the default
|
||||
# branch, and it checks out `narthex` itself: the schedule selects the branch, not the file's
|
||||
# location.
|
||||
on:
|
||||
schedule:
|
||||
- cron: "30 19 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: The narthex revision to test
|
||||
required: false
|
||||
default: narthex
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
correctness:
|
||||
name: Native correctness on narthex
|
||||
uses: ./.github/workflows/narthex-native-ci.yml
|
||||
with:
|
||||
# The reusable workflow checks this out for every build and test job.
|
||||
candidate_ref: ${{ inputs.ref || 'narthex' }}
|
||||
secrets: inherit
|
||||
@@ -0,0 +1,176 @@
|
||||
# Copyright 2023 Greptime Team
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
name: Narthex Native CI
|
||||
|
||||
# PromQL is moving to a native series-major route on `narthex`, but the legacy route is still a
|
||||
# fallback: a suite that passes with the switch on does not by itself show that a statement ran
|
||||
# natively. These jobs check the native route directly, each on its own axis:
|
||||
#
|
||||
# promql-sqlness the native corpus in tests/narthex-native-results, every environment
|
||||
# vm-performance candidate, the narthex baseline and VictoriaMetrics on one machine
|
||||
#
|
||||
# The measurements that need a dedicated machine live in a separate reusable workflow so this file
|
||||
# stays about correctness.
|
||||
|
||||
on:
|
||||
# A caller supplies the ref to test, which is how the nightly job selects `narthex` from the
|
||||
# default branch.
|
||||
workflow_call:
|
||||
inputs:
|
||||
candidate_ref:
|
||||
description: The GreptimeDB revision to build and test
|
||||
type: string
|
||||
required: false
|
||||
default: ""
|
||||
pull_request:
|
||||
branches: [narthex]
|
||||
push:
|
||||
branches: [narthex]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
baseline_ref:
|
||||
description: GreptimeDB baseline SHA or ref for the performance comparison
|
||||
required: false
|
||||
default: ""
|
||||
candidate_ref:
|
||||
description: GreptimeDB candidate SHA or ref
|
||||
required: false
|
||||
default: ""
|
||||
# GitHub runs a schedule from the default branch only, so this trigger does not fire from
|
||||
# `narthex` itself. The nightly job checks out `narthex` explicitly and is registered by
|
||||
# `.github/workflows/narthex-native-ci-nightly.yml` on the default branch.
|
||||
schedule:
|
||||
- cron: "30 19 * * *"
|
||||
|
||||
concurrency:
|
||||
group: narthex-native-ci-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
# The native route is selected per request; the runner turns both halves on from one flag.
|
||||
NARTHEX_BRANCH: narthex
|
||||
|
||||
jobs:
|
||||
# One build feeds every correctness job below, so the three of them agree on the binary.
|
||||
build:
|
||||
name: Build greptime and sqlness-runner
|
||||
if: ${{ github.repository == 'GreptimeTeam/greptimedb' && (github.event_name != 'pull_request' || github.event.pull_request.draft == false || github.run_attempt > 1) }}
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
ref: ${{ inputs.candidate_ref || github.event.pull_request.head.sha || github.sha }}
|
||||
- name: Report the commit under test
|
||||
run: |
|
||||
# The backticks are markdown for the summary, not command substitution.
|
||||
# shellcheck disable=SC2016
|
||||
{
|
||||
printf '## Narthex native CI\n\n'
|
||||
printf -- '- Tested commit: `%s`\n' "$(git rev-parse HEAD)"
|
||||
printf -- '- Base ref: `%s`\n' "${{ github.base_ref || env.NARTHEX_BRANCH }}"
|
||||
} >>"$GITHUB_STEP_SUMMARY"
|
||||
- uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: protoc@3.23.4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
shared-key: "narthex-native-ci"
|
||||
cache-all-crates: "true"
|
||||
cache-workspace-crates: "true"
|
||||
- name: Build binaries
|
||||
run: cargo build --bin greptime --bin sqlness-runner
|
||||
- name: Pack binaries
|
||||
run: |
|
||||
mkdir -p bins
|
||||
cp target/debug/greptime bins/
|
||||
cp target/debug/sqlness-runner bins/
|
||||
chmod +x bins/greptime bins/sqlness-runner
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: narthex-native-bins
|
||||
path: bins/
|
||||
if-no-files-found: error
|
||||
retention-days: 3
|
||||
|
||||
promql-sqlness:
|
||||
name: PromQL sqlness (native expectations)
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 90
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
ref: ${{ inputs.candidate_ref || github.event.pull_request.head.sha || github.sha }}
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: narthex-native-bins
|
||||
path: bins
|
||||
- name: Restore the executable bit
|
||||
# An artifact does not carry file modes, so a downloaded binary is not executable.
|
||||
run: chmod +x bins/greptime bins/sqlness-runner
|
||||
- name: Run every environment on the native route
|
||||
run: |
|
||||
set -o pipefail
|
||||
# The corpus this job compares against is `tests/narthex-native-results`, a partial corpus
|
||||
# whose `.result` files are the native route's own output. `tests/cases` stays identical to
|
||||
# the mainline, which is what the sqlness runs that never select the native route read.
|
||||
RUST_BACKTRACE=1 ./bins/sqlness-runner bare \
|
||||
-c tests/narthex-native-results \
|
||||
--bins-dir ./bins \
|
||||
--enable-native-promql \
|
||||
--preserve-state 2>&1 | tee "$RUNNER_TEMP/sqlness-native.log"
|
||||
# `tee` would otherwise hide a runner that never started: an empty case set exits 0.
|
||||
grep -Fq -- "Case tests/narthex-native-results/" "$RUNNER_TEMP/sqlness-native.log"
|
||||
- name: Record what the run changed
|
||||
if: always()
|
||||
# sqlness writes the output it produced back into the `.result` it compared against, so a
|
||||
# difference here is the material for updating a golden. Recorded only, never a gate.
|
||||
run: git diff -- tests/narthex-native-results >"$RUNNER_TEMP/results.diff" || true
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: narthex-sqlness-native
|
||||
path: |
|
||||
${{ runner.temp }}/sqlness-native.log
|
||||
${{ runner.temp }}/results.diff
|
||||
retention-days: 7
|
||||
|
||||
vm-performance:
|
||||
name: vmbench lite (candidate, narthex baseline, VictoriaMetrics)
|
||||
needs: build
|
||||
# Manual only, for now. The benchmark provisions an ephemeral cloud runner and needs the Aliyun
|
||||
# or AWS credentials and a runner token, so it cannot run on a pull request from a fork; and it
|
||||
# does not measure this build yet - with no image tags passed it compares the published
|
||||
# `greptime/greptimedb:latest` against `greptime/greptimedb:v1.2.1`. Running that on a schedule
|
||||
# would rent a machine every night to measure something else, so the schedule runs correctness
|
||||
# only until a candidate image is wired in.
|
||||
if: ${{ github.event_name == 'workflow_dispatch' }}
|
||||
uses: ./.github/workflows/vmbench-long-range.yml
|
||||
with:
|
||||
# No image tags are passed: the benchmark measures the published `greptime/greptimedb:latest`
|
||||
# against its default comparison tag, not the binaries this workflow builds. Building and
|
||||
# pushing an image for the ref under test is not wired here yet.
|
||||
range_preset: 1w
|
||||
compare_greptimedb: true
|
||||
run_victoriametrics: true
|
||||
secrets: inherit
|
||||
@@ -1,5 +1,103 @@
|
||||
name: VMBench Long Range
|
||||
on:
|
||||
# A caller repeats only the inputs it cares about; the rest keep their defaults below.
|
||||
workflow_call:
|
||||
# `choice` and `options` belong to `workflow_dispatch`; a called workflow takes `string`,
|
||||
# `number` or `boolean`, so the allowed values move into the description. Every input has a
|
||||
# default and is therefore optional: a caller repeats only what it wants to override.
|
||||
inputs:
|
||||
run_greptimedb:
|
||||
description: Run GreptimeDB
|
||||
type: boolean
|
||||
default: true
|
||||
required: false
|
||||
run_victoriametrics:
|
||||
description: Run VictoriaMetrics
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
range_preset:
|
||||
description: 'Long-range query window (fixed dataset per preset): 1w or 1mo'
|
||||
type: string
|
||||
default: 1w
|
||||
required: false
|
||||
compare_greptimedb:
|
||||
description: Compare baseline and candidate sequentially on the same host (adds one full GreptimeDB run)
|
||||
type: boolean
|
||||
default: false
|
||||
required: false
|
||||
baseline_greptimedb_tag:
|
||||
description: Baseline Docker Hub greptime/greptimedb tag; required when comparison is enabled
|
||||
type: string
|
||||
default: v1.2.1
|
||||
required: false
|
||||
greptimedb_tag:
|
||||
description: Candidate Docker Hub greptime/greptimedb tag
|
||||
type: string
|
||||
default: latest
|
||||
required: false
|
||||
victoriametrics_tag:
|
||||
description: Docker Hub victoriametrics/victoria-metrics tag or tag@sha256 digest
|
||||
type: string
|
||||
default: v1.114.0@sha256:227ad53fd57a4b4430624898a1be0cac39431e1235fa0dc92f567cce38969344
|
||||
required: false
|
||||
runtime_image:
|
||||
description: 'Runtime image: auto = AWS ECR Public or Aliyun ACR by provider; explicit tag/digest overrides'
|
||||
type: string
|
||||
default: auto
|
||||
required: false
|
||||
provider:
|
||||
description: 'Cloud provider for the benchmark runner: Aliyun or AWS'
|
||||
type: string
|
||||
default: Aliyun
|
||||
required: false
|
||||
instance_type:
|
||||
description: 'Instance type; auto = Aliyun: ecs.c9i.2xlarge, AWS: c7i.2xlarge (both 8 vCPU / 16 GiB). Enter a specific type to override.'
|
||||
type: string
|
||||
default: auto
|
||||
required: false
|
||||
benchmark_root:
|
||||
description: Absolute disk-backed work directory (outside the o11ybench checkout)
|
||||
type: string
|
||||
default: /home/runner/benchmark-data
|
||||
required: false
|
||||
system_disk_gib:
|
||||
description: 'System disk GiB: auto (or 0) = 80; enter 20..2048 to override'
|
||||
type: string
|
||||
default: auto
|
||||
required: false
|
||||
benchmark_timeout_minutes:
|
||||
description: Benchmark job timeout in minutes (1..360)
|
||||
type: number
|
||||
default: 360
|
||||
required: false
|
||||
janitor_ttl_hours:
|
||||
description: Instance lifetime before janitor eligibility (1..168 hours; at least timeout + 2h)
|
||||
type: number
|
||||
default: 8
|
||||
required: false
|
||||
db_cpus:
|
||||
description: CPU limit per DB container
|
||||
type: string
|
||||
default: '8'
|
||||
required: false
|
||||
db_memory:
|
||||
description: Memory limit per DB container
|
||||
type: string
|
||||
default: 16g
|
||||
required: false
|
||||
secrets:
|
||||
# The credentials the provision step reads; a caller passes them with `secrets: inherit`.
|
||||
AWS_ACCESS_KEY_ID:
|
||||
required: false
|
||||
AWS_SECRET_ACCESS_KEY:
|
||||
required: false
|
||||
ALICLOUD_ECS_ACCESS_KEY_ID:
|
||||
required: false
|
||||
ALICLOUD_ECS_ACCESS_KEY_SECRET:
|
||||
required: false
|
||||
GH_PERSONAL_ACCESS_TOKEN:
|
||||
required: false
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
greptimedb_storage:
|
||||
|
||||
@@ -4,6 +4,9 @@ server_addr = "{addrs.grpc_addr}"
|
||||
|
||||
[query]
|
||||
parallelism = 4
|
||||
{{ if enable_native_promql }}
|
||||
experimental_native_promql = true
|
||||
{{ endif }}
|
||||
|
||||
[event_recorder]
|
||||
event_types = []
|
||||
|
||||
@@ -4,6 +4,9 @@ require_lease_before_startup = true
|
||||
|
||||
[query]
|
||||
parallelism = 4
|
||||
{{ if enable_native_promql }}
|
||||
experimental_native_promql = true
|
||||
{{ endif }}
|
||||
|
||||
[[region_engine]]
|
||||
[region_engine.mito]
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# Native PromQL expectations
|
||||
|
||||
A partial corpus for the native PromQL route: each case here carries the `.result` the native route
|
||||
produces, so `sqlness-runner bare -c tests/narthex-native-results --enable-native-promql` compares
|
||||
against native output without touching `tests/cases`.
|
||||
|
||||
`tests/cases` is the corpus the mainline sqlness runs read, and those runs never select the native
|
||||
route, so a native expectation recorded there fails every one of them. That is why this tree exists
|
||||
separately, and why it holds only the cases whose native output differs from the mainline
|
||||
expectation: a case that agrees needs no second copy.
|
||||
|
||||
## Layout
|
||||
|
||||
- `standalone/…` and `distributed/…` mirror the corpus paths. A case that both environments answer
|
||||
the same way lives under `standalone/common/…` with a `distributed/common` symlink to it; a case
|
||||
whose plan differs per environment is recorded on both sides instead (`standalone/promql/…` and
|
||||
`distributed/promql/…`), because one shared `.result` cannot hold both.
|
||||
- A case's `.sql` is a symlink into `tests/cases` whenever the statements are identical, so a
|
||||
statement change on the mainline is picked up here on the next run. The four cases whose
|
||||
statements need sqlness directives the mainline copy does not carry (`SORT_RESULT` for a
|
||||
row-ordered aggregate, `REPLACE` for a diagnostic) keep a real file.
|
||||
|
||||
## Updating a golden
|
||||
|
||||
Run the job (or, locally, the same `sqlness-runner` invocation), then read `git diff --
|
||||
tests/narthex-native-results`: sqlness writes what it produced into the `.result` it compared
|
||||
against, so the diff is the new expectation. Review it against the plan structure the change
|
||||
intended, then commit it. A `.sql` edit that adds or changes a `-- SQLNESS …` directive must update
|
||||
the `.result` too: sqlness echoes the directive line, and a stale echo fails the comparison before
|
||||
any answer is read.
|
||||
|
||||
## Known differences from the legacy route
|
||||
|
||||
- A source-free statement (`time()`, `label_replace(vector(1), …)`) is planned natively in one
|
||||
environment and keeps the existing plan in the other; those cases are recorded per environment.
|
||||
- Diagnostic text from the native runtime carries no evaluation timestamp, while the legacy runtime
|
||||
appends ` at <ms> ms`. The native expectation records the native wording.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/explain/step_aggr_advance.sql
|
||||
@@ -0,0 +1,433 @@
|
||||
CREATE TABLE http_requests (
|
||||
ts timestamp(3) time index,
|
||||
host STRING,
|
||||
idc STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(host, idc),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE FLOW calc_reqs SINK TO cnt_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - '1m'::interval, now(), '5s') count_values("status_code", http_requests);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SELECT source_table_names FROM information_schema.flows WHERE flow_name = 'calc_reqs';
|
||||
|
||||
+-------------------------------+
|
||||
| source_table_names |
|
||||
+-------------------------------+
|
||||
| greptime.public.http_requests |
|
||||
+-------------------------------+
|
||||
|
||||
SHOW CREATE TABLE cnt_reqs;
|
||||
|
||||
+----------+---------------------------------------------------+
|
||||
| Table | Create Table |
|
||||
+----------+---------------------------------------------------+
|
||||
| cnt_reqs | CREATE TABLE IF NOT EXISTS "cnt_reqs" ( |
|
||||
| | "count(http_requests.val)" DOUBLE NULL, |
|
||||
| | "ts" TIMESTAMP(3) NOT NULL, |
|
||||
| | "status_code" STRING NULL, |
|
||||
| | TIME INDEX ("ts"), |
|
||||
| | PRIMARY KEY ("status_code") |
|
||||
| | ) |
|
||||
| | |
|
||||
| | ENGINE=mito |
|
||||
| | WITH( |
|
||||
| | 'comment' = 'Auto created table by flow engine' |
|
||||
| | ) |
|
||||
+----------+---------------------------------------------------+
|
||||
|
||||
-- test if sink table is tql queryable
|
||||
TQL EVAL (now() - '1m'::interval, now(), '5s') count_values("status_code", cnt_reqs);
|
||||
|
||||
+----+--------------------------+-------------+----------+
|
||||
| ts | count(http_requests.val) | status_code | __name__ |
|
||||
+----+--------------------------+-------------+----------+
|
||||
+----+--------------------------+-------------+----------+
|
||||
|
||||
INSERT INTO TABLE http_requests VALUES
|
||||
(now() - '17s'::interval, 'host1', 'idc1', 200),
|
||||
(now() - '17s'::interval, 'host2', 'idc1', 200),
|
||||
(now() - '17s'::interval, 'host3', 'idc2', 200),
|
||||
(now() - '17s'::interval, 'host4', 'idc2', 401),
|
||||
(now() - '13s'::interval, 'host1', 'idc1', 404),
|
||||
(now() - '13s'::interval, 'host2', 'idc1', 401),
|
||||
(now() - '13s'::interval, 'host3', 'idc2', 404),
|
||||
(now() - '13s'::interval, 'host4', 'idc2', 500),
|
||||
(now() - '7s'::interval, 'host1', 'idc1', 200),
|
||||
(now() - '7s'::interval, 'host2', 'idc1', 200),
|
||||
(now() - '7s'::interval, 'host3', 'idc2', 201),
|
||||
(now() - '7s'::interval, 'host4', 'idc2', 201),
|
||||
(now() - '3s'::interval, 'host1', 'idc1', 500),
|
||||
(now() - '3s'::interval, 'host2', 'idc1', 500),
|
||||
(now() - '3s'::interval, 'host3', 'idc2', 500),
|
||||
(now() - '3s'::interval, 'host4', 'idc2', 500);
|
||||
|
||||
Affected Rows: 16
|
||||
|
||||
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
||||
ADMIN FLUSH_FLOW('calc_reqs');
|
||||
|
||||
+-------------------------------+
|
||||
| ADMIN FLUSH_FLOW('calc_reqs') |
|
||||
+-------------------------------+
|
||||
| FLOW_FLUSHED |
|
||||
+-------------------------------+
|
||||
|
||||
-- too much indeterminsticity in the test, so just check that the flow is running
|
||||
SELECT count(*) > 0 FROM cnt_reqs;
|
||||
|
||||
+---------------------+
|
||||
| count(*) > Int64(0) |
|
||||
+---------------------+
|
||||
| true |
|
||||
+---------------------+
|
||||
|
||||
DROP FLOW calc_reqs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE http_requests;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE cnt_reqs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE http_requests_two_vals (
|
||||
ts timestamp(3) time index,
|
||||
host STRING,
|
||||
idc STRING,
|
||||
val DOUBLE,
|
||||
valb DOUBLE,
|
||||
PRIMARY KEY(host, idc),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- should failed with two value columns error
|
||||
CREATE FLOW calc_reqs SINK TO cnt_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - '1m'::interval, now(), '5s') count_values("status_code", http_requests_two_vals);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Unsupported expr type: count_values on multi-value input
|
||||
|
||||
-- should failed with two value columns error
|
||||
-- SQLNESS REPLACE id=[0-9]+ id=[REDACTED]
|
||||
CREATE FLOW calc_reqs SINK TO cnt_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - '1m'::interval, now(), '5s') rate(http_requests_two_vals[5m]);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Invalid query: TQL query only supports one f64 value column, table `greptime.public.http_requests_two_vals`(id=[REDACTED]) has 2 f64 value columns, columns are: [val Float64 null, valb Float64 null]
|
||||
|
||||
SHOW TABLES;
|
||||
|
||||
+------------------------+
|
||||
| Tables_in_public |
|
||||
+------------------------+
|
||||
| http_requests_two_vals |
|
||||
| numbers |
|
||||
+------------------------+
|
||||
|
||||
DROP TABLE http_requests_two_vals;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE http_requests (
|
||||
ts timestamp(3) time index,
|
||||
host STRING,
|
||||
idc STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(host, idc),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE FLOW calc_reqs SINK TO cnt_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (0, 15, '5s') count_values("status_code", http_requests);
|
||||
|
||||
Error: 2000(InvalidSyntax), Invalid TQL syntax: sql parser error: Expected expression containing `now()`, but have Number("0", false)
|
||||
|
||||
-- standalone&distributed have slightly different error message(distributed will print source error as well ("cannot convert float seconds to Duration: value is negative"))
|
||||
-- so duplicate test into two
|
||||
CREATE FLOW calc_reqs SINK TO cnt_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - now(), now()-(now()+'15s'::interval), '5s') count_values("status_code", http_requests);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), The end time must be greater than start time, start: 0, end: -15000
|
||||
|
||||
CREATE FLOW calc_reqs SINK TO cnt_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - now(), now()-now()+'15s'::interval, '5s') count_values("status_code", http_requests);
|
||||
|
||||
Error: 2000(InvalidSyntax), Invalid TQL syntax: Failed to evaluate TQL expression: Failed to extract a timestamp value IntervalMonthDayNano("IntervalMonthDayNano { months: 0, days: 0, nanoseconds: 15000000000 }")
|
||||
|
||||
CREATE FLOW calc_reqs SINK TO cnt_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - now(), now()-(now()-'15s'::interval), '5s') count_values("status_code", http_requests);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SHOW CREATE TABLE cnt_reqs;
|
||||
|
||||
+----------+---------------------------------------------------+
|
||||
| Table | Create Table |
|
||||
+----------+---------------------------------------------------+
|
||||
| cnt_reqs | CREATE TABLE IF NOT EXISTS "cnt_reqs" ( |
|
||||
| | "count(http_requests.val)" DOUBLE NULL, |
|
||||
| | "ts" TIMESTAMP(3) NOT NULL, |
|
||||
| | "status_code" STRING NULL, |
|
||||
| | TIME INDEX ("ts"), |
|
||||
| | PRIMARY KEY ("status_code") |
|
||||
| | ) |
|
||||
| | |
|
||||
| | ENGINE=mito |
|
||||
| | WITH( |
|
||||
| | 'comment' = 'Auto created table by flow engine' |
|
||||
| | ) |
|
||||
+----------+---------------------------------------------------+
|
||||
|
||||
-- test if sink table is tql queryable
|
||||
TQL EVAL (now() - '1m'::interval, now(), '5s') count_values("status_code", cnt_reqs);
|
||||
|
||||
+----+--------------------------+-------------+----------+
|
||||
| ts | count(http_requests.val) | status_code | __name__ |
|
||||
+----+--------------------------+-------------+----------+
|
||||
+----+--------------------------+-------------+----------+
|
||||
|
||||
INSERT INTO TABLE http_requests VALUES
|
||||
(0::Timestamp, 'host1', 'idc1', 200),
|
||||
(0::Timestamp, 'host2', 'idc1', 200),
|
||||
(0::Timestamp, 'host3', 'idc2', 200),
|
||||
(0::Timestamp, 'host4', 'idc2', 401),
|
||||
(5000::Timestamp, 'host1', 'idc1', 404),
|
||||
(5000::Timestamp, 'host2', 'idc1', 401),
|
||||
(5000::Timestamp, 'host3', 'idc2', 404),
|
||||
(5000::Timestamp, 'host4', 'idc2', 500),
|
||||
(10000::Timestamp, 'host1', 'idc1', 200),
|
||||
(10000::Timestamp, 'host2', 'idc1', 200),
|
||||
(10000::Timestamp, 'host3', 'idc2', 201),
|
||||
(10000::Timestamp, 'host4', 'idc2', 201),
|
||||
(15000::Timestamp, 'host1', 'idc1', 500),
|
||||
(15000::Timestamp, 'host2', 'idc1', 500),
|
||||
(15000::Timestamp, 'host3', 'idc2', 500),
|
||||
(15000::Timestamp, 'host4', 'idc2', 500);
|
||||
|
||||
Affected Rows: 16
|
||||
|
||||
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
||||
ADMIN FLUSH_FLOW('calc_reqs');
|
||||
|
||||
+-------------------------------+
|
||||
| ADMIN FLUSH_FLOW('calc_reqs') |
|
||||
+-------------------------------+
|
||||
| FLOW_FLUSHED |
|
||||
+-------------------------------+
|
||||
|
||||
SELECT * FROM cnt_reqs ORDER BY ts, status_code;
|
||||
|
||||
+--------------------------+---------------------+-------------+
|
||||
| count(http_requests.val) | ts | status_code |
|
||||
+--------------------------+---------------------+-------------+
|
||||
| 3.0 | 1970-01-01T00:00:00 | 200 |
|
||||
| 1.0 | 1970-01-01T00:00:00 | 401 |
|
||||
| 1.0 | 1970-01-01T00:00:05 | 401 |
|
||||
| 2.0 | 1970-01-01T00:00:05 | 404 |
|
||||
| 1.0 | 1970-01-01T00:00:05 | 500 |
|
||||
| 2.0 | 1970-01-01T00:00:10 | 200 |
|
||||
| 2.0 | 1970-01-01T00:00:10 | 201 |
|
||||
| 4.0 | 1970-01-01T00:00:15 | 500 |
|
||||
+--------------------------+---------------------+-------------+
|
||||
|
||||
DROP FLOW calc_reqs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE http_requests;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE cnt_reqs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE http_requests (
|
||||
ts timestamp(3) time index,
|
||||
val DOUBLE,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE FLOW calc_rate SINK TO rate_reqs EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - '1m'::interval, now(), '30s') rate(http_requests[5m]);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SHOW CREATE TABLE rate_reqs;
|
||||
|
||||
+-----------+-----------------------------------------------------------+
|
||||
| Table | Create Table |
|
||||
+-----------+-----------------------------------------------------------+
|
||||
| rate_reqs | CREATE TABLE IF NOT EXISTS "rate_reqs" ( |
|
||||
| | "ts" TIMESTAMP(3) NOT NULL, |
|
||||
| | "prom_rate(ts_range,val,ts,Int64(300000))" DOUBLE NULL, |
|
||||
| | TIME INDEX ("ts") |
|
||||
| | ) |
|
||||
| | |
|
||||
| | ENGINE=mito |
|
||||
| | WITH( |
|
||||
| | 'comment' = 'Auto created table by flow engine' |
|
||||
| | ) |
|
||||
+-----------+-----------------------------------------------------------+
|
||||
|
||||
-- test if sink table is tql queryable
|
||||
TQL EVAL (now() - '1m'::interval, now(), '5s') count_values("status_code", rate_reqs);
|
||||
|
||||
+----+------------------------------------------+-------------+----------+
|
||||
| ts | prom_rate(ts_range,val,ts,Int64(300000)) | status_code | __name__ |
|
||||
+----+------------------------------------------+-------------+----------+
|
||||
+----+------------------------------------------+-------------+----------+
|
||||
|
||||
INSERT INTO TABLE http_requests VALUES
|
||||
(now() - '1m'::interval, 0),
|
||||
(now() - '30s'::interval, 1),
|
||||
(now(), 2);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
||||
ADMIN FLUSH_FLOW('calc_rate');
|
||||
|
||||
+-------------------------------+
|
||||
| ADMIN FLUSH_FLOW('calc_rate') |
|
||||
+-------------------------------+
|
||||
| FLOW_FLUSHED |
|
||||
+-------------------------------+
|
||||
|
||||
SELECT count(*) > 0 FROM rate_reqs;
|
||||
|
||||
+---------------------+
|
||||
| count(*) > Int64(0) |
|
||||
+---------------------+
|
||||
| true |
|
||||
+---------------------+
|
||||
|
||||
DROP FLOW calc_rate;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE http_requests;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE rate_reqs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE http_requests_total (
|
||||
host STRING,
|
||||
job STRING,
|
||||
instance STRING,
|
||||
byte DOUBLE,
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
PRIMARY KEY (host, job, instance)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE FLOW calc_rate
|
||||
SINK TO rate_reqs
|
||||
EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - '1m'::interval, now(), '30s') rate(http_requests_total{job="my_service"}[1m]);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SHOW CREATE TABLE rate_reqs;
|
||||
|
||||
+-----------+-----------------------------------------------------------+
|
||||
| Table | Create Table |
|
||||
+-----------+-----------------------------------------------------------+
|
||||
| rate_reqs | CREATE TABLE IF NOT EXISTS "rate_reqs" ( |
|
||||
| | "ts" TIMESTAMP(3) NOT NULL, |
|
||||
| | "prom_rate(ts_range,byte,ts,Int64(60000))" DOUBLE NULL, |
|
||||
| | "host" STRING NULL, |
|
||||
| | "job" STRING NULL, |
|
||||
| | "instance" STRING NULL, |
|
||||
| | TIME INDEX ("ts"), |
|
||||
| | PRIMARY KEY ("host", "job", "instance") |
|
||||
| | ) |
|
||||
| | |
|
||||
| | ENGINE=mito |
|
||||
| | WITH( |
|
||||
| | 'comment' = 'Auto created table by flow engine' |
|
||||
| | ) |
|
||||
+-----------+-----------------------------------------------------------+
|
||||
|
||||
-- test if sink table is tql queryable
|
||||
TQL EVAL (now() - '1m'::interval, now(), '5s') count_values("status_code", rate_reqs);
|
||||
|
||||
+----+------------------------------------------+-------------+----------+
|
||||
| ts | prom_rate(ts_range,byte,ts,Int64(60000)) | status_code | __name__ |
|
||||
+----+------------------------------------------+-------------+----------+
|
||||
+----+------------------------------------------+-------------+----------+
|
||||
|
||||
INSERT INTO TABLE http_requests_total VALUES
|
||||
('localhost', 'my_service', 'instance1', 100, now() - '1min'::interval),
|
||||
('localhost', 'my_service', 'instance1', 200, now() - '45s'::interval),
|
||||
('remotehost', 'my_service', 'instance1', 300, now() - '30s'::interval),
|
||||
('remotehost', 'their_service', 'instance1', 300, now() - '15s'::interval),
|
||||
('localhost', 'my_service', 'instance1', 400, now());
|
||||
|
||||
Affected Rows: 5
|
||||
|
||||
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
||||
ADMIN FLUSH_FLOW('calc_rate');
|
||||
|
||||
+-------------------------------+
|
||||
| ADMIN FLUSH_FLOW('calc_rate') |
|
||||
+-------------------------------+
|
||||
| FLOW_FLUSHED |
|
||||
+-------------------------------+
|
||||
|
||||
SELECT count(*)>0 FROM rate_reqs;
|
||||
|
||||
+---------------------+
|
||||
| count(*) > Int64(0) |
|
||||
+---------------------+
|
||||
| true |
|
||||
+---------------------+
|
||||
|
||||
CREATE FLOW calc_rate_by_matcher
|
||||
SINK TO rate_reqs_by_matcher
|
||||
EVAL INTERVAL '1m' AS
|
||||
TQL EVAL (now() - '1m'::interval, now(), '30s') rate({__name__="http_requests_total",job="my_service"}[1m]);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
SELECT source_table_names FROM information_schema.flows WHERE flow_name = 'calc_rate_by_matcher';
|
||||
|
||||
+-------------------------------------+
|
||||
| source_table_names |
|
||||
+-------------------------------------+
|
||||
| greptime.public.http_requests_total |
|
||||
+-------------------------------------+
|
||||
|
||||
DROP FLOW calc_rate_by_matcher;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE rate_reqs_by_matcher;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP FLOW calc_rate;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE http_requests_total;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE rate_reqs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/flow-tql/flow_tql.sql
|
||||
@@ -0,0 +1,195 @@
|
||||
-- Simplified schema and queries for TSID on physical table
|
||||
CREATE TABLE phy (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
v DOUBLE NULL,
|
||||
tag1 STRING,
|
||||
tag2 STRING,
|
||||
le STRING,
|
||||
tag4 STRING,
|
||||
tag5 STRING,
|
||||
tag6 STRING NULL,
|
||||
tag7 STRING NULL,
|
||||
tag8 STRING NULL,
|
||||
PRIMARY KEY (
|
||||
tag1,
|
||||
tag2,
|
||||
le,
|
||||
tag4,
|
||||
tag5,
|
||||
tag6,
|
||||
tag7,
|
||||
tag8
|
||||
)
|
||||
) ENGINE = metric WITH ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE IF NOT EXISTS test_tsid (
|
||||
tag1 STRING,
|
||||
tag2 STRING,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
v DOUBLE NULL,
|
||||
le STRING,
|
||||
tag4 STRING,
|
||||
tag5 STRING,
|
||||
tag6 STRING NULL,
|
||||
tag7 STRING NULL,
|
||||
tag8 STRING NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY (
|
||||
tag1,
|
||||
tag2,
|
||||
le,
|
||||
tag4,
|
||||
tag5,
|
||||
tag6,
|
||||
tag7,
|
||||
tag8
|
||||
)
|
||||
) ENGINE=metric WITH(
|
||||
on_physical_table = 'phy'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test_tsid
|
||||
(ts, v, tag1, tag2, le, tag4, tag5, tag8, tag6, tag7)
|
||||
VALUES
|
||||
('2026-01-23T03:40:00Z', 2.0, 'istio-ingressgateway', 'outbound', '0.5', 'svc-a', 'prod', 'peer.example', 'svc-b', 'prod'),
|
||||
('2026-01-23T03:41:00Z', 5.0, 'istio-ingressgateway', 'outbound', '0.9', 'svc-a', 'prod', 'peer.example', 'svc-b', 'prod'),
|
||||
('2026-01-23T03:41:30Z', 10.0, 'istio-ingressgateway', 'outbound', '+Inf', 'svc-a', 'prod', 'peer.example', 'svc-b', 'prod');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (
|
||||
timestamp '2026-01-23 03:30:00+00' + (now() - now()),
|
||||
timestamp '2026-01-23 03:45:00+00' + (now() - now()),
|
||||
'1m'
|
||||
) histogram_quantile(
|
||||
0.50,
|
||||
sum by (le, tag4, tag5) (
|
||||
avg_over_time(test_tsid[30m])
|
||||
)
|
||||
);
|
||||
|
||||
+---------------------+-----+-------+------+----------+
|
||||
| ts | v | tag4 | tag5 | __name__ |
|
||||
+---------------------+-----+-------+------+----------+
|
||||
| 2026-01-23T03:40:00 | NaN | svc-a | prod | |
|
||||
| 2026-01-23T03:41:00 | NaN | svc-a | prod | |
|
||||
| 2026-01-23T03:42:00 | 0.9 | svc-a | prod | |
|
||||
| 2026-01-23T03:43:00 | 0.9 | svc-a | prod | |
|
||||
| 2026-01-23T03:44:00 | 0.9 | svc-a | prod | |
|
||||
| 2026-01-23T03:45:00 | 0.9 | svc-a | prod | |
|
||||
+---------------------+-----+-------+------+----------+
|
||||
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE (RepartitionExec:.*) RepartitionExec: REDACTED
|
||||
-- SQLNESS REPLACE phy.__table_id\s=\sUInt32\(\d+\) phy.__table_id=UInt32(REDACTED)
|
||||
TQL EXPLAIN (
|
||||
timestamp '2026-01-23 03:30:00+00' + (now() - now()),
|
||||
timestamp '2026-01-23 03:45:00+00' + (now() - now()),
|
||||
'1m'
|
||||
) histogram_quantile(
|
||||
0.50,
|
||||
sum by (le, tag4, tag5) (
|
||||
avg_over_time(test_tsid[30m])
|
||||
)
|
||||
);
|
||||
|
||||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | FusedSeries: (state routing: canonical labels except ["le", "__name__", "__type__", "__unit__"]) |
|
||||
| | native_tree=[ |
|
||||
| | Vector: histogram_quantile 0.5 |
|
||||
| | Aggregate: sum by [le, tag4, tag5] final |
|
||||
| | Input: aggregate state |
|
||||
| | ] |
|
||||
| | FusedSeries: (output: series_frame) |
|
||||
| | native_tree=[ |
|
||||
| | Aggregate: sum by [le, tag4, tag5] partial |
|
||||
| | Window: avg_over_time [1800000ms] offset 0 anchor - on grid 1769139000000/60000x16 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | RawSeriesSource: metric=test_tsid, tags=[le, tag1, tag2, tag4, tag5, tag6, tag7, tag8], fields=[v] |
|
||||
| | TableScan: phy projection=[v, ts, tag1, tag2, le, tag4, tag5, tag6, tag7, tag8, __table_id, __tsid], partial_filters=[phy.__table_id=UInt32(REDACTED), ts > TimestampMillisecond(1769137200000, None) AND ts <= TimestampMillisecond(1769139900000, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | FusedSeriesExec |
|
||||
| | native_tree=[ |
|
||||
| | Vector: histogram_quantile 0.5 |
|
||||
| | Aggregate: sum by [le, tag4, tag5] final |
|
||||
| | Input: aggregate state |
|
||||
| | ] |
|
||||
| | SeriesRepartitionExec: REDACTED
|
||||
| | FusedSeriesExec: (output: series_frame) |
|
||||
| | native_tree=[ |
|
||||
| | Aggregate: sum by [le, tag4, tag5] partial |
|
||||
| | Window: avg_over_time [1800000ms] offset 0 anchor - on grid 1769139000000/60000x16 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
CREATE FLOW IF NOT EXISTS test_tsid
|
||||
SINK TO 'test_tsid_output'
|
||||
EVAL INTERVAL '3600 s'
|
||||
AS
|
||||
TQL EVAL (
|
||||
timestamp '2026-01-23 03:10:00+00' + (now() - now()),
|
||||
timestamp '2026-01-23 03:50:00+00' + (now() - now()),
|
||||
'1m'
|
||||
)
|
||||
histogram_quantile(
|
||||
0.50,
|
||||
sum by (le, tag4, tag5) (
|
||||
avg_over_time(test_tsid[30m])
|
||||
)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- SQLNESS REPLACE (ADMIN\sFLUSH_FLOW\('\w+'\)\s+\|\n\+-+\+\n\|\s+)[0-9]+\s+\| $1 FLOW_FLUSHED |
|
||||
ADMIN FLUSH_FLOW('test_tsid');
|
||||
|
||||
+-------------------------------+
|
||||
| ADMIN FLUSH_FLOW('test_tsid') |
|
||||
+-------------------------------+
|
||||
| FLOW_FLUSHED |
|
||||
+-------------------------------+
|
||||
|
||||
SELECT * FROM "test_tsid_output"
|
||||
ORDER BY ts
|
||||
LIMIT 5;
|
||||
|
||||
+-------+------+---------------------+-------------------------------------+
|
||||
| tag4 | tag5 | ts | sum(prom_avg_over_time(ts_range,v)) |
|
||||
+-------+------+---------------------+-------------------------------------+
|
||||
| svc-a | prod | 2026-01-23T03:40:00 | NaN |
|
||||
| svc-a | prod | 2026-01-23T03:41:00 | NaN |
|
||||
| svc-a | prod | 2026-01-23T03:42:00 | 0.9 |
|
||||
| svc-a | prod | 2026-01-23T03:43:00 | 0.9 |
|
||||
| svc-a | prod | 2026-01-23T03:44:00 | 0.9 |
|
||||
+-------+------+---------------------+-------------------------------------+
|
||||
|
||||
DROP FLOW test_tsid;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE IF EXISTS "test_tsid_output";
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE test_tsid;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE phy;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/flow-tql/tsid_on_phy.sql
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
-- Exercise dictionary-encoded metric labels across physical-table partitions.
|
||||
CREATE TABLE metric_dictionary_regex_filter_physical (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
host STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(host)
|
||||
)
|
||||
PARTITION ON COLUMNS (host) (
|
||||
host < 'api-02',
|
||||
host >= 'api-02' AND host < 'db',
|
||||
host >= 'db'
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH (
|
||||
physical_metric_table = "true"
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE metric_dictionary_regex_filter (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
host STRING PRIMARY KEY,
|
||||
val DOUBLE
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH (
|
||||
on_physical_table = "metric_dictionary_regex_filter_physical"
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO metric_dictionary_regex_filter (ts, host, val) VALUES
|
||||
(1000, 'api-01', 1.0),
|
||||
(2000, 'api-02', 2.0),
|
||||
(3000, 'db-01', 3.0);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
ADMIN FLUSH_TABLE('metric_dictionary_regex_filter_physical');
|
||||
|
||||
+--------------------------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('metric_dictionary_regex_filter_physical') |
|
||||
+--------------------------------------------------------------+
|
||||
| 0 |
|
||||
+--------------------------------------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (2, 2, '1s') metric_dictionary_regex_filter{host=~"api-.*"};
|
||||
|
||||
+---------------------+-----+--------+--------------------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+--------+--------------------------------+
|
||||
| 1970-01-01T00:00:02 | 1.0 | api-01 | metric_dictionary_regex_filter |
|
||||
| 1970-01-01T00:00:02 | 2.0 | api-02 | metric_dictionary_regex_filter |
|
||||
+---------------------+-----+--------+--------------------------------+
|
||||
|
||||
SELECT host, ts, val
|
||||
FROM metric_dictionary_regex_filter
|
||||
WHERE host ~ '^api-.*$'
|
||||
ORDER BY host, ts;
|
||||
|
||||
+--------+---------------------+-----+
|
||||
| host | ts | val |
|
||||
+--------+---------------------+-----+
|
||||
| api-01 | 1970-01-01T00:00:01 | 1.0 |
|
||||
| api-02 | 1970-01-01T00:00:02 | 2.0 |
|
||||
+--------+---------------------+-----+
|
||||
|
||||
SELECT host, ts, val
|
||||
FROM metric_dictionary_regex_filter
|
||||
WHERE host !~ '^api-.*$'
|
||||
ORDER BY host, ts;
|
||||
|
||||
+-------+---------------------+-----+
|
||||
| host | ts | val |
|
||||
+-------+---------------------+-----+
|
||||
| db-01 | 1970-01-01T00:00:03 | 3.0 |
|
||||
+-------+---------------------+-----+
|
||||
|
||||
DROP TABLE metric_dictionary_regex_filter;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE metric_dictionary_regex_filter_physical;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/optimizer/metric_dictionary_regex_filter.sql
|
||||
@@ -0,0 +1,751 @@
|
||||
-- Tests for the PromQL `@` modifier on vector and matrix selectors.
|
||||
--
|
||||
-- `@` anchors the sample selection window at a fixed timestamp instead of the timestamp of each
|
||||
-- evaluation step: `@ <unix_ts>` uses the given timestamp, `@ start()` / `@ end()` use the
|
||||
-- start/end of the statement's evaluation range, and `offset` shifts the anchor backwards before
|
||||
-- the window is selected. The output timestamps still follow the evaluation grid.
|
||||
--
|
||||
-- Every metric below carries two series, host 'a' and host 'b', with different values: the
|
||||
-- anchored results must therefore report both of them, per step. A series silently dropped, or a
|
||||
-- batch holding several series handled as one timeline, does not look like a correct single-series
|
||||
-- answer here but shows up as a missing or shifted row.
|
||||
--
|
||||
-- Sample timestamps below are in milliseconds, while `@` and `TQL EVAL` timestamps are in seconds,
|
||||
-- as in Prometheus.
|
||||
CREATE TABLE at_modifier_gauge (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
host STRING,
|
||||
PRIMARY KEY(host)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE at_modifier_counter_total (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
host STRING,
|
||||
PRIMARY KEY(host)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- One sample per minute, so the anchored sample is easy to identify. The default lookback is 5m.
|
||||
-- Host 'a' reports 0.0 to 6.0, host 'b' reports 7.0 to 13.0: the two series are told apart by their
|
||||
-- values alone, which stays true after any anchoring.
|
||||
INSERT INTO at_modifier_gauge VALUES
|
||||
(0, 0.0, 'a'),
|
||||
(60000, 1.0, 'a'),
|
||||
(120000, 2.0, 'a'),
|
||||
(180000, 3.0, 'a'),
|
||||
(240000, 4.0, 'a'),
|
||||
(300000, 5.0, 'a'),
|
||||
(360000, 6.0, 'a'),
|
||||
(0, 7.0, 'b'),
|
||||
(60000, 8.0, 'b'),
|
||||
(120000, 9.0, 'b'),
|
||||
(180000, 10.0, 'b'),
|
||||
(240000, 11.0, 'b'),
|
||||
(300000, 12.0, 'b'),
|
||||
(360000, 13.0, 'b');
|
||||
|
||||
Affected Rows: 14
|
||||
|
||||
-- Host 'a': a counter increasing by 60 per minute, i.e. by 1 per second.
|
||||
-- Host 'b': a counter starting at 100 and increasing by 30 per minute, i.e. by 0.5 per second. Its
|
||||
-- rate differs from host 'a', so a window folded for the wrong series cannot pass as the right one.
|
||||
INSERT INTO at_modifier_counter_total VALUES
|
||||
(0, 0.0, 'a'),
|
||||
(60000, 60.0, 'a'),
|
||||
(120000, 120.0, 'a'),
|
||||
(180000, 180.0, 'a'),
|
||||
(240000, 240.0, 'a'),
|
||||
(300000, 300.0, 'a'),
|
||||
(360000, 360.0, 'a'),
|
||||
(0, 100.0, 'b'),
|
||||
(60000, 130.0, 'b'),
|
||||
(120000, 160.0, 'b'),
|
||||
(180000, 190.0, 'b'),
|
||||
(240000, 220.0, 'b'),
|
||||
(300000, 250.0, 'b'),
|
||||
(360000, 280.0, 'b');
|
||||
|
||||
Affected Rows: 14
|
||||
|
||||
-- 1. Instant query anchored at an absolute timestamp: the sample window is `(anchor - lookback,
|
||||
-- anchor]` = `(0s, 300s]`, so its newest samples are 5.0 for host 'a' and 12.0 for host 'b', both
|
||||
-- at 300s. The output timestamps stay the evaluation timestamps.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge @ 300;
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 12.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 5.0 | a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- Control: the same query without `@` looks back from the evaluation timestamp instead:
|
||||
-- `(-200s, 100s]` selects the samples 1.0 (a) and 8.0 (b) at 60s.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge;
|
||||
|
||||
+---------------------+-----+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 1.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 8.0 | b | at_modifier_gauge |
|
||||
+---------------------+-----+------+-------------------+
|
||||
|
||||
-- The anchor, not the evaluation timestamp, decides which sample is reported.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge @ 360;
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 13.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 6.0 | a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- Sub-second precision is preserved in the anchor: `240.999` selects the samples at 240s.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge @ 240.999;
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 11.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 4.0 | a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- The window `(-300s, 0s]` includes the samples exactly at the anchor.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge @ 0;
|
||||
|
||||
+---------------------+-----+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 0.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 7.0 | b | at_modifier_gauge |
|
||||
+---------------------+-----+------+-------------------+
|
||||
|
||||
-- 2. `@ start()`: every step selects its samples around the start of the evaluation range
|
||||
-- (`(-200s, 100s]`), so every step reports the same value per series (1.0 for 'a', 8.0 for 'b').
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') at_modifier_gauge @ start();
|
||||
|
||||
+---------------------+-----+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 1.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 8.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:03:20 | 1.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:03:20 | 8.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:05:00 | 1.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:05:00 | 8.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:40 | 1.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:40 | 8.0 | b | at_modifier_gauge |
|
||||
+---------------------+-----+------+-------------------+
|
||||
|
||||
-- Control: without `@` every step looks back from its own timestamp, so the steps differ.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') at_modifier_gauge;
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 1.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 8.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:03:20 | 10.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:03:20 | 3.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:05:00 | 12.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:05:00 | 5.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:40 | 13.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:40 | 6.0 | a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- 3. `@ end()`: every step selects its samples around the end of the evaluation range
|
||||
-- (`(100s, 400s]`), whose newest samples are 6.0 (a) and 13.0 (b) at 360s.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') at_modifier_gauge @ end();
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 13.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 6.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:03:20 | 13.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:03:20 | 6.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:05:00 | 13.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:05:00 | 6.0 | a | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:40 | 13.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:40 | 6.0 | a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- 4. Range selector anchored by `@`: the call directly above the anchored range selector is
|
||||
-- evaluated once, at the start of the evaluation, and its result is reported at every step — the
|
||||
-- planner's counterpart of Prometheus' `StepInvariantExpr`. The window `(0s, 300s]` is left-open,
|
||||
-- so it holds 60 -> 300 for host 'a' and 130 -> 250 for host 'b', i.e. 240 and 120 units. The 60s
|
||||
-- gap to the window start is below the extrapolation threshold (1.1 x the 60s sampling interval),
|
||||
-- so `rate` adds it and divides by the 300s window: 240 * 1.25 / 300 = 1.0 and
|
||||
-- 120 * 1.25 / 300 = 0.5 per second. Every step must report those same per-series values, and both
|
||||
-- series must be there at every step.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') rate(at_modifier_counter_total[5m] @ 300);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:02:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:02:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:03:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:03:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Consistency: the instant query below shows the anchored values over the same left-open
|
||||
-- `(0s, 300s]` window (1.0 per second for 'a', 0.5 for 'b'). The `!= 1.0` comparison filters
|
||||
-- host 'a', but host 'b' remains at every step with its rate of 0.5 per second.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (300, 300, '1s') rate(at_modifier_counter_total[5m]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:05:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:05:00 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') rate(at_modifier_counter_total[5m] @ 300) != 1.0;
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:01:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:02:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:03:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Parentheses around the range argument are transparent: the call must be promoted exactly like
|
||||
-- the unparenthesized one above, so every step reports the same anchored values for both series
|
||||
-- (1.0 for host 'a', 0.5 for host 'b') instead of folding a window per step.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') rate((at_modifier_counter_total[5m] @ 300));
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:02:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:02:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:03:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:03:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- The same holds for `@ start()` and `@ end()`, which are also fixed anchors: they resolve to the
|
||||
-- statement's evaluation range, so a range call using them is evaluated once as well.
|
||||
-- The statement starts at 60s: the window `(-240s, 60s]` holds only the samples at 0s and 60s, so
|
||||
-- host 'a' goes 0 -> 60 and host 'b' 100 -> 130. The far 240s gap to the window start is beyond the
|
||||
-- extrapolation threshold (1.1 x the 60s interval), so only half an interval (30s) is added there;
|
||||
-- host 'a' starts its counter at 0, which clamps that back: 60 / 300 = 0.2 and
|
||||
-- 30 * 1.5 / 300 = 0.15 per second.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (60, 300, '60s') rate(at_modifier_counter_total[5m] @ start());
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.15 | b | |
|
||||
| 1970-01-01T00:01:00 | 0.2 | a | |
|
||||
| 1970-01-01T00:02:00 | 0.15 | b | |
|
||||
| 1970-01-01T00:02:00 | 0.2 | a | |
|
||||
| 1970-01-01T00:03:00 | 0.15 | b | |
|
||||
| 1970-01-01T00:03:00 | 0.2 | a | |
|
||||
| 1970-01-01T00:04:00 | 0.15 | b | |
|
||||
| 1970-01-01T00:04:00 | 0.2 | a | |
|
||||
| 1970-01-01T00:05:00 | 0.15 | b | |
|
||||
| 1970-01-01T00:05:00 | 0.2 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- The instant query at 60s folds the same window as every step of the query above.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (60, 60, '1s') rate(at_modifier_counter_total[5m]);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.15 | b | |
|
||||
| 1970-01-01T00:01:00 | 0.2 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- The statement ends at 240s: the window `(-60s, 240s]` holds the samples 0s to 240s, so host 'a'
|
||||
-- goes 0 -> 240 and host 'b' 100 -> 220. The 60s gap to the window start is added for both, but
|
||||
-- host 'a' starts at zero, which clamps it back (240 / 300 = 0.8 per second) while host 'b' keeps
|
||||
-- it (120 * 1.25 / 300 = 0.5 per second).
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') rate(at_modifier_counter_total[5m] @ end());
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:00:00 | 0.8 | a | |
|
||||
| 1970-01-01T00:01:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:01:00 | 0.8 | a | |
|
||||
| 1970-01-01T00:02:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:02:00 | 0.8 | a | |
|
||||
| 1970-01-01T00:03:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:03:00 | 0.8 | a | |
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 0.8 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (240, 240, '1s') rate(at_modifier_counter_total[5m]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 0.8 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Control: without `@` each step folds its own window, so the values keep changing.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') rate(at_modifier_counter_total[5m]);
|
||||
|
||||
+---------------------+---------------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+---------------------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.15 | b | |
|
||||
| 1970-01-01T00:01:00 | 0.2 | a | |
|
||||
| 1970-01-01T00:02:00 | 0.25 | b | |
|
||||
| 1970-01-01T00:02:00 | 0.4 | a | |
|
||||
| 1970-01-01T00:03:00 | 0.35000000000000003 | b | |
|
||||
| 1970-01-01T00:03:00 | 0.6000000000000001 | a | |
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 0.8 | a | |
|
||||
+---------------------+---------------------+------+----------+
|
||||
|
||||
-- `@ start()` on a range selector: the window `(-300s, 0s]` is left-open, so it holds a single
|
||||
-- sample per series — the one exactly at the anchor — and `count_over_time` returns 1 at every step
|
||||
-- for both of them.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 300, '100s') count_over_time(at_modifier_counter_total[5m] @ start());
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | b | |
|
||||
| 1970-01-01T00:01:40 | 1.0 | a | |
|
||||
| 1970-01-01T00:01:40 | 1.0 | b | |
|
||||
| 1970-01-01T00:03:20 | 1.0 | a | |
|
||||
| 1970-01-01T00:03:20 | 1.0 | b | |
|
||||
| 1970-01-01T00:05:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:05:00 | 1.0 | b | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Control: without `@` the window keeps moving, so the count grows with the step.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 300, '100s') count_over_time(at_modifier_counter_total[5m]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | b | |
|
||||
| 1970-01-01T00:01:40 | 2.0 | a | |
|
||||
| 1970-01-01T00:01:40 | 2.0 | b | |
|
||||
| 1970-01-01T00:03:20 | 4.0 | a | |
|
||||
| 1970-01-01T00:03:20 | 4.0 | b | |
|
||||
| 1970-01-01T00:05:00 | 5.0 | a | |
|
||||
| 1970-01-01T00:05:00 | 5.0 | b | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- 5. `@` combined with `offset`: the offset moves the anchor backwards before the window is
|
||||
-- selected, so `@ 300 offset 2m` reports the samples at 180s.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge @ 300 offset 2m;
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 10.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 3.0 | a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge @ 300 offset 1m;
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:01:40 | 11.0 | b | at_modifier_gauge |
|
||||
| 1970-01-01T00:01:40 | 4.0 | a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- Control: the offset applies to the evaluation timestamp when there is no `@`.
|
||||
TQL EVAL (100, 100, '1s') at_modifier_gauge offset 2m;
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
-- 6. `@` inside a larger expression. The anchored operand contributes the same value at every
|
||||
-- step, while the plain operand still follows the evaluation step. A binary expression is never
|
||||
-- promoted: when one side is anchored and the other is not, the anchored side replays on its own,
|
||||
-- and when both sides are anchored, each side reports its own anchored samples. The join then runs
|
||||
-- at every step over the replayed per-series inputs.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') at_modifier_gauge @ 300 + at_modifier_gauge @ 0;
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:40 | 19.0 | b | |
|
||||
| 1970-01-01T00:01:40 | 5.0 | a | |
|
||||
| 1970-01-01T00:03:20 | 19.0 | b | |
|
||||
| 1970-01-01T00:03:20 | 5.0 | a | |
|
||||
| 1970-01-01T00:05:00 | 19.0 | b | |
|
||||
| 1970-01-01T00:05:00 | 5.0 | a | |
|
||||
| 1970-01-01T00:06:40 | 19.0 | b | |
|
||||
| 1970-01-01T00:06:40 | 5.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- The aggregation above the anchored selector runs at every step over the replayed (still
|
||||
-- per-series) samples, so it sums both series at every step.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') sum(at_modifier_gauge @ 0);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:01:40 | 7.0 | |
|
||||
| 1970-01-01T00:03:20 | 7.0 | |
|
||||
| 1970-01-01T00:05:00 | 7.0 | |
|
||||
| 1970-01-01T00:06:40 | 7.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') abs(at_modifier_gauge @ 0);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:01:40 | 0.0 | a | |
|
||||
| 1970-01-01T00:01:40 | 7.0 | b | |
|
||||
| 1970-01-01T00:03:20 | 0.0 | a | |
|
||||
| 1970-01-01T00:03:20 | 7.0 | b | |
|
||||
| 1970-01-01T00:05:00 | 0.0 | a | |
|
||||
| 1970-01-01T00:05:00 | 7.0 | b | |
|
||||
| 1970-01-01T00:06:40 | 0.0 | a | |
|
||||
| 1970-01-01T00:06:40 | 7.0 | b | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') at_modifier_gauge @ 300 + at_modifier_gauge;
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:40 | 20.0 | b | |
|
||||
| 1970-01-01T00:01:40 | 6.0 | a | |
|
||||
| 1970-01-01T00:03:20 | 22.0 | b | |
|
||||
| 1970-01-01T00:03:20 | 8.0 | a | |
|
||||
| 1970-01-01T00:05:00 | 10.0 | a | |
|
||||
| 1970-01-01T00:05:00 | 24.0 | b | |
|
||||
| 1970-01-01T00:06:40 | 11.0 | a | |
|
||||
| 1970-01-01T00:06:40 | 25.0 | b | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- 7. `@ -1`, an anchor before the Unix epoch, is accepted. Its window `(-301s, -1s]` holds no
|
||||
-- sample, so the result is empty.
|
||||
TQL EVAL (0, 0, '1s') at_modifier_gauge @ -1;
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
-- 8. `@` on a metric that does not exist yields an empty result.
|
||||
TQL EVAL (100, 100, '1s') at_modifier_missing @ 300;
|
||||
|
||||
+------+-------+
|
||||
| time | value |
|
||||
+------+-------+
|
||||
+------+-------+
|
||||
|
||||
-- The same for a range selector over a missing metric: the anchored window is folded once by the
|
||||
-- promoted call, but the scan has no row to fold, so the whole grid stays empty.
|
||||
TQL EVAL (0, 240, '60s') rate(at_modifier_missing[5m] @ 300);
|
||||
|
||||
+------+------------------------------------------------+
|
||||
| time | prom_rate(time_range,value,time,Int64(300000)) |
|
||||
+------+------------------------------------------------+
|
||||
+------+------------------------------------------------+
|
||||
|
||||
-- 9. Multi-series coverage of the promoted call. The call above the anchored range selector is
|
||||
-- evaluated once per series and its result is replayed per series, so grouping by `host` must
|
||||
-- report both groups at every step: 1.0 for host 'a' and 0.5 for host 'b'. A promoted result that
|
||||
-- treated the two series as one timeline would report the first step from the first row of the
|
||||
-- batch and the later steps from its last row, dropping or mixing a host here.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') sum by (host) (rate(at_modifier_counter_total[5m] @ 300));
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:02:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:02:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:03:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:03:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Consistency: comparing the per-host sequence above against 1.0 keeps exactly host 'b' at
|
||||
-- every step, confirming it stays at 0.5 for the whole grid.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') sum by (host) (rate(at_modifier_counter_total[5m] @ 300)) != 1.0;
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:01:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:02:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:03:00 | 0.5 | b | |
|
||||
| 1970-01-01T00:04:00 | 0.5 | b | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- A value function directly over an anchored instant selector is not promoted: the selector
|
||||
-- anchors and replays its sample per series, and `abs` is evaluated at every step over that replay.
|
||||
-- It must keep one row per series per step.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (100, 400, '100s') abs(at_modifier_gauge @ 300);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:40 | 12.0 | b | |
|
||||
| 1970-01-01T00:01:40 | 5.0 | a | |
|
||||
| 1970-01-01T00:03:20 | 12.0 | b | |
|
||||
| 1970-01-01T00:03:20 | 5.0 | a | |
|
||||
| 1970-01-01T00:05:00 | 12.0 | b | |
|
||||
| 1970-01-01T00:05:00 | 5.0 | a | |
|
||||
| 1970-01-01T00:06:40 | 12.0 | b | |
|
||||
| 1970-01-01T00:06:40 | 5.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- 10. `predict_linear` over an anchored range selector: the regression is centered on the
|
||||
-- evaluation instant of the step, not on the last sample of the window. The window `(0s, 300s]` of
|
||||
-- host 'a' is left-open (the sample at 0s is outside it) and rises by 1.0 per minute, so each step
|
||||
-- predicts 60s ahead of the trend read at its own instant: 6.0 at 300s and 7.0 at 360s.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (300, 360, '60s') predict_linear(at_modifier_gauge{host="a"}[5m] @ 300, 60);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:05:00 | 6.0 | a | |
|
||||
| 1970-01-01T00:06:00 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- The anchor and the start of the evaluation differ here, so the window `(-60s, 240s]` — samples 0s
|
||||
-- to 240s — is shifted by `at_offset` = 300s - 240s = 60s. Every step must follow the evaluation
|
||||
-- grid (6.0 to 11.0); a regression read at the wrong instant predicts 60s ahead of the window's
|
||||
-- last sample instead, i.e. 5.0 at every step — the sample at 240s is 4.0 and the trend rises by
|
||||
-- 1.0 per minute — and shows up as a constant here.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (300, 600, '60s') predict_linear(at_modifier_gauge{host="a"}[5m] @ 240, 60);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:05:00 | 6.0 | a | |
|
||||
| 1970-01-01T00:06:00 | 7.0 | a | |
|
||||
| 1970-01-01T00:07:00 | 8.0 | a | |
|
||||
| 1970-01-01T00:08:00 | 9.0 | a | |
|
||||
| 1970-01-01T00:09:00 | 10.0 | a | |
|
||||
| 1970-01-01T00:10:00 | 11.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- Control: without `@` every step folds its own window, whose last sample is up to a step older
|
||||
-- than the evaluation instant. Reading the regression off that sample reports 6.0 / 7.0 instead
|
||||
-- of 6.5 / 7.5 here.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (330, 390, '60s') predict_linear(at_modifier_gauge{host="a"}[5m], 60);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:05:30 | 6.5 | a | |
|
||||
| 1970-01-01T00:06:30 | 7.5 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- The same holds with an `offset`, which shifts the whole window backwards without moving the
|
||||
-- evaluation instants: the window of step `T` is the left-open `(T - 1m - 5m, T - 1m]`, and the
|
||||
-- trend is read at `T`, i.e. one minute past its newest sample.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (330, 390, '60s') predict_linear(at_modifier_gauge{host="a"}[5m] offset 1m, 60);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:05:30 | 6.5 | a | |
|
||||
| 1970-01-01T00:06:30 | 7.5 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- `timestamp()` of an anchored instant selector is not promoted either: its argument is an
|
||||
-- instant selector, not a range selector, so the selector anchors and replays its sample per series
|
||||
-- on its own and `timestamp()` reports the timestamp of the sample the anchor selected at every
|
||||
-- step (300s here). Its plan keeps the anchored selection below the replay of the grid and projects
|
||||
-- the timestamp above it.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 240, '60s') timestamp(at_modifier_gauge @ 300);
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 300.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 300.0 | b | |
|
||||
| 1970-01-01T00:01:00 | 300.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 300.0 | b | |
|
||||
| 1970-01-01T00:02:00 | 300.0 | a | |
|
||||
| 1970-01-01T00:02:00 | 300.0 | b | |
|
||||
| 1970-01-01T00:03:00 | 300.0 | a | |
|
||||
| 1970-01-01T00:03:00 | 300.0 | b | |
|
||||
| 1970-01-01T00:04:00 | 300.0 | a | |
|
||||
| 1970-01-01T00:04:00 | 300.0 | b | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- With an `offset`, the anchor selects the sample at 240s, and `timestamp()` reports 240s.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 120, '60s') timestamp(at_modifier_gauge @ 300 offset 1m);
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 240.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 240.0 | b | |
|
||||
| 1970-01-01T00:01:00 | 240.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 240.0 | b | |
|
||||
| 1970-01-01T00:02:00 | 240.0 | a | |
|
||||
| 1970-01-01T00:02:00 | 240.0 | b | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE (RepartitionExec:.*) RepartitionExec: REDACTED
|
||||
TQL EXPLAIN (0, 240, '60s') timestamp(at_modifier_gauge @ 300);
|
||||
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | FusedSeries |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 300000ms offset 0 on grid 0/60000x5 @ 300000ms timestamp |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | RawSeriesSource: metric=at_modifier_gauge, tags=[host], fields=[val] |
|
||||
| | TableScan: at_modifier_gauge, partial_filters=[ts > TimestampMillisecond(0, None) AND ts <= TimestampMillisecond(300000, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | FusedSeriesExec |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 300000ms offset 0 on grid 0/60000x5 @ 300000ms timestamp |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | CooperativeExec |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
-- 11. `label_join` above an anchored selector. The call rewrites the label the input series are
|
||||
-- told apart by (`host` becomes `a-a` and `b-b`), so it is never promoted: it must stay above the
|
||||
-- per-series replay of the selector and be evaluated at every step. Both hosts are still reported,
|
||||
-- with their own value, at every step. A promoted `label_join` would instead be replayed through
|
||||
-- the labels it just rewrote and report the two series as a single timeline, i.e. one mixed row
|
||||
-- per step.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (300, 480, '60s') label_join(at_modifier_gauge @ 300, "host", "-", "host", "host");
|
||||
|
||||
+---------------------+------+------+-------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+-------------------+
|
||||
| 1970-01-01T00:05:00 | 12.0 | b-b | at_modifier_gauge |
|
||||
| 1970-01-01T00:05:00 | 5.0 | a-a | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:00 | 12.0 | b-b | at_modifier_gauge |
|
||||
| 1970-01-01T00:06:00 | 5.0 | a-a | at_modifier_gauge |
|
||||
| 1970-01-01T00:07:00 | 12.0 | b-b | at_modifier_gauge |
|
||||
| 1970-01-01T00:07:00 | 5.0 | a-a | at_modifier_gauge |
|
||||
| 1970-01-01T00:08:00 | 12.0 | b-b | at_modifier_gauge |
|
||||
| 1970-01-01T00:08:00 | 5.0 | a-a | at_modifier_gauge |
|
||||
+---------------------+------+------+-------------------+
|
||||
|
||||
-- The same join below another call: neither is promoted, and both are evaluated at every step over
|
||||
-- the per-series replay of the anchored selector.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (300, 480, '60s') abs(label_join(at_modifier_gauge @ 300, "host", "-", "host", "host"));
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:05:00 | 12.0 | b-b | |
|
||||
| 1970-01-01T00:05:00 | 5.0 | a-a | |
|
||||
| 1970-01-01T00:06:00 | 12.0 | b-b | |
|
||||
| 1970-01-01T00:06:00 | 5.0 | a-a | |
|
||||
| 1970-01-01T00:07:00 | 12.0 | b-b | |
|
||||
| 1970-01-01T00:07:00 | 5.0 | a-a | |
|
||||
| 1970-01-01T00:08:00 | 12.0 | b-b | |
|
||||
| 1970-01-01T00:08:00 | 5.0 | a-a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- A range call below the join is still promoted on its own (it is the direct call over the
|
||||
-- anchored range selector): the anchored window is folded once per series, and the join above that
|
||||
-- replay reports the rate of both hosts at every step.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (300, 480, '60s') label_join(rate(at_modifier_counter_total[5m] @ 300), "host", "-", "host", "host");
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:05:00 | 0.5 | b-b | |
|
||||
| 1970-01-01T00:05:00 | 1.0 | a-a | |
|
||||
| 1970-01-01T00:06:00 | 0.5 | b-b | |
|
||||
| 1970-01-01T00:06:00 | 1.0 | a-a | |
|
||||
| 1970-01-01T00:07:00 | 0.5 | b-b | |
|
||||
| 1970-01-01T00:07:00 | 1.0 | a-a | |
|
||||
| 1970-01-01T00:08:00 | 0.5 | b-b | |
|
||||
| 1970-01-01T00:08:00 | 1.0 | a-a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
DROP TABLE at_modifier_gauge;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE at_modifier_counter_total;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/promql/at_modifier.sql
|
||||
@@ -0,0 +1,553 @@
|
||||
-- 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 | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:05 | 4.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | b | h1 | y | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') {"otel.m"} and on("service.name") {"otel.m", "service.name"="b"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | b | h1 | y | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') {"otel.m"} and on(host) {"otel.m", host="y"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | b | h1 | y | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') {"otel.m"} unless {"otel.m", "Host"="h1"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | a | h2 | x | otel.m |
|
||||
| 1970-01-01T00:00:05 | 5.0 | a | h2 | x | otel.m |
|
||||
| 1970-01-01T00:00:10 | 9.0 | a | h2 | x | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') {"otel.m"} unless on("service.name") {"otel.m", "service.name"="b"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:00 | 2.0 | a | h2 | x | otel.m |
|
||||
| 1970-01-01T00:00:05 | 4.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:05 | 5.0 | a | h2 | x | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:10 | 9.0 | a | h2 | x | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') {"otel.m"} or {"otel.m", "Host"="h1"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:00 | 2.0 | a | h2 | x | otel.m |
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:05 | 4.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:05 | 5.0 | a | h2 | x | otel.m |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:10 | 9.0 | a | h2 | x | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') count_values("v.name", {"otel.m"});
|
||||
|
||||
+---------------------+-------+--------+----------+
|
||||
| ts.time | v.val | v.name | __name__ |
|
||||
+---------------------+-------+--------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | 1 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | 2 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | 3 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | 4 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | 5 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | 6 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | 9 | |
|
||||
| 1970-01-01T00:00:10 | 2.0 | 8 | |
|
||||
+---------------------+-------+--------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') count_values by ("service.name") ("v.name", {"otel.m"});
|
||||
|
||||
+---------------------+-------+--------------+--------+----------+
|
||||
| ts.time | v.val | service.name | v.name | __name__ |
|
||||
+---------------------+-------+--------------+--------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | 1 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | 2 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | b | 3 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | a | 4 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | a | 5 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | b | 6 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | a | 8 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | a | 9 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | b | 8 | |
|
||||
+---------------------+-------+--------------+--------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') topk(1, {"otel.m"});
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:10 | 9.0 | a | h2 | x | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') bottomk by ("service.name") (1, {"otel.m"});
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:05 | 4.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | h1 | y | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | a | h1 | x | otel.m |
|
||||
| 1970-01-01T00:00:10 | 8.0 | b | h1 | y | otel.m |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') sum by ("service.name") ({"otel.m"});
|
||||
|
||||
+---------------------+-------+--------------+----------+
|
||||
| ts.time | v.val | service.name | __name__ |
|
||||
+---------------------+-------+--------------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | |
|
||||
| 1970-01-01T00:00:05 | 9.0 | a | |
|
||||
| 1970-01-01T00:00:10 | 17.0 | a | |
|
||||
| 1970-01-01T00:00:10 | 8.0 | b | |
|
||||
+---------------------+-------+--------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') sum by ("Host") ({"otel.m"});
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts.time | v.val | Host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | h2 | |
|
||||
| 1970-01-01T00:00:00 | 4.0 | h1 | |
|
||||
| 1970-01-01T00:00:05 | 10.0 | h1 | |
|
||||
| 1970-01-01T00:00:05 | 5.0 | h2 | |
|
||||
| 1970-01-01T00:00:10 | 16.0 | h1 | |
|
||||
| 1970-01-01T00:00:10 | 9.0 | h2 | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') sum by (host) ({"otel.m"});
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts.time | v.val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | x | |
|
||||
| 1970-01-01T00:00:00 | 3.0 | y | |
|
||||
| 1970-01-01T00:00:05 | 6.0 | y | |
|
||||
| 1970-01-01T00:00:05 | 9.0 | x | |
|
||||
| 1970-01-01T00:00:10 | 17.0 | x | |
|
||||
| 1970-01-01T00:00:10 | 8.0 | y | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') sum without ("Host") ({"otel.m"});
|
||||
|
||||
+---------------------+-------+--------------+------+----------+
|
||||
| ts.time | v.val | service.name | host | __name__ |
|
||||
+---------------------+-------+--------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | a | x | |
|
||||
| 1970-01-01T00:00:00 | 3.0 | b | y | |
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | y | |
|
||||
| 1970-01-01T00:00:05 | 9.0 | a | x | |
|
||||
| 1970-01-01T00:00:10 | 17.0 | a | x | |
|
||||
| 1970-01-01T00:00:10 | 8.0 | b | y | |
|
||||
+---------------------+-------+--------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') -{"otel.m"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | -1.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:00 | -2.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:00 | -3.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:05 | -4.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:05 | -5.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:05 | -6.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:10 | -8.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:10 | -8.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:10 | -9.0 | a | h2 | x | |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') 2 * {"otel.m"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:00 | 4.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:00 | 6.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:05 | 10.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:05 | 12.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:05 | 8.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:10 | 16.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:10 | 16.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:10 | 18.0 | a | h2 | x | |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') {"otel.m"} - 1;
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:00 | 2.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:05 | 3.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:05 | 4.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:05 | 5.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:10 | 7.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:10 | 7.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:10 | 8.0 | a | h2 | x | |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') timestamp({"otel.m"});
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 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 | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 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 | 0.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:05 | 0.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:05 | 0.0 | b | h1 | y | |
|
||||
| 1970-01-01T00:00:10 | 0.0 | a | h1 | x | |
|
||||
| 1970-01-01T00:00:10 | 0.0 | a | h2 | x | |
|
||||
| 1970-01-01T00:00:10 | 0.0 | b | h1 | y | |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (5, 10, '5s') sum by ("service.name") (increase({"otel.m"}[10s]));
|
||||
|
||||
+---------------------+-------+--------------+----------+
|
||||
| ts.time | v.val | service.name | __name__ |
|
||||
+---------------------+-------+--------------+----------+
|
||||
| 1970-01-01T00:00:05 | 6.0 | b | |
|
||||
| 1970-01-01T00:00:05 | 9.0 | a | |
|
||||
| 1970-01-01T00:00:10 | 16.0 | a | |
|
||||
| 1970-01-01T00:00:10 | 4.0 | b | |
|
||||
+---------------------+-------+--------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') scalar(sum({"otel.m"})) * {"otel.m", "Host"="h2"};
|
||||
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| ts.time | v.val | service.name | Host | host | __name__ |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
| 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 | a | h2 | x | |
|
||||
+---------------------+-------+--------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') absent({"otel.m", "service.name"="c"});
|
||||
|
||||
+---------------------+-------+--------------+----------+
|
||||
| ts.time | v.val | service.name | __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 | v.val | service.name | __name__ |
|
||||
+---------------------+-------+--------------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.55 | a | |
|
||||
| 1970-01-01T00:00:05 | 0.55 | a | |
|
||||
| 1970-01-01T00:00:10 | 0.775 | a | |
|
||||
+---------------------+-------+--------------+----------+
|
||||
|
||||
-- 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_| FusedSeries_|
|
||||
|_| native_tree=[_|
|
||||
|_| Set: and ignoring []_|
|
||||
|_|_Input: evaluated samples source=0, contiguous_|
|
||||
|_|_Input: evaluated samples source=1, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_FusedSeries: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| RawSeriesSource: metric=otel.m, tags=[service.name, Host, host], fields=[v.val]_|
|
||||
|_|_TableScan: otel.m, partial_filters=[ts.time > TimestampMillisecond(-300000, None) AND ts.time <= TimestampMillisecond(10000, None)]_|
|
||||
|_| ]]_|
|
||||
|_|_FusedSeries: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| RawSeriesSource: metric=otel.m, tags=[service.name, Host, host], fields=[v.val]_|
|
||||
|_|_TableScan: otel.m, partial_filters=[Host = Utf8("h1"), ts.time > TimestampMillisecond(-300000, None) AND ts.time <= TimestampMillisecond(10000, None)] |
|
||||
|_| ]]_|
|
||||
| physical_plan | FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Set: and ignoring []_|
|
||||
|_|_Input: evaluated samples source=0, contiguous_|
|
||||
|_|_Input: evaluated samples source=1, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_SeriesRepartitionExec: outputs=1, input_partitions=2_|
|
||||
|_|_FusedSeriesExec: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_SeriesRepartitionExec: outputs=1, input_partitions=2_|
|
||||
|_|_FusedSeriesExec: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_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_| FusedSeries_|
|
||||
|_| native_tree=[_|
|
||||
|_| Vector: topk 1 by []_|
|
||||
|_|_Input: evaluated samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_FusedSeries: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| RawSeriesSource: metric=otel.m, tags=[service.name, Host, host], fields=[v.val]_|
|
||||
|_|_TableScan: otel.m, partial_filters=[ts.time > TimestampMillisecond(-300000, None) AND ts.time <= TimestampMillisecond(10000, None)] |
|
||||
|_| ]]_|
|
||||
| physical_plan | FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Vector: topk 1 by []_|
|
||||
|_|_Input: evaluated samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_SeriesRepartitionExec: outputs=1, input_partitions=2_|
|
||||
|_|_FusedSeriesExec: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_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_| FusedSeries_|
|
||||
|_| native_tree=[_|
|
||||
|_| Aggregate: sum by [service.name] final_|
|
||||
|_|_Input: aggregate state_|
|
||||
|_| ]_|
|
||||
|_|_FusedSeries: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Aggregate: sum by [service.name] partial_|
|
||||
|_|_Window: increase [10000ms] offset 0 anchor - on grid 5000/5000x2_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| RawSeriesSource: metric=otel.m, tags=[service.name, Host, host], fields=[v.val]_|
|
||||
|_|_TableScan: otel.m, partial_filters=[ts.time > TimestampMillisecond(-5000, None) AND ts.time <= TimestampMillisecond(10000, None)] |
|
||||
|_| ]]_|
|
||||
| physical_plan | FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Aggregate: sum by [service.name] final_|
|
||||
|_|_Input: aggregate state_|
|
||||
|_| ]_|
|
||||
|_|_SeriesRepartitionExec: outputs=4, input_partitions=2_|
|
||||
|_|_FusedSeriesExec: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Aggregate: sum by [service.name] partial_|
|
||||
|_|_Window: increase [10000ms] offset 0 anchor - on grid 5000/5000x2_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_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_| FusedSeries_|
|
||||
|_| native_tree=[_|
|
||||
|_| Vector: histogram_quantile 0.5_|
|
||||
|_|_Input: evaluated samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_FusedSeries: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| RawSeriesSource: metric=otel.h, tags=[service.name, le], fields=[v.val]_|
|
||||
|_|_TableScan: otel.h, partial_filters=[ts.time > TimestampMillisecond(-300000, None) AND ts.time <= TimestampMillisecond(10000, None)] |
|
||||
|_| ]]_|
|
||||
| physical_plan | FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Vector: histogram_quantile 0.5_|
|
||||
|_|_Input: evaluated samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_FusedSeriesExec: (output: series_frame)_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_CooperativeExec_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
+-+-+
|
||||
|
||||
DROP TABLE "otel.m";
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE "otel.h";
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/promql/dotted_column_names.sql
|
||||
@@ -0,0 +1,64 @@
|
||||
create table count_total (
|
||||
ts timestamp time index,
|
||||
tag_a string,
|
||||
tag_b string,
|
||||
val double,
|
||||
primary key (tag_a, tag_b),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- if `RangeManipulate` can be encoded/decoded correctly in substrait, the following queries should pass
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (partitioning.*) REDACTED
|
||||
tql explain (0, 100, '1s')
|
||||
max_over_time(increase(count_total{
|
||||
tag_a="ffa",
|
||||
}[1h])[12h:1h]);
|
||||
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | FusedSeries |
|
||||
| | native_tree=[ |
|
||||
| | Window: max_over_time [43200000ms] offset 0 anchor - on grid 0/1000x101 |
|
||||
| | Input: evaluated samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | FusedSeries: (output: series_frame) |
|
||||
| | native_tree=[ |
|
||||
| | Window: increase [3600000ms] offset 0 anchor - on grid -39600000/3600000x12 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | RawSeriesSource: metric=count_total, tags=[tag_a, tag_b], fields=[val] |
|
||||
| | TableScan: count_total, partial_filters=[tag_a = Utf8("ffa"), ts > TimestampMillisecond(-43200000, None) AND ts <= TimestampMillisecond(0, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | FusedSeriesExec |
|
||||
| | native_tree=[ |
|
||||
| | Window: max_over_time [43200000ms] offset 0 anchor - on grid 0/1000x101 |
|
||||
| | Input: evaluated samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | FusedSeriesExec: (output: series_frame) |
|
||||
| | native_tree=[ |
|
||||
| | Window: increase [3600000ms] offset 0 anchor - on grid -39600000/3600000x12 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | CooperativeExec |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
tql eval (0, 100, '1s')
|
||||
max_over_time(increase(count_total{
|
||||
tag_a="ffa",
|
||||
}[1h])[12h:1h]);
|
||||
|
||||
+----+-----+-------+-------+----------+
|
||||
| ts | val | tag_a | tag_b | __name__ |
|
||||
+----+-----+-------+-------+----------+
|
||||
+----+-----+-------+-------+----------+
|
||||
|
||||
drop table count_total;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/promql/encode_substrait.sql
|
||||
@@ -0,0 +1,67 @@
|
||||
-- Regression test for promql `group()` aggregator planning.
|
||||
CREATE TABLE kubernetes_build_info (
|
||||
ts timestamp(3) time index,
|
||||
cluster_name STRING,
|
||||
service_name STRING,
|
||||
job_name STRING,
|
||||
instance STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(cluster_name, service_name, job_name, instance),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE kubernetes_build_info VALUES
|
||||
(0, 'cluster_a', 'kubernetes', 'apiserver', '0', 123.0),
|
||||
(0, 'cluster_a', 'kubernetes', 'apiserver', '1', 456.0),
|
||||
(0, 'cluster_b', 'kubernetes', 'apiserver', '0', 789.0);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') sum(group by (cluster_name)(kubernetes_build_info{service_name="kubernetes",job_name="apiserver"}));
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
DROP TABLE kubernetes_build_info;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- `group()` doesn't support multi-field input without selecting a single field.
|
||||
CREATE TABLE kubernetes_build_info_multi (
|
||||
ts timestamp(3) time index,
|
||||
cluster_name STRING,
|
||||
service_name STRING,
|
||||
job_name STRING,
|
||||
instance STRING,
|
||||
cpu DOUBLE,
|
||||
mem DOUBLE,
|
||||
PRIMARY KEY(cluster_name, service_name, job_name, instance),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE kubernetes_build_info_multi VALUES
|
||||
(0, 'cluster_a', 'kubernetes', 'apiserver', '0', 1.0, 2.0),
|
||||
(0, 'cluster_b', 'kubernetes', 'apiserver', '0', 3.0, 4.0);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') group by (cluster_name)(kubernetes_build_info_multi{service_name="kubernetes",job_name="apiserver"});
|
||||
|
||||
+---------------------+-----+-----+--------------+----------+
|
||||
| ts | cpu | mem | cluster_name | __name__ |
|
||||
+---------------------+-----+-----+--------------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | 1.0 | cluster_a | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | 1.0 | cluster_b | |
|
||||
+---------------------+-----+-----+--------------+----------+
|
||||
|
||||
DROP TABLE kubernetes_build_info_multi;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
-- Regression test for promql `group()` aggregator planning.
|
||||
|
||||
CREATE TABLE kubernetes_build_info (
|
||||
ts timestamp(3) time index,
|
||||
cluster_name STRING,
|
||||
service_name STRING,
|
||||
job_name STRING,
|
||||
instance STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(cluster_name, service_name, job_name, instance),
|
||||
);
|
||||
|
||||
INSERT INTO TABLE kubernetes_build_info VALUES
|
||||
(0, 'cluster_a', 'kubernetes', 'apiserver', '0', 123.0),
|
||||
(0, 'cluster_a', 'kubernetes', 'apiserver', '1', 456.0),
|
||||
(0, 'cluster_b', 'kubernetes', 'apiserver', '0', 789.0);
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') sum(group by (cluster_name)(kubernetes_build_info{service_name="kubernetes",job_name="apiserver"}));
|
||||
|
||||
DROP TABLE kubernetes_build_info;
|
||||
|
||||
-- `group()` doesn't support multi-field input without selecting a single field.
|
||||
CREATE TABLE kubernetes_build_info_multi (
|
||||
ts timestamp(3) time index,
|
||||
cluster_name STRING,
|
||||
service_name STRING,
|
||||
job_name STRING,
|
||||
instance STRING,
|
||||
cpu DOUBLE,
|
||||
mem DOUBLE,
|
||||
PRIMARY KEY(cluster_name, service_name, job_name, instance),
|
||||
);
|
||||
|
||||
INSERT INTO TABLE kubernetes_build_info_multi VALUES
|
||||
(0, 'cluster_a', 'kubernetes', 'apiserver', '0', 1.0, 2.0),
|
||||
(0, 'cluster_b', 'kubernetes', 'apiserver', '0', 3.0, 4.0);
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') group by (cluster_name)(kubernetes_build_info_multi{service_name="kubernetes",job_name="apiserver"});
|
||||
|
||||
DROP TABLE kubernetes_build_info_multi;
|
||||
@@ -0,0 +1,86 @@
|
||||
-- Minimal repro for histogram quantile over multi-partition input.
|
||||
create table histogram_gap_bucket (
|
||||
ts timestamp time index,
|
||||
le string,
|
||||
shard string,
|
||||
val double,
|
||||
primary key (shard, le)
|
||||
) partition on columns (shard) (
|
||||
shard < 'n',
|
||||
shard >= 'n'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into histogram_gap_bucket values
|
||||
(0, '0.5', 'a', 1),
|
||||
(0, '1', 'a', 2),
|
||||
(0, '+Inf', 'a', 2),
|
||||
(0, '0.5', 'z', 2),
|
||||
(0, '1', 'z', 4),
|
||||
(0, '+Inf', 'z', 4),
|
||||
(10000, '0.5', 'a', 1),
|
||||
(10000, '1', 'a', 2),
|
||||
(10000, '+Inf', 'a', 2),
|
||||
(10000, '0.5', 'z', 1),
|
||||
(10000, '1', 'z', 3),
|
||||
(10000, '+Inf', 'z', 3);
|
||||
|
||||
Affected Rows: 12
|
||||
|
||||
-- Ensure the physical plan keeps the required repartition/order before folding buckets.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE Hash\(\[ts@1\],.* Hash([ts@1],REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[le@0,\sts@1\],.* Hash([le@0, ts@1],REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
tql analyze (0, 10, '10s') histogram_quantile(0.5, sum by (le) (histogram_gap_bucket));
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Vector: histogram_quantile 0.5, REDACTED
|
||||
|_|_|_Aggregate: sum by [le] final, REDACTED
|
||||
|_|_|_Input: aggregate state, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Aggregate: sum by [le] partial, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/10000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 1_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 2_|
|
||||
+-+-+-+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (0, 10, '10s') histogram_quantile(0.5, sum by (le) (histogram_gap_bucket));
|
||||
|
||||
+---------------------+--------------------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+--------------------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.5 | |
|
||||
| 1970-01-01T00:00:10 | 0.5833333333333334 | |
|
||||
+---------------------+--------------------+----------+
|
||||
|
||||
drop table histogram_gap_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/promql/histogram_multi_partition.sql
|
||||
@@ -0,0 +1,897 @@
|
||||
-- Regression test for TSID-backed PromQL binary joins on metric-engine tables.
|
||||
-- Default arithmetic and comparison joins should use `__tsid` when matching is the
|
||||
-- default one-to-one case. Label modifiers still have to stay label-based.
|
||||
CREATE TABLE tsid_binary_join_physical (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
) ENGINE = metric WITH ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE tsid_binary_join_left (
|
||||
host STRING NULL,
|
||||
job STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(host, job),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'tsid_binary_join_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE tsid_binary_join_right (
|
||||
host STRING NULL,
|
||||
job STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(host, job),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'tsid_binary_join_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE tsid_binary_join_right_by_job (
|
||||
job STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(job),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'tsid_binary_join_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE tsid_binary_join_third (
|
||||
host STRING NULL,
|
||||
job STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(host, job),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'tsid_binary_join_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO tsid_binary_join_left (host, job, ts, greptime_value) VALUES
|
||||
('host1', 'job1', 0, 12),
|
||||
('host2', 'job2', 0, 18),
|
||||
('host1', 'job1', 5000, 15),
|
||||
('host2', 'job2', 5000, 21);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
INSERT INTO tsid_binary_join_right (host, job, ts, greptime_value) VALUES
|
||||
('host1', 'job1', 0, 3),
|
||||
('host2', 'job2', 0, 6),
|
||||
('host1', 'job1', 5000, 5),
|
||||
('host2', 'job2', 5000, 7);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
INSERT INTO tsid_binary_join_right_by_job (job, ts, greptime_value) VALUES
|
||||
('job1', 0, 3),
|
||||
('job2', 0, 6),
|
||||
('job1', 5000, 5),
|
||||
('job2', 5000, 7);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
INSERT INTO tsid_binary_join_third (host, job, ts, greptime_value) VALUES
|
||||
('host1', 'job1', 0, 2),
|
||||
('host2', 'job2', 0, 3),
|
||||
('host1', 'job1', 5000, 4),
|
||||
('host2', 'job2', 5000, 6);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
-- Default vector-vector arithmetic should join on `__tsid` and time index.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@1,\sts@2\],.* Hash([__tsid@1, ts@2],REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@3,\sts@4\],.* Hash([__tsid@3, ts@4],REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') tsid_binary_join_left / tsid_binary_join_right;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- Repeated operands in a safe arithmetic island should be planned once and reused
|
||||
-- in the final projection.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@1,\sts@2\],.* Hash([__tsid@1, ts@2],REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@3,\sts@4\],.* Hash([__tsid@3, ts@4],REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') (tsid_binary_join_left + tsid_binary_join_right) / tsid_binary_join_left;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: + ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- A larger arithmetic island should still plan each distinct vector selector only once
|
||||
-- while reusing the repeated left operand in multiple branches.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[[^\]]+\],.* Hash([REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') ((tsid_binary_join_left + tsid_binary_join_right) * (tsid_binary_join_left - tsid_binary_join_third)) / (tsid_binary_join_left + 2);
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: + ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Scalar: 2_|
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: * ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: + ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: - ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- Label modifiers must disable the TSID shortcut and keep matching on the remaining labels.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[job@1,\sts@2\],.* Hash([job@1, ts@2],REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[job@2,\sts@4\],.* Hash([job@2, ts@4],REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') tsid_binary_join_left / ignoring(host) tsid_binary_join_right;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [host] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- `on(job)` must stay label-based when only the left side has extra row-key labels.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[job@1,\sts@2\],.* Hash([job@1, ts@2],REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[job@1,\sts@3\],.* Hash([job@1, ts@3],REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') tsid_binary_join_left / on(job) tsid_binary_join_right_by_job;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / on [job] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- Comparison filters can join on `__tsid`, but the filtered result must still behave like
|
||||
-- a regular derived vector downstream.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@1,\sts@2\],.* Hash([__tsid@1, ts@2],REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@3,\sts@4\],.* Hash([__tsid@3, ts@4],REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') tsid_binary_join_left > tsid_binary_join_right;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: > ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- `bool` comparison should follow the same TSID-backed matching path.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@1,\sts@2\],.* Hash([__tsid@1, ts@2],REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[__tsid@3,\sts@4\],.* Hash([__tsid@3, ts@4],REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') tsid_binary_join_left > bool tsid_binary_join_right;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: > bool ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- Comparison filters are a barrier for binary island coalescing because they filter the
|
||||
-- vector domain instead of producing only a value expression.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[[^\]]+\],.* Hash([REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') ((tsid_binary_join_left > tsid_binary_join_right) / tsid_binary_join_left) * 100;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: * ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Binary: / ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_Scalar: 100_|
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: > ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- Bool comparisons are intentionally outside the first island optimization version.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[[^\]]+\],.* Hash([REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') ((tsid_binary_join_left > bool tsid_binary_join_right) + tsid_binary_join_left) / tsid_binary_join_left;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: + ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: > bool ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- Set operators are a barrier because they have distinct matching and output-domain
|
||||
-- semantics.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[[^\]]+\],.* Hash([REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') (tsid_binary_join_left or tsid_binary_join_right) / tsid_binary_join_left;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Set: or ignoring [], REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=2, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- Group modifiers are many-to-one/one-to-many matching barriers and must stay on the
|
||||
-- legacy path.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE Hash\(\[[^\]]+\],.* Hash([REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 5, '5s') (tsid_binary_join_left / ignoring(host) group_left tsid_binary_join_right) / tsid_binary_join_left;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [] one-to-one, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_Input: evaluated samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: / ignoring [host] many-to-one [], REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=1, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x2, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- A group modifier that keeps the many side's whole tag set keeps its `__tsid` too, so the
|
||||
-- enclosing operation matches on it. Same rows as the label-based plan.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') (tsid_binary_join_left / ignoring(host) group_left tsid_binary_join_right) / tsid_binary_join_left;
|
||||
|
||||
+---------------------+---------------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.16666666666666666 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:00 | 0.3333333333333333 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 0.14285714285714285 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:05 | 0.2 | host1 | job1 | |
|
||||
+---------------------+---------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') tsid_binary_join_left / tsid_binary_join_right;
|
||||
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:00 | 4.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 3.0 | host2 | job2 | |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') tsid_binary_join_left / on(job) tsid_binary_join_right_by_job;
|
||||
|
||||
+---------------------+----------------+------+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+----------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | job2 | |
|
||||
| 1970-01-01T00:00:00 | 4.0 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 3.0 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 3.0 | job2 | |
|
||||
+---------------------+----------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') (tsid_binary_join_left + tsid_binary_join_right) / tsid_binary_join_left;
|
||||
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.25 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:00 | 1.3333333333333333 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:05 | 1.3333333333333333 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 1.3333333333333333 | host2 | job2 | |
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') ((tsid_binary_join_left + tsid_binary_join_right) * (tsid_binary_join_left - tsid_binary_join_third)) / (tsid_binary_join_left + 2);
|
||||
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 10.714285714285714 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:00 | 18.0 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:05 | 12.941176470588236 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 18.26086956521739 | host2 | job2 | |
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') ((tsid_binary_join_left > tsid_binary_join_right) / tsid_binary_join_left) * 100;
|
||||
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 100.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:00 | 100.0 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:05 | 100.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 100.0 | host2 | job2 | |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') ((tsid_binary_join_left > bool tsid_binary_join_right) + tsid_binary_join_left) / tsid_binary_join_left;
|
||||
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0555555555555556 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:00 | 1.0833333333333333 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 1.0476190476190477 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:05 | 1.0666666666666667 | host1 | job1 | |
|
||||
+---------------------+--------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') (tsid_binary_join_left or tsid_binary_join_right) / tsid_binary_join_left;
|
||||
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | host2 | job2 | |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
|
||||
-- Range functions are outside the first island version; the range selector subtree must
|
||||
-- remain a barrier.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') rate(tsid_binary_join_left[5s]) / tsid_binary_join_left;
|
||||
|
||||
+----+----------------+------+-----+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+----+----------------+------+-----+----------+
|
||||
+----+----------------+------+-----+----------+
|
||||
|
||||
-- Regression for aggregating a binary expression over `time()` and a TSID-backed metric.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') sum by (host, job) (time() - tsid_binary_join_left);
|
||||
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| ts | greptime_value | host | job | __name__ |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:00 | -12.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:00 | -18.0 | host2 | job2 | |
|
||||
| 1970-01-01T00:00:05 | -10.0 | host1 | job1 | |
|
||||
| 1970-01-01T00:00:05 | -16.0 | host2 | job2 | |
|
||||
+---------------------+----------------+-------+------+----------+
|
||||
|
||||
DROP TABLE tsid_binary_join_third;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE tsid_binary_join_right_by_job;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE tsid_binary_join_right;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE tsid_binary_join_left;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE tsid_binary_join_physical;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/promql/tsid_binary_join_regression.sql
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
-- Regression test for `__tsid` optimization on non-aggregating PromQL queries.
|
||||
-- The `__tsid` column must not affect operators that infer label columns from the input schema,
|
||||
-- such as `histogram_quantile` (HistogramFold).
|
||||
CREATE TABLE tsid_no_aggr_physical (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
val DOUBLE,
|
||||
) ENGINE = metric WITH ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE tsid_no_aggr_metric (
|
||||
job STRING NULL,
|
||||
instance STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
val DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(job, instance),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'tsid_no_aggr_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE tsid_no_aggr_histogram_bucket (
|
||||
job STRING NULL,
|
||||
le STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
val DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(job, le),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'tsid_no_aggr_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO tsid_no_aggr_metric VALUES
|
||||
('job1', 'instance1', 0, 1),
|
||||
('job1', 'instance1', 5000, 3),
|
||||
('job1', 'instance1', 10000, 5);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
INSERT INTO tsid_no_aggr_histogram_bucket VALUES
|
||||
('job1', '1', 0, 1),
|
||||
('job1', '2', 0, 2),
|
||||
('job1', '+Inf', 0, 3),
|
||||
('job1', '1', 5000, 2),
|
||||
('job1', '2', 5000, 4),
|
||||
('job1', '+Inf', 5000, 6),
|
||||
('job1', '1', 10000, 3),
|
||||
('job1', '2', 10000, 6),
|
||||
('job1', '+Inf', 10000, 9);
|
||||
|
||||
Affected Rows: 9
|
||||
|
||||
-- Selector (no series merge)
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') tsid_no_aggr_metric;
|
||||
|
||||
+---------------------+-----+----------+-----------+---------------------+
|
||||
| ts | val | instance | job | __name__ |
|
||||
+---------------------+-----+----------+-----------+---------------------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | job1 | instance1 | tsid_no_aggr_metric |
|
||||
| 1970-01-01T00:00:05 | 3.0 | job1 | instance1 | tsid_no_aggr_metric |
|
||||
| 1970-01-01T00:00:10 | 5.0 | job1 | instance1 | tsid_no_aggr_metric |
|
||||
+---------------------+-----+----------+-----------+---------------------+
|
||||
|
||||
-- Scalar function (no series merge)
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') abs(tsid_no_aggr_metric);
|
||||
|
||||
+---------------------+-----+----------+-----------+----------+
|
||||
| ts | val | instance | job | __name__ |
|
||||
+---------------------+-----+----------+-----------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | job1 | instance1 | |
|
||||
| 1970-01-01T00:00:05 | 3.0 | job1 | instance1 | |
|
||||
| 1970-01-01T00:00:10 | 5.0 | job1 | instance1 | |
|
||||
+---------------------+-----+----------+-----------+----------+
|
||||
|
||||
-- Range function (no series merge)
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') avg_over_time(tsid_no_aggr_metric[5s]);
|
||||
|
||||
+---------------------+-----+----------+-----------+----------+
|
||||
| ts | val | instance | job | __name__ |
|
||||
+---------------------+-----+----------+-----------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | job1 | instance1 | |
|
||||
| 1970-01-01T00:00:05 | 3.0 | job1 | instance1 | |
|
||||
| 1970-01-01T00:00:10 | 5.0 | job1 | instance1 | |
|
||||
+---------------------+-----+----------+-----------+----------+
|
||||
|
||||
-- Histogram quantile must fold buckets across `le` even when `__tsid` exists.
|
||||
-- The physical plan must not treat `__tsid` as a label column for HistogramFold.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE __table_id\s*=\s*UInt32\(\d+\) __table_id=UInt32(REDACTED)
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 10, '5s') histogram_quantile(0.5, tsid_no_aggr_histogram_bucket);
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Vector: histogram_quantile 0.5, REDACTED
|
||||
|_|_|_Input: evaluated samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x3, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 3_|
|
||||
+-+-+-+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 10, '5s') histogram_quantile(0.5, tsid_no_aggr_histogram_bucket);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | job | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.5 | job1 | |
|
||||
| 1970-01-01T00:00:05 | 1.5 | job1 | |
|
||||
| 1970-01-01T00:00:10 | 1.5 | job1 | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
DROP TABLE tsid_no_aggr_histogram_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE tsid_no_aggr_metric;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE tsid_no_aggr_physical;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/promql/tsid_histogram_quantile_regression.sql
|
||||
@@ -0,0 +1,145 @@
|
||||
create table t1 (a string primary key, b timestamp time index, c double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into t1 values ("a", 1000, 1.0), ("b", 2000, 2.0), ("c", 3000, 3.0);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
tql analyze (1, 3, '1s') t1{ a = "a" };
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 1000/1000x3, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 3_|
|
||||
+-+-+-+
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
tql analyze (1, 3, '1s') t1{ a =~ ".*" };
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 1000/1000x3, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 6_|
|
||||
+-+-+-+
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
tql analyze (1, 3, '1s') t1{ a =~ "a.*" };
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 1000/1000x3, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 3_|
|
||||
+-+-+-+
|
||||
|
||||
drop table t1;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table t2 (a string primary key, b timestamp time index, c double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE t2 VALUES
|
||||
('10.0.160.237:8080', 0, 1),
|
||||
('10.0.160.237:8081', 0, 1),
|
||||
('20.0.10.237:8081', 0, 1),
|
||||
('abcx', 0, 1),
|
||||
('xabc', 0, 1);
|
||||
|
||||
Affected Rows: 5
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') t2{a=~"10"};
|
||||
|
||||
+---+---+---+----------+
|
||||
| b | c | a | __name__ |
|
||||
+---+---+---+----------+
|
||||
+---+---+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') t2{a=~"10.*"};
|
||||
|
||||
+---------------------+-----+-------------------+----------+
|
||||
| b | c | a | __name__ |
|
||||
+---------------------+-----+-------------------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | 10.0.160.237:8080 | t2 |
|
||||
| 1970-01-01T00:00:00 | 1.0 | 10.0.160.237:8081 | t2 |
|
||||
+---------------------+-----+-------------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') t2{a=~".*10.*"};
|
||||
|
||||
+---------------------+-----+-------------------+----------+
|
||||
| b | c | a | __name__ |
|
||||
+---------------------+-----+-------------------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | 10.0.160.237:8080 | t2 |
|
||||
| 1970-01-01T00:00:00 | 1.0 | 10.0.160.237:8081 | t2 |
|
||||
| 1970-01-01T00:00:00 | 1.0 | 20.0.10.237:8081 | t2 |
|
||||
+---------------------+-----+-------------------+----------+
|
||||
|
||||
drop table t2;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/select/tql_filter.sql
|
||||
@@ -0,0 +1,214 @@
|
||||
CREATE TABLE test(i DOUBLE, j TIMESTAMP TIME INDEX, k STRING PRIMARY KEY);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- insert two points at 1ms and one point at 2ms
|
||||
INSERT INTO test VALUES (1, 1, "a"), (1, 1, "b"), (2, 2, "a");
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- analyze at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 10, '5s') test;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x3, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- 'lookback' parameter is not fully supported, the test has to be updated
|
||||
-- analyze at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 10, '1s', '2s') test;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 2000ms offset 0 on grid 0/1000x11, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- analyze at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE ('1970-01-01T00:00:00'::timestamp, '1970-01-01T00:00:00'::timestamp + '10 seconds'::interval, '5s') test;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x3, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
-- analyze verbose at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (elapsed_compute.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (Duration.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE (flat_format.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE VERBOSE (0, 10, '5s') test;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x3, REDACTED
|
||||
|_|_|_Input: raw samples source=0, contiguous, REDACTED
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 4_|
|
||||
+-+-+-+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- partition table
|
||||
CREATE TABLE test(i DOUBLE, j TIMESTAMP TIME INDEX, k STRING, l STRING, PRIMARY KEY(k, l)) PARTITION ON COLUMNS (k) (k < 'a', k >= 'a');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 10, '5s') test;
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_|_Input: raw samples source=0, contiguous_|
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 1_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 0_|
|
||||
+-+-+-+
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (0, 10, '5s') rate(test[10s]);
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Window: rate [10000ms] offset 0 anchor - on grid 0/5000x3_|
|
||||
|_|_|_Input: raw samples source=0, contiguous_|
|
||||
|_|_|_]_|
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 1_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 0_|
|
||||
+-+-+-+
|
||||
|
||||
drop table test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/tql-explain-analyze/analyze.sql
|
||||
@@ -0,0 +1,630 @@
|
||||
CREATE TABLE test(i DOUBLE, j TIMESTAMP TIME INDEX, k STRING PRIMARY KEY);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- insert two points at 1ms and one point at 2ms
|
||||
INSERT INTO test VALUES (1, 1, "a"), (1, 1, "b"), (2, 2, "a");
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- explain at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
TQL EXPLAIN (0, 10, '5s') test;
|
||||
|
||||
+---------------+-------------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+-------------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | FusedSeries |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 300000ms offset 0 on grid 0/5000x3 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | RawSeriesSource: metric=test, tags=[k], fields=[i] |
|
||||
| | TableScan: test, partial_filters=[j > TimestampMillisecond(-300000, None) AND j <= TimestampMillisecond(10000, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | FusedSeriesExec |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 300000ms offset 0 on grid 0/5000x3 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | CooperativeExec |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+-------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
-- 'lookback' parameter is not fully supported, the test has to be updated
|
||||
-- explain at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
TQL EXPLAIN (0, 10, '1s', '2s') test;
|
||||
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | FusedSeries |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 2000ms offset 0 on grid 0/1000x11 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | RawSeriesSource: metric=test, tags=[k], fields=[i] |
|
||||
| | TableScan: test, partial_filters=[j > TimestampMillisecond(-2000, None) AND j <= TimestampMillisecond(10000, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | FusedSeriesExec |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 2000ms offset 0 on grid 0/1000x11 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | CooperativeExec |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
-- explain at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
TQL EXPLAIN ('1970-01-01T00:00:00'::timestamp, '1970-01-01T00:00:00'::timestamp + '10 seconds'::interval, '5s') test;
|
||||
|
||||
+---------------+-------------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+-------------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | FusedSeries |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 300000ms offset 0 on grid 0/5000x3 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | RawSeriesSource: metric=test, tags=[k], fields=[i] |
|
||||
| | TableScan: test, partial_filters=[j > TimestampMillisecond(-300000, None) AND j <= TimestampMillisecond(10000, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | FusedSeriesExec |
|
||||
| | native_tree=[ |
|
||||
| | Instant: lookback 300000ms offset 0 on grid 0/5000x3 |
|
||||
| | Input: raw samples source=0, contiguous |
|
||||
| | ] |
|
||||
| | CooperativeExec |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+-------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
-- explain verbose at 0s, 5s and 10s. No point at 0s.
|
||||
-- The distributed-only SST analyzer is a no-op for TQL; omit its unchanged-plan row.
|
||||
-- SQLNESS REPLACE (?m)^\|\s*logical_plan\s+after\s+sst_manifest_aggregate\s*\|\s*SAME\s+TEXT\s+AS\s+ABOVE\s*\|\n
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (elapsed_compute.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (RepartitionExec:.*) RepartitionExec: REDACTED
|
||||
TQL EXPLAIN VERBOSE (0, 10, '5s') test;
|
||||
|
||||
+-+-+
|
||||
| plan_type_| plan_|
|
||||
+-+-+
|
||||
| initial_logical_plan_| FusedSeries_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_RawSeriesSource: metric=test, tags=[k], fields=[i]_|
|
||||
|_|_TableScan: test, partial_filters=[j > TimestampMillisecond(-300000, None) AND j <= TimestampMillisecond(10000, None)]_|
|
||||
| logical_plan after apply_function_rewrites_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after count_wildcard_to_time_index_rule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after StringNormalizationRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after TranscribeAtatRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after resolve_grouping_function_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after type_coercion_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ConstNormalizationRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after DistPlannerAnalyzer_| FusedSeries_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| RawSeriesSource: metric=test, tags=[k], fields=[i]_|
|
||||
|_|_TableScan: test, partial_filters=[j > TimestampMillisecond(-300000, None) AND j <= TimestampMillisecond(10000, None)]_|
|
||||
|_| ]]_|
|
||||
| logical_plan after JsonSchemaConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after FixStateUdafOrderingAnalyzer_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after expr_depth_| SAME TEXT AS ABOVE_|
|
||||
| analyzed_logical_plan_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after rewrite_set_comparison_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_unions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after unions_to_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after simplify_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after replace_distinct_aggregate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_predicate_subquery_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after scalar_subquery_to_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_lateral_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_equijoin_predicate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_duplicated_expr_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_cross_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after propagate_empty_relation_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after filter_null_join_keys_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_outer_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after infer_aggregate_input_bounds_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_group_by_constant_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after common_sub_expression_eliminate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_leaf_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_leaf_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after merge_scan_projection_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ScanHintRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after JsonTypeConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan_| FusedSeries_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| RawSeriesSource: metric=test, tags=[k], fields=[i]_|
|
||||
|_|_TableScan: test, partial_filters=[j > TimestampMillisecond(-300000, None) AND j <= TimestampMillisecond(10000, None)]_|
|
||||
|_| ]]_|
|
||||
| initial_physical_plan_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| initial_physical_plan_with_stats_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ], statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:),(Col[3]:)]]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| initial_physical_plan_with_schema_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ], schema=[j:Timestamp(ms), i:Float64;N, k:Utf8;N, __name__:Utf8;N]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after OutputRequirements_| OutputRequirementExec: order_by=[], dist_by=Unspecified_|
|
||||
|_|_FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after aggregate_statistics_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after join_selection_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitedDistinctAggregation_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after FilterPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after parallelize_scan_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after PromqlTsidNarrowJoin_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnforceSorting_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after WindowTopN_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureRequirements_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after CombinePartialFinalAggregate_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after OptimizeAggregateOrder_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after ProjectionPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after OutputRequirements_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after LimitAggregation_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitPushPastWindows_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after HashJoinBuffering_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after TopKRepartition_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after ProjectionPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after PushdownSort_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureCooperative_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_CooperativeExec_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after FilterPushdown(Post)_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after WindowedSortRule_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after MatchesConstantTerm_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureGlobalLimitForFetch_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after RemoveDuplicateRule_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after SeriesFrameOutput_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after SanityCheckPlan_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ]_|
|
||||
|_|_CooperativeExec_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan_with_stats_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ], statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:),(Col[3]:)]]_|
|
||||
|_|_CooperativeExec, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:),(Col[3]:),(Col[4]:),(Col[5]:)]]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan_with_schema_| FusedSeriesExec_|
|
||||
|_| native_tree=[_|
|
||||
|_| Instant: lookback 300000ms offset 0 on grid 0/5000x3_|
|
||||
|_|_Input: raw samples source=0, contiguous_|
|
||||
|_| ], schema=[j:Timestamp(ms), i:Float64;N, k:Utf8;N, __name__:Utf8;N]_|
|
||||
|_|_CooperativeExec, schema=[read_key:Binary;N, is_last:Boolean, time:Struct("timestamps": non-null List(non-null Int64)), fields:Struct("i": non-null Struct("float_values": List(Float64), "histogram": Struct("indices": non-null List(UInt32), "table": non-null List(non-null Struct("schema": non-null Int32, "zero_threshold": non-null Float64, "sum": non-null Float64, "count": non-null Float64, "zero_count": non-null Float64, "reset_hint": non-null Int32, "start_timestamp": Int64, "custom_values": non-null List(non-null Float64), "positive_span_offsets": non-null List(non-null Int32), "positive_span_lengths": non-null List(non-null Int32), "positive_buckets": non-null List(non-null Float64), "negative_span_offsets": non-null List(non-null Int32), "negative_span_lengths": non-null List(non-null Int32), "negative_buckets": non-null List(non-null Float64)))))), name:Utf8;N, labels:List(non-null Struct("name": non-null Utf8, "value": non-null Utf8))]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
+-+-+
|
||||
|
||||
-- explain verbose at 0s, 5s and 10s. No point at 0s.
|
||||
-- SQLNESS REPLACE (?m)^\|\s*logical_plan\s+after\s+sst_manifest_aggregate\s*\|\s*SAME\s+TEXT\s+AS\s+ABOVE\s*\|\n
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (elapsed_compute.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (RepartitionExec:.*) RepartitionExec: REDACTED
|
||||
TQL EXPLAIN VERBOSE (0, 10, '5s') test AS series;
|
||||
|
||||
+-+-+
|
||||
| plan_type_| plan_|
|
||||
+-+-+
|
||||
| initial_logical_plan_| Projection: test.i AS series, test.k, test.j_|
|
||||
|_|_PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test.k ASC NULLS FIRST, test.j ASC NULLS FIRST_|
|
||||
|_|_Filter: test.j >= TimestampMillisecond(-299999, None) AND test.j <= TimestampMillisecond(10000, None)_|
|
||||
|_|_TableScan: test_|
|
||||
| logical_plan after apply_function_rewrites_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after count_wildcard_to_time_index_rule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after StringNormalizationRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after TranscribeAtatRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after resolve_grouping_function_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after type_coercion_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ConstNormalizationRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after DistPlannerAnalyzer_| Projection: series, test.k, test.j_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| Projection: test.i AS series, test.k, test.j_|
|
||||
|_|_PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test.k ASC NULLS FIRST, test.j ASC NULLS FIRST_|
|
||||
|_|_Filter: test.j >= TimestampMillisecond(-299999, None) AND test.j <= TimestampMillisecond(10000, None)_|
|
||||
|_|_TableScan: test, partial_filters=[test.j >= TimestampMillisecond(-299999, None), test.j <= TimestampMillisecond(10000, None)] |
|
||||
|_| ]]_|
|
||||
| logical_plan after JsonSchemaConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after FixStateUdafOrderingAnalyzer_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after expr_depth_| SAME TEXT AS ABOVE_|
|
||||
| analyzed_logical_plan_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after rewrite_set_comparison_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_unions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after unions_to_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after simplify_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after replace_distinct_aggregate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_predicate_subquery_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after scalar_subquery_to_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_lateral_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_equijoin_predicate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_duplicated_expr_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_cross_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after propagate_empty_relation_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after filter_null_join_keys_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_outer_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after infer_aggregate_input_bounds_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_group_by_constant_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after common_sub_expression_eliminate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_leaf_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_leaf_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_projections_| MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| Projection: test.i AS series, test.k, test.j_|
|
||||
|_|_PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test.k ASC NULLS FIRST, test.j ASC NULLS FIRST_|
|
||||
|_|_Filter: test.j >= TimestampMillisecond(-299999, None) AND test.j <= TimestampMillisecond(10000, None)_|
|
||||
|_|_TableScan: test, partial_filters=[test.j >= TimestampMillisecond(-299999, None), test.j <= TimestampMillisecond(10000, None)] |
|
||||
|_| ]]_|
|
||||
| logical_plan after merge_scan_projection_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ScanHintRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after JsonTypeConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after rewrite_set_comparison_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_unions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after unions_to_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after simplify_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after replace_distinct_aggregate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_predicate_subquery_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after scalar_subquery_to_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_lateral_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_equijoin_predicate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_duplicated_expr_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_cross_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after propagate_empty_relation_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after filter_null_join_keys_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_outer_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after infer_aggregate_input_bounds_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_group_by_constant_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after common_sub_expression_eliminate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_leaf_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_leaf_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after merge_scan_projection_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ScanHintRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after JsonTypeConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan_| MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| Projection: test.i AS series, test.k, test.j_|
|
||||
|_|_PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test.k ASC NULLS FIRST, test.j ASC NULLS FIRST_|
|
||||
|_|_Filter: test.j >= TimestampMillisecond(-299999, None) AND test.j <= TimestampMillisecond(10000, None)_|
|
||||
|_|_TableScan: test, partial_filters=[test.j >= TimestampMillisecond(-299999, None), test.j <= TimestampMillisecond(10000, None)] |
|
||||
|_| ]]_|
|
||||
| initial_physical_plan_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| initial_physical_plan_with_stats_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| initial_physical_plan_with_schema_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after OutputRequirements_| OutputRequirementExec: order_by=[], dist_by=Unspecified_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after aggregate_statistics_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after join_selection_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitedDistinctAggregation_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after FilterPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after parallelize_scan_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after PromqlTsidNarrowJoin_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnforceSorting_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after WindowTopN_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureRequirements_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after CombinePartialFinalAggregate_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after OptimizeAggregateOrder_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after ProjectionPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after OutputRequirements_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after LimitAggregation_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitPushPastWindows_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after HashJoinBuffering_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after TopKRepartition_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after ProjectionPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after PushdownSort_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureCooperative_| CooperativeExec_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after FilterPushdown(Post)_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after WindowedSortRule_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after MatchesConstantTerm_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureGlobalLimitForFetch_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after RemoveDuplicateRule_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after SeriesFrameOutput_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after SanityCheckPlan_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan_| CooperativeExec_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan_with_stats_| CooperativeExec, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:)]]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan_with_schema_| CooperativeExec, schema=[series:Float64;N, k:Dictionary(UInt32, Utf8);N, j:Timestamp(ms)]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
+-+-+
|
||||
|
||||
CREATE TABLE test_nano(i DOUBLE, j TIMESTAMP(9) TIME INDEX, k STRING PRIMARY KEY);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test_nano VALUES (1, 1000000, "a"), (1, 1000000, "b"), (2, 2000000, "a");
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- explain at 0s, 5s and 10s for a nanosecond time index.
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (RepartitionExec:.*) RepartitionExec: REDACTED
|
||||
TQL EXPLAIN (0, 10, '5s') test_nano;
|
||||
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j] |
|
||||
| | PromSeriesDivide: tags=["k"] |
|
||||
| | Sort: test_nano.k ASC NULLS FIRST, test_nano.j ASC NULLS FIRST |
|
||||
| | Projection: test_nano.i, test_nano.k, test_nano.j |
|
||||
| | Filter: test_nano.j > TimestampNanosecond(-300000000000, None) AND test_nano.j <= TimestampNanosecond(10000000000, None) |
|
||||
| | TableScan: test_nano, partial_filters=[test_nano.j > TimestampNanosecond(-300000000000, None), test_nano.j <= TimestampNanosecond(10000000000, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | CooperativeExec |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
-- explain verbose at 0s, 5s and 10s for a nanosecond time index.
|
||||
-- SQLNESS REPLACE (?m)^\|\s*logical_plan\s+after\s+sst_manifest_aggregate\s*\|\s*SAME\s+TEXT\s+AS\s+ABOVE\s*\|\n
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (elapsed_compute.*) REDACTED
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (RepartitionExec:.*) RepartitionExec: REDACTED
|
||||
TQL EXPLAIN VERBOSE (0, 10, '5s') test_nano;
|
||||
|
||||
+-+-+
|
||||
| plan_type_| plan_|
|
||||
+-+-+
|
||||
| initial_logical_plan_| PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test_nano.k ASC NULLS FIRST, test_nano.j ASC NULLS FIRST_|
|
||||
|_|_Filter: test_nano.j > TimestampNanosecond(-300000000000, None) AND test_nano.j <= TimestampNanosecond(10000000000, None)_|
|
||||
|_|_Projection: test_nano.i, test_nano.k, test_nano.j_|
|
||||
|_|_TableScan: test_nano_|
|
||||
| logical_plan after apply_function_rewrites_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after count_wildcard_to_time_index_rule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after StringNormalizationRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after TranscribeAtatRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after resolve_grouping_function_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after type_coercion_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ConstNormalizationRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after DistPlannerAnalyzer_| Projection: test_nano.i, test_nano.k, test_nano.j_|
|
||||
|_|_MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test_nano.k ASC NULLS FIRST, test_nano.j ASC NULLS FIRST_|
|
||||
|_|_Projection: test_nano.i, test_nano.k, test_nano.j_|
|
||||
|_|_Filter: test_nano.j > TimestampNanosecond(-300000000000, None) AND test_nano.j <= TimestampNanosecond(10000000000, None)_|
|
||||
|_|_TableScan: test_nano, partial_filters=[test_nano.j > TimestampNanosecond(-300000000000, None), test_nano.j <= TimestampNanosecond(10000000000, None)] |
|
||||
|_| ]]_|
|
||||
| logical_plan after JsonSchemaConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after FixStateUdafOrderingAnalyzer_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after expr_depth_| SAME TEXT AS ABOVE_|
|
||||
| analyzed_logical_plan_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after rewrite_set_comparison_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_unions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after unions_to_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after simplify_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after replace_distinct_aggregate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_predicate_subquery_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after scalar_subquery_to_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_lateral_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_equijoin_predicate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_duplicated_expr_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_cross_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after propagate_empty_relation_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after filter_null_join_keys_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_outer_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after infer_aggregate_input_bounds_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_group_by_constant_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after common_sub_expression_eliminate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_leaf_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_leaf_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_projections_| MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test_nano.k ASC NULLS FIRST, test_nano.j ASC NULLS FIRST_|
|
||||
|_|_Projection: test_nano.i, test_nano.k, test_nano.j_|
|
||||
|_|_Filter: test_nano.j > TimestampNanosecond(-300000000000, None) AND test_nano.j <= TimestampNanosecond(10000000000, None)_|
|
||||
|_|_TableScan: test_nano, partial_filters=[test_nano.j > TimestampNanosecond(-300000000000, None), test_nano.j <= TimestampNanosecond(10000000000, None)] |
|
||||
|_| ]]_|
|
||||
| logical_plan after merge_scan_projection_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ScanHintRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after JsonTypeConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after rewrite_set_comparison_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_unions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after unions_to_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after simplify_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after replace_distinct_aggregate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_predicate_subquery_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after scalar_subquery_to_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after decorrelate_lateral_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_equijoin_predicate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_duplicated_expr_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_cross_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after propagate_empty_relation_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after filter_null_join_keys_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_outer_join_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_limit_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after infer_aggregate_input_bounds_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_filter_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after single_distinct_aggregation_to_group_by | SAME TEXT AS ABOVE_|
|
||||
| logical_plan after eliminate_group_by_constant_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after common_sub_expression_eliminate_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after extract_leaf_expressions_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after push_down_leaf_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after optimize_projections_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after merge_scan_projection_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after ScanHintRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan after JsonTypeConcretizeRule_| SAME TEXT AS ABOVE_|
|
||||
| logical_plan_| MergeScan [is_placeholder=false, remote_input=[_|
|
||||
|_| PromInstantManipulate: range=[0..10000], lookback=[300000], interval=[5000], time index=[j]_|
|
||||
|_|_PromSeriesDivide: tags=["k"]_|
|
||||
|_|_Sort: test_nano.k ASC NULLS FIRST, test_nano.j ASC NULLS FIRST_|
|
||||
|_|_Projection: test_nano.i, test_nano.k, test_nano.j_|
|
||||
|_|_Filter: test_nano.j > TimestampNanosecond(-300000000000, None) AND test_nano.j <= TimestampNanosecond(10000000000, None)_|
|
||||
|_|_TableScan: test_nano, partial_filters=[test_nano.j > TimestampNanosecond(-300000000000, None), test_nano.j <= TimestampNanosecond(10000000000, None)] |
|
||||
|_| ]]_|
|
||||
| initial_physical_plan_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| initial_physical_plan_with_stats_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| initial_physical_plan_with_schema_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after OutputRequirements_| OutputRequirementExec: order_by=[], dist_by=Unspecified_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after aggregate_statistics_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after join_selection_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitedDistinctAggregation_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after FilterPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after parallelize_scan_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after PromqlTsidNarrowJoin_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnforceSorting_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after WindowTopN_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureRequirements_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after CombinePartialFinalAggregate_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after OptimizeAggregateOrder_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after ProjectionPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after OutputRequirements_| MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after LimitAggregation_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitPushPastWindows_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after HashJoinBuffering_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after LimitPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after TopKRepartition_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after ProjectionPushdown_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after PushdownSort_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureCooperative_| CooperativeExec_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan after FilterPushdown(Post)_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after WindowedSortRule_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after MatchesConstantTerm_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after EnsureGlobalLimitForFetch_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after RemoveDuplicateRule_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after SeriesFrameOutput_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan after SanityCheckPlan_| SAME TEXT AS ABOVE_|
|
||||
| physical_plan_| CooperativeExec_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan_with_stats_| CooperativeExec, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:),(Col[1]:),(Col[2]:)]]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
| physical_plan_with_schema_| CooperativeExec, schema=[i:Float64;N, k:Dictionary(UInt32, Utf8);N, j:Timestamp(ms)]_|
|
||||
|_|_MergeScanExec: REDACTED
|
||||
|_|_|
|
||||
+-+-+
|
||||
|
||||
DROP TABLE test_nano;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/tql-explain-analyze/explain.sql
|
||||
@@ -0,0 +1,171 @@
|
||||
-- no partition
|
||||
create table t (
|
||||
i double,
|
||||
j timestamp time index,
|
||||
k string primary key
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
tql analyze (0, 10, '1s') 100 - (avg by (k) (irate(t[1m])) * 100);
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: - ignoring [] one-to-one_|
|
||||
|_|_|_Scalar: 100_|
|
||||
|_|_|_Binary: * ignoring [] one-to-one_|
|
||||
|_|_|_Aggregate: avg by [k] final, REDACTED
|
||||
|_|_|_Input: aggregate state_|
|
||||
|_|_|_Scalar: 100_|
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Aggregate: avg by [k] partial, REDACTED
|
||||
|_|_|_Window: irate [60000ms] offset 0 anchor - on grid 0/1000x11_|
|
||||
|_|_|_Input: raw samples source=0, contiguous_|
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 0_|
|
||||
+-+-+-+
|
||||
|
||||
drop table t;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- partition on tag
|
||||
create table t (
|
||||
i double,
|
||||
j timestamp time index,
|
||||
k string,
|
||||
l string,
|
||||
primary key (k, l)
|
||||
) partition on columns (k, l) (k < 'a', k >= 'a');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
tql analyze (0, 10, '1s') 100 - (avg by (k) (irate(t[1m])) * 100);
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: - ignoring [] one-to-one_|
|
||||
|_|_|_Scalar: 100_|
|
||||
|_|_|_Binary: * ignoring [] one-to-one_|
|
||||
|_|_|_Aggregate: avg by [k] final, REDACTED
|
||||
|_|_|_Input: aggregate state_|
|
||||
|_|_|_Scalar: 100_|
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Aggregate: avg by [k] partial, REDACTED
|
||||
|_|_|_Window: irate [60000ms] offset 0 anchor - on grid 0/1000x11_|
|
||||
|_|_|_Input: raw samples source=0, contiguous_|
|
||||
|_|_|_]_|
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 1_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 0_|
|
||||
+-+-+-+
|
||||
|
||||
drop table t;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- partition on value
|
||||
create table t (
|
||||
i double,
|
||||
j timestamp time index,
|
||||
k string,
|
||||
l string,
|
||||
primary key (k, l)
|
||||
) partition on columns (i) (i < 1.0, i >= 1.0);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE (Hash.*) REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
tql analyze (0, 10, '1s') 100 - (avg by (k) (irate(t[1m])) * 100);
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_FusedSeriesExec REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Binary: - ignoring [] one-to-one_|
|
||||
|_|_|_Scalar: 100_|
|
||||
|_|_|_Binary: * ignoring [] one-to-one_|
|
||||
|_|_|_Aggregate: avg by [k] final, REDACTED
|
||||
|_|_|_Input: aggregate state_|
|
||||
|_|_|_Scalar: 100_|
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_FusedSeriesExec: (output: series_frame) REDACTED
|
||||
|_|_|_native_tree=[_|
|
||||
|_|_|_Aggregate: avg by [k] partial, REDACTED
|
||||
|_|_|_Window: irate [60000ms] offset 0 anchor - on grid 0/1000x11_|
|
||||
|_|_|_Input: raw samples source=0, contiguous_|
|
||||
|_|_|_]_|
|
||||
|_|_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 0_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
| 1_| 1_|_SeriesRepartitionExec REDACTED
|
||||
|_|_|_RawSeriesSourceExec REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScanExec: source=primary_key, fields=1, partitions=4 REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 0_|
|
||||
+-+-+-+
|
||||
|
||||
drop table t;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../cases/distributed/common/tql/partition.sql
|
||||
@@ -0,0 +1,126 @@
|
||||
create table t (
|
||||
ts timestamp(3) time index,
|
||||
job STRING,
|
||||
instance STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(job, instance),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into t values
|
||||
(0, 'job1', 'instance1', 1),
|
||||
(0, 'job2', 'instance2', 2),
|
||||
(5000, 'job1', 'instance3',3),
|
||||
(5000, 'job2', 'instance4',4),
|
||||
(10000, 'job1', 'instance5',5),
|
||||
(10000, 'job2', 'instance6',6),
|
||||
(15000, 'job1', 'instance7',7),
|
||||
(15000, 'job2', 'instance8',8);
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') absent(t{job="job1"});
|
||||
|
||||
+----+-----+-----+----------+
|
||||
| ts | val | job | __name__ |
|
||||
+----+-----+-----+----------+
|
||||
+----+-----+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') absent(t{job="job2"});
|
||||
|
||||
+----+-----+-----+----------+
|
||||
| ts | val | job | __name__ |
|
||||
+----+-----+-----+----------+
|
||||
+----+-----+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') absent(t{job="job3"});
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | job | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | job3 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | job3 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | job3 | |
|
||||
| 1970-01-01T00:00:15 | 1.0 | job3 | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') absent(nonexistent_table);
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 1.0 |
|
||||
| 1970-01-01T00:00:05 | 1.0 |
|
||||
| 1970-01-01T00:00:10 | 1.0 |
|
||||
| 1970-01-01T00:00:15 | 1.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') absent(t{job="nonexistent_job"});
|
||||
|
||||
+---------------------+-----+-----------------+----------+
|
||||
| ts | val | job | __name__ |
|
||||
+---------------------+-----+-----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | nonexistent_job | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | nonexistent_job | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | nonexistent_job | |
|
||||
| 1970-01-01T00:00:15 | 1.0 | nonexistent_job | |
|
||||
+---------------------+-----+-----------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1000, 1000, '1s') absent(t{job="job1"});
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | job | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:16:40 | 1.0 | job1 | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') absent(t{job="nonexistent_job1", job="nonexistent_job2"});
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | |
|
||||
| 1970-01-01T00:00:15 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') absent(t{job=~"nonexistent_job1", job!="nonexistent_job2"});
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | |
|
||||
| 1970-01-01T00:00:15 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 15, '5s') sum(t{job="job2"});
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | |
|
||||
| 1970-01-01T00:00:05 | 6.0 | |
|
||||
| 1970-01-01T00:00:10 | 12.0 | |
|
||||
| 1970-01-01T00:00:15 | 20.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
-- ABSENT is not supported for aggregation functions for now
|
||||
-- tql eval (0, 15, '5s') absent(sum(t{job="job2"}));
|
||||
-- tql eval (0, 15, '5s') absent(sum(t{job="job3"}));
|
||||
drop table t;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/absent.sql
|
||||
@@ -0,0 +1,106 @@
|
||||
CREATE TABLE phy (
|
||||
t TIMESTAMP TIME INDEX,
|
||||
v DOUBLE
|
||||
) ENGINE=metric WITH ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE metric_a (
|
||||
l1 STRING NULL,
|
||||
l2 STRING NULL,
|
||||
l3 STRING NULL,
|
||||
l4 STRING NULL,
|
||||
l5 STRING NULL,
|
||||
t TIMESTAMP NOT NULL,
|
||||
v DOUBLE NULL,
|
||||
TIME INDEX (t),
|
||||
PRIMARY KEY (l1, l2, l3, l4, l5)
|
||||
) ENGINE=metric WITH (on_physical_table = 'phy');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE metric_b (
|
||||
l6 STRING NULL,
|
||||
l1 STRING NULL,
|
||||
l2 STRING NULL,
|
||||
l3 STRING NULL,
|
||||
l4 STRING NULL,
|
||||
t TIMESTAMP NOT NULL,
|
||||
v DOUBLE NULL,
|
||||
TIME INDEX (t),
|
||||
PRIMARY KEY (l6, l1, l2, l3, l4)
|
||||
) ENGINE=metric WITH (on_physical_table = 'phy');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO metric_a (l1, l2, l3, l4, l5, t, v) VALUES
|
||||
('v1', 'v2', 'v3', 'v4a', 'v5a', 1, 0),
|
||||
('v1', 'v2', 'v3', 'v4a', 'v5a', 180000, 120),
|
||||
('v1', 'v2', 'v3', 'v4a', 'v5a', 360000, 240),
|
||||
('v1', 'v2', 'v3', 'v4a', 'v5b', 1, 0),
|
||||
('v1', 'v2', 'v3', 'v4a', 'v5b', 180000, 30),
|
||||
('v1', 'v2', 'v3', 'v4a', 'v5b', 360000, 60),
|
||||
('v1', 'v2', 'v3-b', 'v4b', 'v5c', 1, 0),
|
||||
('v1', 'v2', 'v3-b', 'v4b', 'v5c', 180000, 60),
|
||||
('v1', 'v2', 'v3-b', 'v4b', 'v5c', 360000, 120);
|
||||
|
||||
Affected Rows: 9
|
||||
|
||||
INSERT INTO metric_b (l6, l1, l2, l3, l4, t, v) VALUES
|
||||
('v6', 'v1', 'v2', 'v3', 'v4a', 1, 1),
|
||||
('v6', 'v1', 'v2', 'v3', 'v4a', 180000, 1),
|
||||
('v6', 'v1', 'v2', 'v3', 'v4a', 360000, 1),
|
||||
('v6', 'v1', 'v2', 'v3-b', 'v4b', 1, 2),
|
||||
('v6', 'v1', 'v2', 'v3-b', 'v4b', 180000, 2),
|
||||
('v6', 'v1', 'v2', 'v3-b', 'v4b', 360000, 2);
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 360, '180s') count(((rate(metric_a{l1="v1",l2="v2",l3=~"v3(|-a|-b)"}[3m]) / on(l3,l4) group_left metric_b{l6="v6",l1="v1",l2="v2",l3=~"v3(|-a|-b)"}) > 0.50));
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| t | v | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:03:00 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 360, '180s') count(rate(metric_a{l1="v1",l2="v2",l3=~"v3(|-a|-b)"}[3m]));
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| t | v | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:03:00 | 3.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 360, '180s') count(rate(metric_a{l1="v1",l2="v2",l3=~"v3(|-a|-b)"}[3m])) / 2;
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| t | v | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:03:00 | 1.5 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 360, '180s') (count(((rate(metric_a{l1="v1",l2="v2",l3=~"v3(|-a|-b)"}[3m]) / on(l3,l4) group_left metric_b{l6="v6",l1="v1",l2="v2",l3=~"v3(|-a|-b)"}) > 0.50)) / count(rate(metric_a{l1="v1",l2="v2",l3=~"v3(|-a|-b)"}[3m]))) * 100;
|
||||
|
||||
+---------------------+-------------------+----------+
|
||||
| t | v | __name__ |
|
||||
+---------------------+-------------------+----------+
|
||||
| 1970-01-01T00:03:00 | 33.33333333333333 | |
|
||||
+---------------------+-------------------+----------+
|
||||
|
||||
DROP TABLE metric_a;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE metric_b;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE phy;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/anon_promql_ratio_repro.sql
|
||||
@@ -0,0 +1,63 @@
|
||||
CREATE TABLE IF NOT EXISTS `test_metric` (
|
||||
`asset` STRING NULL,
|
||||
`attribute` STRING NULL,
|
||||
`timestamp` TIMESTAMP(3) NOT NULL,
|
||||
`value` DOUBLE NULL,
|
||||
`measurement` STRING NULL,
|
||||
TIME INDEX (`timestamp`),
|
||||
PRIMARY KEY (`asset`, `attribute`, `measurement`)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Saturday 2023-10-28
|
||||
-- Sunday 2023-10-29
|
||||
INSERT INTO test_metric (asset, attribute, measurement, `timestamp`, `value`)
|
||||
VALUES
|
||||
('Generator01', 'voltage', 'electrical', '2023-10-23 00:00:00', 220.5),
|
||||
('Generator01', 'current', 'electrical', '2023-10-23 06:00:00', 15.2),
|
||||
('Generator02', 'voltage', 'electrical', '2023-10-23 12:00:00', 219.8),
|
||||
('Generator02', 'current', 'electrical', '2023-10-23 18:00:00', 14.9),
|
||||
('Generator01', 'voltage', 'electrical', '2023-10-24 00:00:00', 221.3),
|
||||
('Generator01', 'current', 'electrical', '2023-10-24 06:00:00', 15.4),
|
||||
('Generator02', 'voltage', 'electrical', '2023-10-24 12:00:00', 220.1),
|
||||
('Generator02', 'current', 'electrical', '2023-10-24 18:00:00', 15.0),
|
||||
('Generator01', 'voltage', 'electrical', '2023-10-25 00:00:00', 219.7),
|
||||
('Generator01', 'current', 'electrical', '2023-10-25 06:00:00', 15.3),
|
||||
('Generator02', 'voltage', 'electrical', '2023-10-25 12:00:00', 220.5),
|
||||
('Generator02', 'current', 'electrical', '2023-10-25 18:00:00', 15.1),
|
||||
('Generator01', 'voltage', 'electrical', '2023-10-26 00:00:00', 220.2),
|
||||
('Generator01', 'current', 'electrical', '2023-10-26 06:00:00', 15.5),
|
||||
('Generator02', 'voltage', 'electrical', '2023-10-26 12:00:00', 219.9),
|
||||
('Generator02', 'current', 'electrical', '2023-10-26 18:00:00', 14.8),
|
||||
('Generator01', 'voltage', 'electrical', '2023-10-27 00:00:00', 220.9),
|
||||
('Generator01', 'current', 'electrical', '2023-10-27 06:00:00', 15.6),
|
||||
('Generator02', 'voltage', 'electrical', '2023-10-27 12:00:00', 220.3),
|
||||
('Generator02', 'current', 'electrical', '2023-10-27 18:00:00', 15.2),
|
||||
('Generator01', 'voltage', 'electrical', '2023-10-28 00:00:00', 218.5),
|
||||
('Generator01', 'current', 'electrical', '2023-10-28 06:00:00', 14.9),
|
||||
('Generator02', 'voltage', 'electrical', '2023-10-28 12:00:00', 219.4),
|
||||
('Generator02', 'current', 'electrical', '2023-10-28 18:00:00', 14.7),
|
||||
('Generator01', 'voltage', 'electrical', '2023-10-29 00:00:00', 219.1),
|
||||
('Generator01', 'current', 'electrical', '2023-10-29 06:00:00', 14.8),
|
||||
('Generator02', 'voltage', 'electrical', '2023-10-29 12:00:00', 220.0),
|
||||
('Generator02', 'current', 'electrical', '2023-10-29 18:00:00', 14.6);
|
||||
|
||||
Affected Rows: 28
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(1697731200, 1698595200, 120) max_over_time(test_metric[30s]) > 100 and on () (day_of_week() == 0 or day_of_week() == 6);
|
||||
|
||||
+---------------------+-------+-------------+-----------+-------------+----------+
|
||||
| timestamp | value | asset | attribute | measurement | __name__ |
|
||||
+---------------------+-------+-------------+-----------+-------------+----------+
|
||||
| 2023-10-28T00:00:00 | 218.5 | Generator01 | voltage | electrical | |
|
||||
| 2023-10-28T12:00:00 | 219.4 | Generator02 | voltage | electrical | |
|
||||
| 2023-10-29T00:00:00 | 219.1 | Generator01 | voltage | electrical | |
|
||||
| 2023-10-29T12:00:00 | 220.0 | Generator02 | voltage | electrical | |
|
||||
+---------------------+-------+-------------+-----------+-------------+----------+
|
||||
|
||||
DROP TABLE test_metric;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/binary_time_fn.sql
|
||||
@@ -0,0 +1,119 @@
|
||||
-- Use metric engine to match real PromQL usage.
|
||||
CREATE TABLE comparison_filter_or_physical (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
greptime_value DOUBLE
|
||||
) ENGINE=metric WITH ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE a (
|
||||
k STRING NULL,
|
||||
ts TIMESTAMP NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY (k)
|
||||
) ENGINE=metric WITH (on_physical_table = 'comparison_filter_or_physical');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE b (
|
||||
k STRING NULL,
|
||||
ts TIMESTAMP NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY (k)
|
||||
) ENGINE=metric WITH (on_physical_table = 'comparison_filter_or_physical');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO a (ts, k, greptime_value)
|
||||
VALUES
|
||||
(0, 'x', 3),
|
||||
(0, 'y', 1),
|
||||
(0, 'z', 5);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
INSERT INTO b (ts, k, greptime_value)
|
||||
VALUES
|
||||
(0, 'x', 1),
|
||||
(0, 'y', 2);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
-- Regression: vector-vector comparison without `bool` is a filter that keeps LHS values.
|
||||
-- It must not leak RHS columns (e.g. duplicated `ts`), otherwise set operators like `or`
|
||||
-- can fail with ambiguous column references.
|
||||
--
|
||||
-- Also cover the common PromQL pattern `(A > B) or B or A`, which uses `or` to fill missing
|
||||
-- series from RHS (e.g. B missing for some labels, then fallback to A).
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (0, 0, '1s') (a > b) or b or a;
|
||||
|
||||
+---------------------+----------------+---+----------+
|
||||
| ts | greptime_value | k | __name__ |
|
||||
+---------------------+----------------+---+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | y | b |
|
||||
| 1970-01-01T00:00:00 | 3.0 | x | a |
|
||||
| 1970-01-01T00:00:00 | 5.0 | z | a |
|
||||
+---------------------+----------------+---+----------+
|
||||
|
||||
-- Regression: derived vector expressions may not have a concrete `ctx.table_name`.
|
||||
-- Function planning (which filters empty values) must not require a table name when the
|
||||
-- input plan is valid.
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (0, 0, '1s') abs(a > b);
|
||||
|
||||
+---------------------+----------------+---+----------+
|
||||
| ts | greptime_value | k | __name__ |
|
||||
+---------------------+----------------+---+----------+
|
||||
| 1970-01-01T00:00:00 | 3.0 | x | |
|
||||
+---------------------+----------------+---+----------+
|
||||
|
||||
-- Regression: scalar-vector comparison (scalar on LHS) without `bool` is a filter that keeps
|
||||
-- the vector side's samples/labels (not the scalar side).
|
||||
CREATE TABLE m (
|
||||
k STRING NULL,
|
||||
ts TIMESTAMP NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY (k)
|
||||
) ENGINE=metric WITH (on_physical_table = 'comparison_filter_or_physical');
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO m (ts, k, greptime_value)
|
||||
VALUES
|
||||
(1000, 'x', 3),
|
||||
(1000, 'y', 0),
|
||||
(2000, 'x', 4),
|
||||
(2000, 'y', 0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 2, '1s') time() < m;
|
||||
|
||||
+---------------------+----------------+---+----------+
|
||||
| ts | greptime_value | k | __name__ |
|
||||
+---------------------+----------------+---+----------+
|
||||
| 1970-01-01T00:00:01 | 3.0 | x | m |
|
||||
| 1970-01-01T00:00:02 | 4.0 | x | m |
|
||||
+---------------------+----------------+---+----------+
|
||||
|
||||
drop table m;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table a;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table b;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table comparison_filter_or_physical;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/comparison_filter_or.sql
|
||||
@@ -0,0 +1,97 @@
|
||||
-- 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
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table computed_scalar_rhs (
|
||||
ts timestamp time index,
|
||||
val double,
|
||||
host string primary key
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into computed_scalar_lhs values
|
||||
(0, 1.0, 'a'),
|
||||
(0, 2.0, 'b');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
insert into computed_scalar_rhs values
|
||||
(0, 10.0, 'x');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') computed_scalar_lhs + time();
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 61.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 62.0 | b | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') time() + computed_scalar_lhs;
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 61.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 62.0 | b | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') computed_scalar_lhs * scalar(computed_scalar_rhs);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 10.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 20.0 | b | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') computed_scalar_lhs < bool (time() * 2);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | b | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') (time() >= computed_scalar_lhs) ^ scalar(computed_scalar_rhs);
|
||||
|
||||
+---------------------+--------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+--------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 1024.0 | b | |
|
||||
+---------------------+--------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') scalar(computed_scalar_rhs) * (time() >= computed_scalar_lhs);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 10.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 20.0 | b | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
drop table computed_scalar_lhs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table computed_scalar_rhs;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/computed_scalar_rhs.sql
|
||||
@@ -0,0 +1,206 @@
|
||||
CREATE TABLE http_requests (
|
||||
ts timestamp(3) time index,
|
||||
host STRING,
|
||||
idc STRING,
|
||||
val BIGINT,
|
||||
PRIMARY KEY(host, idc),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE http_requests VALUES
|
||||
(0, 'host1', "idc1", 200),
|
||||
(0, 'host2', "idc1", 200),
|
||||
(0, 'host3', "idc2", 200),
|
||||
(0, 'host4', "idc2", 401),
|
||||
(5000, 'host1', "idc1", 404),
|
||||
(5000, 'host2', "idc1", 401),
|
||||
(5000, 'host3', "idc2", 404),
|
||||
(5000, 'host4', "idc2", 500),
|
||||
(10000, 'host1', "idc1", 200),
|
||||
(10000, 'host2', "idc1", 200),
|
||||
(10000, 'host3', "idc2", 201),
|
||||
(10000, 'host4', "idc2", 201),
|
||||
(15000, 'host1', "idc1", 500),
|
||||
(15000, 'host2', "idc1", 500),
|
||||
(15000, 'host3', "idc2", 500),
|
||||
(15000, 'host4', "idc2", 500);
|
||||
|
||||
Affected Rows: 16
|
||||
|
||||
TQL EVAL (0, 15, '5s') count_values("status_code", http_requests);
|
||||
|
||||
+--------------------------+---------------------+-------------+
|
||||
| count(http_requests.val) | ts | status_code |
|
||||
+--------------------------+---------------------+-------------+
|
||||
| 3 | 1970-01-01T00:00:00 | 200 |
|
||||
| 1 | 1970-01-01T00:00:00 | 401 |
|
||||
| 1 | 1970-01-01T00:00:05 | 401 |
|
||||
| 2 | 1970-01-01T00:00:05 | 404 |
|
||||
| 1 | 1970-01-01T00:00:05 | 500 |
|
||||
| 2 | 1970-01-01T00:00:10 | 200 |
|
||||
| 2 | 1970-01-01T00:00:10 | 201 |
|
||||
| 4 | 1970-01-01T00:00:15 | 500 |
|
||||
+--------------------------+---------------------+-------------+
|
||||
|
||||
TQL EVAL (0, 15, '5s') count_values("status_code", http_requests) by (idc);
|
||||
|
||||
+--------------------------+------+---------------------+-------------+
|
||||
| count(http_requests.val) | idc | ts | status_code |
|
||||
+--------------------------+------+---------------------+-------------+
|
||||
| 2 | idc1 | 1970-01-01T00:00:00 | 200 |
|
||||
| 1 | idc1 | 1970-01-01T00:00:05 | 401 |
|
||||
| 1 | idc1 | 1970-01-01T00:00:05 | 404 |
|
||||
| 2 | idc1 | 1970-01-01T00:00:10 | 200 |
|
||||
| 2 | idc1 | 1970-01-01T00:00:15 | 500 |
|
||||
| 1 | idc2 | 1970-01-01T00:00:00 | 200 |
|
||||
| 1 | idc2 | 1970-01-01T00:00:00 | 401 |
|
||||
| 1 | idc2 | 1970-01-01T00:00:05 | 404 |
|
||||
| 1 | idc2 | 1970-01-01T00:00:05 | 500 |
|
||||
| 2 | idc2 | 1970-01-01T00:00:10 | 201 |
|
||||
| 2 | idc2 | 1970-01-01T00:00:15 | 500 |
|
||||
+--------------------------+------+---------------------+-------------+
|
||||
|
||||
-- https://github.com/GreptimeTeam/greptimedb/issues/9181
|
||||
-- The label generated by `count_values` must survive an enclosing expression,
|
||||
-- e.g. a per-sample function, an arithmetic operation or an enclosing aggregation.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') abs(count_values("v", http_requests));
|
||||
|
||||
+---------------------+-------------------------------+-----+
|
||||
| ts | abs(count(http_requests.val)) | v |
|
||||
+---------------------+-------------------------------+-----+
|
||||
| 1970-01-01T00:00:00 | 1 | 401 |
|
||||
| 1970-01-01T00:00:00 | 3 | 200 |
|
||||
| 1970-01-01T00:00:05 | 1 | 401 |
|
||||
| 1970-01-01T00:00:05 | 1 | 500 |
|
||||
| 1970-01-01T00:00:05 | 2 | 404 |
|
||||
| 1970-01-01T00:00:10 | 2 | 200 |
|
||||
| 1970-01-01T00:00:10 | 2 | 201 |
|
||||
| 1970-01-01T00:00:15 | 4 | 500 |
|
||||
+---------------------+-------------------------------+-----+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') round(count_values("v", http_requests));
|
||||
|
||||
+---------------------+-------------------------------------------------+-----+
|
||||
| ts | prom_round(count(http_requests.val),Float64(1)) | v |
|
||||
+---------------------+-------------------------------------------------+-----+
|
||||
| 1970-01-01T00:00:00 | 1.0 | 401 |
|
||||
| 1970-01-01T00:00:00 | 3.0 | 200 |
|
||||
| 1970-01-01T00:00:05 | 1.0 | 401 |
|
||||
| 1970-01-01T00:00:05 | 1.0 | 500 |
|
||||
| 1970-01-01T00:00:05 | 2.0 | 404 |
|
||||
| 1970-01-01T00:00:10 | 2.0 | 200 |
|
||||
| 1970-01-01T00:00:10 | 2.0 | 201 |
|
||||
| 1970-01-01T00:00:15 | 4.0 | 500 |
|
||||
+---------------------+-------------------------------------------------+-----+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') count_values("v", http_requests) + 1;
|
||||
|
||||
+-----+---------------------+---------------------------------------+
|
||||
| v | ts | count(http_requests.val) + Float64(1) |
|
||||
+-----+---------------------+---------------------------------------+
|
||||
| 200 | 1970-01-01T00:00:00 | 4.0 |
|
||||
| 200 | 1970-01-01T00:00:10 | 3.0 |
|
||||
| 201 | 1970-01-01T00:00:10 | 3.0 |
|
||||
| 401 | 1970-01-01T00:00:00 | 2.0 |
|
||||
| 401 | 1970-01-01T00:00:05 | 2.0 |
|
||||
| 404 | 1970-01-01T00:00:05 | 3.0 |
|
||||
| 500 | 1970-01-01T00:00:05 | 2.0 |
|
||||
| 500 | 1970-01-01T00:00:15 | 5.0 |
|
||||
+-----+---------------------+---------------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') sum by (v) (count_values("v", http_requests));
|
||||
|
||||
+-----+---------------------+-------------------------------+
|
||||
| v | ts | sum(count(http_requests.val)) |
|
||||
+-----+---------------------+-------------------------------+
|
||||
| 200 | 1970-01-01T00:00:00 | 3 |
|
||||
| 200 | 1970-01-01T00:00:10 | 2 |
|
||||
| 201 | 1970-01-01T00:00:10 | 2 |
|
||||
| 401 | 1970-01-01T00:00:00 | 1 |
|
||||
| 401 | 1970-01-01T00:00:05 | 1 |
|
||||
| 404 | 1970-01-01T00:00:05 | 2 |
|
||||
| 500 | 1970-01-01T00:00:05 | 1 |
|
||||
| 500 | 1970-01-01T00:00:15 | 4 |
|
||||
+-----+---------------------+-------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') topk(10, count_values("v", http_requests));
|
||||
|
||||
+--------------------------+-----+---------------------+
|
||||
| count(http_requests.val) | v | ts |
|
||||
+--------------------------+-----+---------------------+
|
||||
| 1 | 401 | 1970-01-01T00:00:00 |
|
||||
| 1 | 401 | 1970-01-01T00:00:05 |
|
||||
| 1 | 500 | 1970-01-01T00:00:05 |
|
||||
| 2 | 200 | 1970-01-01T00:00:10 |
|
||||
| 2 | 201 | 1970-01-01T00:00:10 |
|
||||
| 2 | 404 | 1970-01-01T00:00:05 |
|
||||
| 3 | 200 | 1970-01-01T00:00:00 |
|
||||
| 4 | 500 | 1970-01-01T00:00:15 |
|
||||
+--------------------------+-----+---------------------+
|
||||
|
||||
-- The generated label overwrites an input label with the same name (PromQL semantics),
|
||||
-- and must not turn the generated column into an ambiguous reference.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') count_values("idc", http_requests) by (idc);
|
||||
|
||||
+--------------------------+---------------------+-----+
|
||||
| count(http_requests.val) | ts | idc |
|
||||
+--------------------------+---------------------+-----+
|
||||
| 1 | 1970-01-01T00:00:00 | 401 |
|
||||
| 1 | 1970-01-01T00:00:05 | 401 |
|
||||
| 1 | 1970-01-01T00:00:05 | 500 |
|
||||
| 2 | 1970-01-01T00:00:05 | 404 |
|
||||
| 2 | 1970-01-01T00:00:10 | 200 |
|
||||
| 2 | 1970-01-01T00:00:10 | 201 |
|
||||
| 3 | 1970-01-01T00:00:00 | 200 |
|
||||
| 4 | 1970-01-01T00:00:15 | 500 |
|
||||
+--------------------------+---------------------+-----+
|
||||
|
||||
-- The generated label is the sample value in PromQL's textual form
|
||||
-- (`strconv.FormatFloat(value, 'f', -1, 64)`: the shortest decimal form without an
|
||||
-- exponent), so it is a string: `200.0` becomes the label `200` and `1e21` becomes
|
||||
-- `1000000000000000000000`.
|
||||
CREATE TABLE http_requests_double (
|
||||
ts timestamp(3) time index,
|
||||
host STRING,
|
||||
idc STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(host, idc),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE http_requests_double VALUES
|
||||
(0, 'host1', "idc1", 200.0),
|
||||
(0, 'host2', "idc1", 0.5),
|
||||
(5000, 'host1', "idc1", 200.0),
|
||||
(5000, 'host2', "idc1", 1e21);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 5, '5s') count_values("val_label", http_requests_double);
|
||||
|
||||
+---------------------+-----+------------------------+----------+
|
||||
| ts | val | val_label | __name__ |
|
||||
+---------------------+-----+------------------------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | 0.5 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | 200 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | 1000000000000000000000 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | 200 | |
|
||||
+---------------------+-----+------------------------+----------+
|
||||
|
||||
DROP TABLE http_requests_double;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE http_requests;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/count_values.sql
|
||||
@@ -0,0 +1,43 @@
|
||||
CREATE TABLE counter_reset_precision (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO counter_reset_precision VALUES
|
||||
(0, 10000000000000000.0, 'a'),
|
||||
(30000, 1.0, 'a'),
|
||||
(60000, 0.0, 'a'),
|
||||
(90000, 1.0, 'a'),
|
||||
(120000, 2.0, 'a'),
|
||||
(150000, 3.0, 'a'),
|
||||
(180000, 4.0, 'a');
|
||||
|
||||
Affected Rows: 7
|
||||
|
||||
-- The counter resets twice, at 30s from 1e16 and at 60s from 1.0, and 1e16 + 1.0 is 1e16 in
|
||||
-- f64. Windows are two minutes wide and step by one sample, so every row here depends on the
|
||||
-- 1.0 reset surviving.
|
||||
--
|
||||
-- Summing the two corrections on their own drops the 1.0 and then cancels against the first
|
||||
-- sample, so the 90s window reports no increase. Carrying that sum into the next window and
|
||||
-- subtracting the 1e16 that left it reports half the increase, and the windows after that
|
||||
-- subtract a reset the sum never held, so the correction turns negative and stays there for
|
||||
-- the rest of the batch.
|
||||
TQL EVAL (90, 180, '30s') increase(counter_reset_precision[2m]);
|
||||
|
||||
+---------------------+--------------------+--------+----------+
|
||||
| ts | greptime_value | series | __name__ |
|
||||
+---------------------+--------------------+--------+----------+
|
||||
| 1970-01-01T00:01:30 | 1.3333333333333333 | a | |
|
||||
| 1970-01-01T00:02:00 | 2.6666666666666665 | a | |
|
||||
| 1970-01-01T00:02:30 | 3.0 | a | |
|
||||
| 1970-01-01T00:03:00 | 4.0 | a | |
|
||||
+---------------------+--------------------+--------+----------+
|
||||
|
||||
DROP TABLE counter_reset_precision;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/counter_reset_precision.sql
|
||||
@@ -0,0 +1,210 @@
|
||||
CREATE TABLE delta_temporality (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
series STRING,
|
||||
otlp_aggregation_temporality STRING,
|
||||
PRIMARY KEY (series, otlp_aggregation_temporality)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO delta_temporality VALUES
|
||||
(60000, 10, 'delta', 'delta'),
|
||||
(120000, 20, 'delta', 'delta'),
|
||||
(180000, 15, 'delta', 'delta'),
|
||||
(180000, 7, 'single', 'delta'),
|
||||
(60000, 10, 'cumulative', NULL),
|
||||
(120000, 20, 'cumulative', NULL),
|
||||
(180000, 30, 'cumulative', NULL);
|
||||
|
||||
Affected Rows: 7
|
||||
|
||||
-- Raw deltas are summed; untagged rows retain cumulative reset-aware math.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') increase(delta_temporality[3m]);
|
||||
|
||||
+---------------------+---------------------------------------------------------+------------+------------------------------+
|
||||
| ts | prom_increase(ts_range,greptime_value,ts,Int64(180000)) | series | otlp_aggregation_temporality |
|
||||
+---------------------+---------------------------------------------------------+------------+------------------------------+
|
||||
| 1970-01-01T00:03:00 | 30.0 | cumulative | |
|
||||
| 1970-01-01T00:03:00 | 45.0 | delta | delta |
|
||||
| 1970-01-01T00:03:00 | 7.0 | single | delta |
|
||||
+---------------------+---------------------------------------------------------+------------+------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') rate(delta_temporality[3m]);
|
||||
|
||||
+---------------------+-----------------------------------------------------+------------+------------------------------+
|
||||
| ts | prom_rate(ts_range,greptime_value,ts,Int64(180000)) | series | otlp_aggregation_temporality |
|
||||
+---------------------+-----------------------------------------------------+------------+------------------------------+
|
||||
| 1970-01-01T00:03:00 | 0.03888888888888889 | single | delta |
|
||||
| 1970-01-01T00:03:00 | 0.16666666666666666 | cumulative | |
|
||||
| 1970-01-01T00:03:00 | 0.25 | delta | delta |
|
||||
+---------------------+-----------------------------------------------------+------------+------------------------------+
|
||||
|
||||
-- The physical plan selects raw-delta math per series while retaining cumulative rate.
|
||||
-- SQLNESS REPLACE (metrics.*) REDACTED
|
||||
-- SQLNESS REPLACE (RoundRobinBatch.*) REDACTED
|
||||
-- SQLNESS REPLACE (-+) -
|
||||
-- SQLNESS REPLACE (\s\s+) _
|
||||
-- SQLNESS REPLACE (?m)^\|\s1_\|\s0_\|_(?:Projection|Filter)Exec:.*\n
|
||||
-- SQLNESS REPLACE (?m)^\|_\|_\|_FilterExec:.*\n
|
||||
-- SQLNESS REPLACE END\sas\s.*,\sseries@2\sas\sseries END as RATE_RESULT, series@2 as series
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE input_partitions=\d+ input_partitions=REDACTED
|
||||
-- SQLNESS REPLACE "partition_count":\{(.*?)\} "partition_count":REDACTED
|
||||
-- SQLNESS REPLACE region=\d+\(\d+,\s+\d+\) region=REDACTED
|
||||
-- SQLNESS REPLACE \\?"(dyn_filters|time_range|file_summary|max_part_range)\\?":.* "$1":REDACTED
|
||||
TQL ANALYZE (180, 180, '1m') rate(delta_temporality[3m]);
|
||||
|
||||
+-+-+-+
|
||||
| stage | node | plan_|
|
||||
+-+-+-+
|
||||
| 0_| 0_|_CooperativeExec REDACTED
|
||||
|_|_|_MergeScanExec: REDACTED
|
||||
|_|_|_|
|
||||
|_|_|_ProjectionExec: expr=[ts@0 as ts, CASE WHEN otlp_aggregation_temporality@3 = delta THEN prom_sum_over_time(ts_range@4, greptime_value@1) / 180 ELSE prom_rate(ts_range@4, greptime_value@1, ts@0, 180000) END as RATE_RESULT, series@2 as series, otlp_aggregation_temporality@3 as otlp_aggregation_temporality] REDACTED
|
||||
|_|_|_PromRangeManipulateExec: req range=[180000..180000], interval=[60000], eval range=[180000], time index=[ts] REDACTED
|
||||
|_|_|_PromSeriesNormalizeExec: offset=[0], time index=[ts], filter NaN: [true] REDACTED
|
||||
|_|_|_PromSeriesDivideExec: tags=["series", "otlp_aggregation_temporality"] REDACTED
|
||||
|_|_|_CooperativeExec REDACTED
|
||||
|_|_|_SeriesScan: region=REDACTED, "partition_count":REDACTED, "distribution":"PerSeries", "projection": ["ts", "greptime_value", "series", "otlp_aggregation_temporality"], "filters": ["ts >= TimestampMillisecond(1, None)", "ts <= TimestampMillisecond(180000, None)"], "time_range":REDACTED
|
||||
|_|_|_|
|
||||
|_|_| Total rows: 3_|
|
||||
+-+-+-+
|
||||
|
||||
-- The reserved temporality marker treats NULL as the absent cumulative state.
|
||||
TQL EVAL (180, 180, '1m') delta_temporality{otlp_aggregation_temporality=""};
|
||||
|
||||
+---------------------+----------------+------------+------------------------------+-------------------+
|
||||
| ts | greptime_value | series | otlp_aggregation_temporality | __name__ |
|
||||
+---------------------+----------------+------------+------------------------------+-------------------+
|
||||
| 1970-01-01T00:03:00 | 30.0 | cumulative | | delta_temporality |
|
||||
+---------------------+----------------+------------+------------------------------+-------------------+
|
||||
|
||||
TQL EVAL (180, 180, '1m') delta_temporality{otlp_aggregation_temporality!="delta"};
|
||||
|
||||
+---------------------+----------------+------------+------------------------------+-------------------+
|
||||
| ts | greptime_value | series | otlp_aggregation_temporality | __name__ |
|
||||
+---------------------+----------------+------------+------------------------------+-------------------+
|
||||
| 1970-01-01T00:03:00 | 30.0 | cumulative | | delta_temporality |
|
||||
+---------------------+----------------+------------+------------------------------+-------------------+
|
||||
|
||||
-- Generated vector plans retain timestamp broadcast across the temporality marker.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') vector(2) * delta_temporality;
|
||||
|
||||
+----+-------+----------+
|
||||
| ts | value | __name__ |
|
||||
+----+-------+----------+
|
||||
+----+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') vector(2) * ignoring(otlp_aggregation_temporality) delta_temporality;
|
||||
|
||||
+----+-------+----------+
|
||||
| ts | value | __name__ |
|
||||
+----+-------+----------+
|
||||
+----+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') delta_temporality * vector(2);
|
||||
|
||||
+----+----------------+--------+------------------------------+----------+
|
||||
| ts | greptime_value | series | otlp_aggregation_temporality | __name__ |
|
||||
+----+----------------+--------+------------------------------+----------+
|
||||
+----+----------------+--------+------------------------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') delta_temporality * ignoring(otlp_aggregation_temporality) vector(2);
|
||||
|
||||
+----+----------------+--------+----------+
|
||||
| ts | greptime_value | series | __name__ |
|
||||
+----+----------------+--------+----------+
|
||||
+----+----------------+--------+----------+
|
||||
|
||||
-- Aggregation preserves or deliberately removes the visible stored marker.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') sum by (series, otlp_aggregation_temporality) (rate(delta_temporality[3m]));
|
||||
|
||||
+------------+------------------------------+---------------------+----------------------------------------------------------+
|
||||
| series | otlp_aggregation_temporality | ts | sum(prom_rate(ts_range,greptime_value,ts,Int64(180000))) |
|
||||
+------------+------------------------------+---------------------+----------------------------------------------------------+
|
||||
| cumulative | | 1970-01-01T00:03:00 | 0.16666666666666666 |
|
||||
| delta | delta | 1970-01-01T00:03:00 | 0.25 |
|
||||
| single | delta | 1970-01-01T00:03:00 | 0.03888888888888889 |
|
||||
+------------+------------------------------+---------------------+----------------------------------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (180, 180, '1m') sum by (series) (rate(delta_temporality[3m]));
|
||||
|
||||
+------------+---------------------+----------------------------------------------------------+
|
||||
| series | ts | sum(prom_rate(ts_range,greptime_value,ts,Int64(180000))) |
|
||||
+------------+---------------------+----------------------------------------------------------+
|
||||
| cumulative | 1970-01-01T00:03:00 | 0.16666666666666666 |
|
||||
| delta | 1970-01-01T00:03:00 | 0.25 |
|
||||
| single | 1970-01-01T00:03:00 | 0.03888888888888889 |
|
||||
+------------+---------------------+----------------------------------------------------------+
|
||||
|
||||
TQL EVAL (180, 180, '1m') round(sum(rate(delta_temporality[3m])), 0.000001);
|
||||
|
||||
+---------------------+----------------------------------------------------------------------------------------+
|
||||
| ts | prom_round(sum(prom_rate(ts_range,greptime_value,ts,Int64(180000))),Float64(0.000001)) |
|
||||
+---------------------+----------------------------------------------------------------------------------------+
|
||||
| 1970-01-01T00:03:00 | 0.455556 |
|
||||
+---------------------+----------------------------------------------------------------------------------------+
|
||||
|
||||
CREATE TABLE delta_marker_only (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
otlp_aggregation_temporality STRING PRIMARY KEY
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO delta_marker_only VALUES
|
||||
(180000, 1, 'delta'),
|
||||
(180000, 2, NULL);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
CREATE TABLE delta_tagless (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
greptime_value DOUBLE
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO delta_tagless VALUES (180000, 10);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- A missing temporality marker matches the NULL cumulative state; "delta" does not.
|
||||
TQL EVAL (180, 180, '1m') delta_marker_only + delta_tagless;
|
||||
|
||||
+---------------------+----------------+------------------------------+----------+
|
||||
| ts | greptime_value | otlp_aggregation_temporality | __name__ |
|
||||
+---------------------+----------------+------------------------------+----------+
|
||||
| 1970-01-01T00:03:00 | 12.0 | | |
|
||||
+---------------------+----------------+------------------------------+----------+
|
||||
|
||||
TQL EVAL (180, 180, '1m') delta_marker_only AND delta_tagless;
|
||||
|
||||
+---------------------+----------------+------------------------------+-------------------+
|
||||
| ts | greptime_value | otlp_aggregation_temporality | __name__ |
|
||||
+---------------------+----------------+------------------------------+-------------------+
|
||||
| 1970-01-01T00:03:00 | 2.0 | | delta_marker_only |
|
||||
+---------------------+----------------+------------------------------+-------------------+
|
||||
|
||||
DROP TABLE delta_tagless;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE delta_marker_only;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE delta_temporality;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/delta_temporality.sql
|
||||
@@ -0,0 +1,115 @@
|
||||
-- NaN and rounding follow Prometheus (IEEE 754) rather than SQL ordering.
|
||||
-- Expected results are from Prometheus 3.
|
||||
create table float_semantics (
|
||||
ts timestamp time index,
|
||||
val double,
|
||||
host string primary key
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into float_semantics values
|
||||
(0, 1.0, 'a'),
|
||||
(0, 2.0, 'b'),
|
||||
(0, 'NaN'::double, 'c'),
|
||||
(0, -2.5, 'd');
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
tql eval (0, 0, '1s') max(float_semantics);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
tql eval (0, 0, '1s') min(float_semantics);
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | -2.5 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
tql eval (0, 0, '1s') topk(1, float_semantics);
|
||||
|
||||
+---------------------+-----+------+-----------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+-----------------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | b | float_semantics |
|
||||
+---------------------+-----+------+-----------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') float_semantics <= NaN;
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') float_semantics != bool NaN;
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | b | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | c | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | d | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') round(float_semantics);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | -2.0 | d | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 2.0 | b | |
|
||||
| 1970-01-01T00:00:00 | NaN | c | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') sqrt(float_semantics);
|
||||
|
||||
+---------------------+--------------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+--------------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:00 | 1.4142135623730951 | b | |
|
||||
| 1970-01-01T00:00:00 | NaN | c | |
|
||||
| 1970-01-01T00:00:00 | NaN | d | |
|
||||
+---------------------+--------------------+------+----------+
|
||||
|
||||
-- prom_min/prom_max have their own column names, so SQL can use them next to min/max.
|
||||
select min(val) as sql_lo, prom_min(val) as prom_lo from float_semantics;
|
||||
|
||||
+--------+---------+
|
||||
| sql_lo | prom_lo |
|
||||
+--------+---------+
|
||||
| -2.5 | -2.5 |
|
||||
+--------+---------+
|
||||
|
||||
select max(val) as sql_hi, prom_max(val) as prom_hi from float_semantics;
|
||||
|
||||
+--------+---------+
|
||||
| sql_hi | prom_hi |
|
||||
+--------+---------+
|
||||
| NaN | 2.0 |
|
||||
+--------+---------+
|
||||
|
||||
select prom_min(val) as lo from float_semantics having min(val) < 0;
|
||||
|
||||
+------+
|
||||
| lo |
|
||||
+------+
|
||||
| -2.5 |
|
||||
+------+
|
||||
|
||||
drop table float_semantics;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/float_semantics.sql
|
||||
@@ -0,0 +1,180 @@
|
||||
CREATE TABLE
|
||||
prom_series (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
host STRING PRIMARY KEY
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO
|
||||
prom_series (ts, val, host)
|
||||
VALUES
|
||||
(0, 0.0, 'p'),
|
||||
(300, 10.0, 'p'),
|
||||
(600, 20.0, 'p'),
|
||||
(900, 30.0, 'p'),
|
||||
(1200, 40.0, 'p'),
|
||||
(1500, 0.0, 'p'),
|
||||
(1800, 10.0, 'p'),
|
||||
(2100, 20.0, 'p'),
|
||||
(2400, 30.0, 'p'),
|
||||
(2700, 40.0, 'p'),
|
||||
(3000, 50.0, 'p');
|
||||
|
||||
Affected Rows: 11
|
||||
|
||||
-- predict_linear
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 3, '1s') predict_linear(prom_series[3s], 0);
|
||||
|
||||
+---------------------+-------------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------------------+------+----------+
|
||||
| 1970-01-01T00:00:03 | 37.27272727272727 | p | |
|
||||
+---------------------+-------------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 3, '1s') predict_linear(prom_series[3s], 3);
|
||||
|
||||
+---------------------+-------------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------------------+------+----------+
|
||||
| 1970-01-01T00:00:03 | 64.54545454545455 | p | |
|
||||
+---------------------+-------------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 3, '1s') predict_linear(prom_series[3s], 40 + 2);
|
||||
|
||||
+---------------------+------------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------------------+------+----------+
|
||||
| 1970-01-01T00:00:03 | 419.090909090909 | p | |
|
||||
+---------------------+------------------+------+----------+
|
||||
|
||||
-- double_exponential_smoothing
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (10, 10, '1s') double_exponential_smoothing(prom_series[10s], 0.4 + 0.1, 0.1);
|
||||
|
||||
+---------------------+---------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+---------------+------+----------+
|
||||
| 1970-01-01T00:00:10 | 47.0806953125 | p | |
|
||||
+---------------------+---------------+------+----------+
|
||||
|
||||
DROP TABLE prom_series;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE
|
||||
prom_series_q (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
host STRING PRIMARY KEY
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO
|
||||
prom_series_q (ts, val, host)
|
||||
VALUES
|
||||
(1000, 123.45, 'q'),
|
||||
(2000, 234.567, 'q'),
|
||||
(3000, 345.678, 'q'),
|
||||
(4000, 456.789, 'q');
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
-- quantile_over_time
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (4, 4, '1s') quantile_over_time(0.2 + 0.05, prom_series_q[4s]);
|
||||
|
||||
+---------------------+--------------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+--------------------+------+----------+
|
||||
| 1970-01-01T00:00:04 | 206.78775000000002 | q | |
|
||||
+---------------------+--------------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (4, 4, '1s') quantile_over_time(0.4 + 0.1, prom_series_q[4s]);
|
||||
|
||||
+---------------------+----------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+----------+------+----------+
|
||||
| 1970-01-01T00:00:04 | 290.1225 | q | |
|
||||
+---------------------+----------+------+----------+
|
||||
|
||||
-- round
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 3, '1s') round(prom_series_q);
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:03 | 346.0 | q | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 4, '1s') round(prom_series_q, 0.01);
|
||||
|
||||
+---------------------+--------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+--------+------+----------+
|
||||
| 1970-01-01T00:00:01 | 123.45 | q | |
|
||||
| 1970-01-01T00:00:02 | 234.57 | q | |
|
||||
| 1970-01-01T00:00:03 | 345.68 | q | |
|
||||
| 1970-01-01T00:00:04 | 456.79 | q | |
|
||||
+---------------------+--------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 4, '1s') round(prom_series_q, 0.05 + 0.05);
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:01 | 123.5 | q | |
|
||||
| 1970-01-01T00:00:02 | 234.6 | q | |
|
||||
| 1970-01-01T00:00:03 | 345.7 | q | |
|
||||
| 1970-01-01T00:00:04 | 456.8 | q | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 4, '1s') round(prom_series_q, 10.0);
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:01 | 120.0 | q | |
|
||||
| 1970-01-01T00:00:02 | 230.0 | q | |
|
||||
| 1970-01-01T00:00:03 | 350.0 | q | |
|
||||
| 1970-01-01T00:00:04 | 460.0 | q | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 4, '1s') round(prom_series_q, 100.0 + 3.0);
|
||||
|
||||
+---------------------+--------------------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+--------------------+------+----------+
|
||||
| 1970-01-01T00:00:01 | 103.00000000000001 | q | |
|
||||
| 1970-01-01T00:00:02 | 206.00000000000003 | q | |
|
||||
| 1970-01-01T00:00:03 | 309.0 | q | |
|
||||
| 1970-01-01T00:00:04 | 412.00000000000006 | q | |
|
||||
+---------------------+--------------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 4, '1s') round(prom_series_q, - 3.0 + 13.0);
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:01 | 120.0 | q | |
|
||||
| 1970-01-01T00:00:02 | 230.0 | q | |
|
||||
| 1970-01-01T00:00:03 | 350.0 | q | |
|
||||
| 1970-01-01T00:00:04 | 460.0 | q | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
DROP TABLE prom_series_q;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/functions.sql
|
||||
@@ -0,0 +1,186 @@
|
||||
-- SQL semantic inputs accompany the direct integration test for native routing and multi-partition execution.
|
||||
-- One insert and one flush keep the fixture small; this runner does not prove scan partitioning.
|
||||
-- Four series, one sample per second. Instant selectors below evaluate at 4s, so their last values
|
||||
-- are h1/left 5, h1/right 50, h2/left 10, h2/right 100.
|
||||
CREATE TABLE fused_multi_standalone (
|
||||
host STRING,
|
||||
kind STRING,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY (host, kind),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO fused_multi_standalone VALUES
|
||||
('h1', 'left', 0, 1), ('h1', 'right', 0, 10), ('h2', 'left', 0, 2), ('h2', 'right', 0, 20),
|
||||
('h1', 'left', 1000, 2), ('h1', 'right', 1000, 20), ('h2', 'left', 1000, 4), ('h2', 'right', 1000, 40),
|
||||
('h1', 'left', 2000, 3), ('h1', 'right', 2000, 30), ('h2', 'left', 2000, 6), ('h2', 'right', 2000, 60),
|
||||
('h1', 'left', 3000, 4), ('h1', 'right', 3000, 40), ('h2', 'left', 3000, 8), ('h2', 'right', 3000, 80),
|
||||
('h1', 'left', 4000, 5), ('h1', 'right', 4000, 50), ('h2', 'left', 4000, 10), ('h2', 'right', 4000, 100);
|
||||
|
||||
Affected Rows: 20
|
||||
|
||||
ADMIN FLUSH_TABLE('fused_multi_standalone');
|
||||
|
||||
+---------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('fused_multi_standalone') |
|
||||
+---------------------------------------------+
|
||||
| 0 |
|
||||
+---------------------------------------------+
|
||||
|
||||
-- Both occurrences are the same full-key selector, combined by default matching addition.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} + fused_multi_standalone{host!="",kind!=""};
|
||||
|
||||
+---------------------+-------+------+-------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+-------+------+-------+----------+
|
||||
| 1970-01-01T00:00:04 | 10.0 | h1 | left | |
|
||||
| 1970-01-01T00:00:04 | 100.0 | h1 | right | |
|
||||
| 1970-01-01T00:00:04 | 20.0 | h2 | left | |
|
||||
| 1970-01-01T00:00:04 | 200.0 | h2 | right | |
|
||||
+---------------------+-------+------+-------+----------+
|
||||
|
||||
-- Subtraction is order sensitive: each series must be minus its own last value.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} - (fused_multi_standalone{host!="",kind!=""} * 2);
|
||||
|
||||
+---------------------+--------+------+-------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+--------+------+-------+----------+
|
||||
| 1970-01-01T00:00:04 | -10.0 | h2 | left | |
|
||||
| 1970-01-01T00:00:04 | -100.0 | h2 | right | |
|
||||
| 1970-01-01T00:00:04 | -5.0 | h1 | left | |
|
||||
| 1970-01-01T00:00:04 | -50.0 | h1 | right | |
|
||||
+---------------------+--------+------+-------+----------+
|
||||
|
||||
-- A matcher-bearing range selector with @ and offset exercises scan bounds as well as labels.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone{host="h1",kind="left"}[3s] @ 3 offset 1s);
|
||||
|
||||
+---------------------+-----+------+------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+-----+------+------+----------+
|
||||
| 1970-01-01T00:00:04 | 1.0 | h1 | left | |
|
||||
+---------------------+-----+------+------+----------+
|
||||
|
||||
-- The same two selectors, added with an explicit full-key join.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} + on(host, kind) fused_multi_standalone{host!="",kind!=""};
|
||||
|
||||
+---------------------+-------+------+-------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+-------+------+-------+----------+
|
||||
| 1970-01-01T00:00:04 | 10.0 | h1 | left | |
|
||||
| 1970-01-01T00:00:04 | 100.0 | h1 | right | |
|
||||
| 1970-01-01T00:00:04 | 20.0 | h2 | left | |
|
||||
| 1970-01-01T00:00:04 | 200.0 | h2 | right | |
|
||||
+---------------------+-------+------+-------+----------+
|
||||
|
||||
-- Equality with bool keeps all four series and reports 1 for each.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} == bool fused_multi_standalone{host!="",kind!=""};
|
||||
|
||||
+---------------------+-----+------+-------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+-----+------+-------+----------+
|
||||
| 1970-01-01T00:00:04 | 1.0 | h1 | left | |
|
||||
| 1970-01-01T00:00:04 | 1.0 | h1 | right | |
|
||||
| 1970-01-01T00:00:04 | 1.0 | h2 | left | |
|
||||
| 1970-01-01T00:00:04 | 1.0 | h2 | right | |
|
||||
+---------------------+-----+------+-------+----------+
|
||||
|
||||
-- Independent matcher-bearing inputs match on host: h1 55 and h2 110.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{kind="left"} + on(host) fused_multi_standalone{kind="right"};
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:04 | 110.0 | h2 | |
|
||||
| 1970-01-01T00:00:04 | 55.0 | h1 | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- Noncommutative matching detects swapped or reused inputs: h1 -45 and h2 -90.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{kind="left"} - on(host) fused_multi_standalone{kind="right"};
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:04 | -45.0 | h1 | |
|
||||
| 1970-01-01T00:00:04 | -90.0 | h2 | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- Each range input keeps its own bounds: left ends at 2s, right at 4s; rates differ by -9/-18.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone{kind="left"}[3s] @ 3 offset 1s) - on(host) rate(fused_multi_standalone{kind="right"}[2s] @ 4);
|
||||
|
||||
+---------------------+-------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+------+----------+
|
||||
| 1970-01-01T00:00:04 | -18.0 | h2 | |
|
||||
| 1970-01-01T00:00:04 | -9.0 | h1 | |
|
||||
+---------------------+-------+------+----------+
|
||||
|
||||
-- group_right keeps the right-side kind: h1/left 10 and h1/right 55.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{kind="left",host="h1"} + on(host) group_right fused_multi_standalone{host="h1"};
|
||||
|
||||
+---------------------+------+------+-------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+------+------+-------+----------+
|
||||
| 1970-01-01T00:00:04 | 10.0 | h1 | left | |
|
||||
| 1970-01-01T00:00:04 | 55.0 | h1 | right | |
|
||||
+---------------------+------+------+-------+----------+
|
||||
|
||||
-- Raw-table anchor: @ 3 with offset 1s ends the 3s window at 2s, although evaluation is at 4s.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone[3s] @ 3 offset 1s);
|
||||
|
||||
+---------------------+------+------+-------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+------+------+-------+----------+
|
||||
| 1970-01-01T00:00:04 | 1.0 | h1 | left | |
|
||||
| 1970-01-01T00:00:04 | 10.0 | h1 | right | |
|
||||
| 1970-01-01T00:00:04 | 2.0 | h2 | left | |
|
||||
| 1970-01-01T00:00:04 | 20.0 | h2 | right | |
|
||||
+---------------------+------+------+-------+----------+
|
||||
|
||||
-- Incomplete matching identity via on() stays on fallback, even for one series.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') fused_multi_standalone{host="h1",kind="left"} - on() (fused_multi_standalone{host="h1",kind="left"} * 2);
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:00:04 | -5.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
-- Aggregate and subquery forms stay on the legacy fallback source path.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') sum(rate(fused_multi_standalone[5s]));
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:00:04 | 33.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone[5s:1s]);
|
||||
|
||||
+---------------------+------+------+-------+----------+
|
||||
| ts | val | host | kind | __name__ |
|
||||
+---------------------+------+------+-------+----------+
|
||||
| 1970-01-01T00:00:04 | 1.0 | h1 | left | |
|
||||
| 1970-01-01T00:00:04 | 10.0 | h1 | right | |
|
||||
| 1970-01-01T00:00:04 | 2.0 | h2 | left | |
|
||||
| 1970-01-01T00:00:04 | 20.0 | h2 | right | |
|
||||
+---------------------+------+------+-------+----------+
|
||||
|
||||
DROP TABLE fused_multi_standalone;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/fused_multi_standalone.sql
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
-- 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])));
|
||||
|
||||
+---------------------+----------------------+-------+----------+
|
||||
| ts | val | pod | __name__ |
|
||||
+---------------------+----------------------+-------+----------+
|
||||
| 1970-01-01T00:50:00 | 0.05 | pod-a | |
|
||||
| 1970-01-01T00:50:00 | 0.062499999999999986 | pod-b | |
|
||||
+---------------------+----------------------+-------+----------+
|
||||
|
||||
-- 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;
|
||||
|
||||
+---------------------+----------------------+-------+----------+
|
||||
| ts | val | pod | __name__ |
|
||||
+---------------------+----------------------+-------+----------+
|
||||
| 1970-01-01T00:50:00 | 0.05 | pod-a | |
|
||||
| 1970-01-01T00:50:00 | 0.062499999999999986 | pod-b | |
|
||||
+---------------------+----------------------+-------+----------+
|
||||
|
||||
-- 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;
|
||||
|
||||
+---------------------+----------------------+-------+----------+
|
||||
| ts | val | pod | __name__ |
|
||||
+---------------------+----------------------+-------+----------+
|
||||
| 1970-01-01T00:50:00 | 0.05 | pod-a | |
|
||||
| 1970-01-01T00:50:00 | 0.062499999999999986 | pod-b | |
|
||||
+---------------------+----------------------+-------+----------+
|
||||
|
||||
-- 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;
|
||||
|
||||
+---------------------+-----+-------+----------+
|
||||
| ts | val | pod | __name__ |
|
||||
+---------------------+-----+-------+----------+
|
||||
| 1970-01-01T00:50:00 | 1.0 | pod-a | |
|
||||
| 1970-01-01T00:50:00 | 1.0 | pod-b | |
|
||||
+---------------------+-----+-------+----------+
|
||||
|
||||
-- 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 | val | pod | __name__ |
|
||||
+---------------------+-----+-------+----------+
|
||||
| 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
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/histogram_quantile_binary_op.sql
|
||||
@@ -0,0 +1,552 @@
|
||||
-- Correctness coverage for the instant-selector last-row optimization.
|
||||
-- Each TQL EVAL below has distinct values so its chosen physical sample is visible.
|
||||
-- The default instant lookback is (T - 300s, T]: exclude its lower bound,
|
||||
-- include a sample just inside it and at T, and exclude a future sample.
|
||||
CREATE TABLE instant_last_lookback (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_lookback VALUES
|
||||
(700000, 10, 'lower_excluded'),
|
||||
(700001, 11, 'just_inside'),
|
||||
(1000000, 12, 'upper_included'),
|
||||
(1000000, 14, 'future_has_prior'),
|
||||
(1000001, 13, 'future_has_prior');
|
||||
|
||||
Affected Rows: 5
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_lookback');
|
||||
|
||||
+--------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_lookback') |
|
||||
+--------------------------------------------+
|
||||
| 0 |
|
||||
+--------------------------------------------+
|
||||
|
||||
-- Expected pairs: just_inside=11, upper_included=12, future_has_prior=14.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_lookback;
|
||||
|
||||
+---------------------+------+------------------+-----------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+------------------+-----------------------+
|
||||
| 1970-01-01T00:16:40 | 11.0 | just_inside | instant_last_lookback |
|
||||
| 1970-01-01T00:16:40 | 12.0 | upper_included | instant_last_lookback |
|
||||
| 1970-01-01T00:16:40 | 14.0 | future_has_prior | instant_last_lookback |
|
||||
+---------------------+------+------------------+-----------------------+
|
||||
|
||||
-- An empty table must remain an empty instant vector.
|
||||
CREATE TABLE instant_last_empty (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Expected: no rows.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_empty;
|
||||
|
||||
+----+-----+--------+----------+
|
||||
| ts | val | series | __name__ |
|
||||
+----+-----+--------+----------+
|
||||
+----+-----+--------+----------+
|
||||
|
||||
DROP TABLE instant_last_empty;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE instant_last_lookback;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Positive offset reads earlier data; negative offset reads later data. Repeat
|
||||
-- the earlier evaluation after a later one to catch a cached instant window.
|
||||
CREATE TABLE instant_last_offset (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_offset VALUES
|
||||
(940000, 21, 'offset'),
|
||||
(1000000, 22, 'offset'),
|
||||
(1060000, 23, 'offset');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_offset');
|
||||
|
||||
+------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_offset') |
|
||||
+------------------------------------------+
|
||||
| 0 |
|
||||
+------------------------------------------+
|
||||
|
||||
-- Expected value: 22.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_offset;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 22.0 | offset | instant_last_offset |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
-- Expected value: 21 (evaluation time shifted back 60s).
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_offset offset 60s;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 21.0 | offset | instant_last_offset |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
-- Expected value: 23 (evaluation time shifted forward 60s).
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_offset offset -60s;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 23.0 | offset | instant_last_offset |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
-- Expected value: 23.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1060, 1060, '1s') instant_last_offset;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:17:40 | 23.0 | offset | instant_last_offset |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
-- Expected value: 22 again, not the later evaluation's value.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_offset;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 22.0 | offset | instant_last_offset |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
DROP TABLE instant_last_offset;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Put t1 and t2 in one SST. Deleting newest t2 must reveal t1 whether the
|
||||
-- Delete is still in the memtable or has been flushed to a newer SST.
|
||||
CREATE TABLE instant_last_delete (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_delete VALUES
|
||||
(900000, 31, 'delete'),
|
||||
(1000000, 32, 'delete');
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_delete');
|
||||
|
||||
+------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_delete') |
|
||||
+------------------------------------------+
|
||||
| 0 |
|
||||
+------------------------------------------+
|
||||
|
||||
DELETE FROM instant_last_delete WHERE series = 'delete' AND ts = 1000000;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- Expected value: 31; the newest point is a memtable Delete.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_delete;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 31.0 | delete | instant_last_delete |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_delete');
|
||||
|
||||
+------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_delete') |
|
||||
+------------------------------------------+
|
||||
| 0 |
|
||||
+------------------------------------------+
|
||||
|
||||
-- Expected value: 31; the Delete is now in an SST.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_delete;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 31.0 | delete | instant_last_delete |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
-- A same-timestamp memtable overwrite of t1 must win over the old SST value.
|
||||
INSERT INTO instant_last_delete VALUES (900000, 33, 'delete');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- Expected value: 33.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_delete;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 33.0 | delete | instant_last_delete |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
-- A newer memtable point must win, and retain that identity after its flush.
|
||||
INSERT INTO instant_last_delete VALUES (1010000, 34, 'delete');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- Expected value: 34.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1010, 1010, '1s') instant_last_delete;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:50 | 34.0 | delete | instant_last_delete |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_delete');
|
||||
|
||||
+------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_delete') |
|
||||
+------------------------------------------+
|
||||
| 0 |
|
||||
+------------------------------------------+
|
||||
|
||||
-- Expected value: 33 after flush; it overwrites t1 in an older SST.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_delete;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:40 | 33.0 | delete | instant_last_delete |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
-- Expected value: 34 after flush.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1010, 1010, '1s') instant_last_delete;
|
||||
|
||||
+---------------------+------+--------+---------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+---------------------+
|
||||
| 1970-01-01T00:16:50 | 34.0 | delete | instant_last_delete |
|
||||
+---------------------+------+--------+---------------------+
|
||||
|
||||
DROP TABLE instant_last_delete;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Ordinary IEEE NaN is a valid PromQL sample and must not be suppressed.
|
||||
CREATE TABLE instant_last_nan (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_nan VALUES (1000000, 'NaN'::DOUBLE, 'ordinary_nan');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_nan');
|
||||
|
||||
+---------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_nan') |
|
||||
+---------------------------------------+
|
||||
| 0 |
|
||||
+---------------------------------------+
|
||||
|
||||
-- Expected value: NaN, with the ordinary_nan series present.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1000, 1000, '1s') instant_last_nan;
|
||||
|
||||
+---------------------+-----+--------------+------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+-----+--------------+------------------+
|
||||
| 1970-01-01T00:16:40 | NaN | ordinary_nan | instant_last_nan |
|
||||
+---------------------+-----+--------------+------------------+
|
||||
|
||||
DROP TABLE instant_last_nan;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- PromQL normalizes to milliseconds; these distinct raw timestamps collide at
|
||||
-- 1s. LastRow must preserve the unhinted path's selected samples: 42 and 52.
|
||||
CREATE TABLE instant_last_sec (
|
||||
ts TIMESTAMP(0) TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_sec VALUES
|
||||
(0, 61, 'sec'),
|
||||
(1, 62, 'sec'),
|
||||
(2, 63, 'sec');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_sec');
|
||||
|
||||
+---------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_sec') |
|
||||
+---------------------------------------+
|
||||
| 0 |
|
||||
+---------------------------------------+
|
||||
|
||||
-- Expected value: 62 at the native seconds boundary.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1, 1, '1s') instant_last_sec;
|
||||
|
||||
+------+--------+---------------------+
|
||||
| val | series | ts |
|
||||
+------+--------+---------------------+
|
||||
| 62.0 | sec | 1970-01-01T00:00:01 |
|
||||
+------+--------+---------------------+
|
||||
|
||||
CREATE TABLE instant_last_micro (
|
||||
ts TIMESTAMP(6) TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_micro VALUES
|
||||
(999999, 41, 'micro'),
|
||||
(1000000, 42, 'micro'),
|
||||
(1000001, 43, 'micro');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_micro');
|
||||
|
||||
+-----------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_micro') |
|
||||
+-----------------------------------------+
|
||||
| 0 |
|
||||
+-----------------------------------------+
|
||||
|
||||
-- Expected value: 42, matching the unhinted millisecond-normalized path.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1, 1, '1s') instant_last_micro;
|
||||
|
||||
+------+--------+---------------------+
|
||||
| val | series | ts |
|
||||
+------+--------+---------------------+
|
||||
| 42.0 | micro | 1970-01-01T00:00:01 |
|
||||
+------+--------+---------------------+
|
||||
|
||||
CREATE TABLE instant_last_nano (
|
||||
ts TIMESTAMP(9) TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_nano VALUES
|
||||
(999999999, 51, 'nano'),
|
||||
(1000000000, 52, 'nano'),
|
||||
(1000000001, 53, 'nano');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_nano');
|
||||
|
||||
+----------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_nano') |
|
||||
+----------------------------------------+
|
||||
| 0 |
|
||||
+----------------------------------------+
|
||||
|
||||
-- Expected value: 52, matching the unhinted millisecond-normalized path.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1, 1, '1s') instant_last_nano;
|
||||
|
||||
+------+--------+---------------------+
|
||||
| val | series | ts |
|
||||
+------+--------+---------------------+
|
||||
| 52.0 | nano | 1970-01-01T00:00:01 |
|
||||
+------+--------+---------------------+
|
||||
|
||||
DROP TABLE instant_last_sec;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE instant_last_micro;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE instant_last_nano;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- A field selector chooses the val column; it does not filter val. PromQL must
|
||||
-- apply the comparison after selecting the latest eligible sample, rather than
|
||||
-- falling back to an older sample that satisfies the comparison.
|
||||
CREATE TABLE instant_last_field_filter (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
host STRING,
|
||||
instance STRING,
|
||||
PRIMARY KEY (host, instance)
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Keep the older matching sample in an SST and the latest non-matching sample
|
||||
-- in the memtable. Both timestamps are eligible at 1s.
|
||||
INSERT INTO instant_last_field_filter VALUES (900, 10, 'host-a', 'instance-a');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_field_filter');
|
||||
|
||||
+------------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_field_filter') |
|
||||
+------------------------------------------------+
|
||||
| 0 |
|
||||
+------------------------------------------------+
|
||||
|
||||
INSERT INTO instant_last_field_filter VALUES (1000, 1, 'host-a', 'instance-a');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- Expected: no rows. The selected latest value is 1, so it must not fall back
|
||||
-- to the older value 10 merely because that value is greater than 5.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1, 1, '1s') instant_last_field_filter{__field__="val"} > 5;
|
||||
|
||||
+-----+------+----------+----+
|
||||
| val | host | instance | ts |
|
||||
+-----+------+----------+----+
|
||||
+-----+------+----------+----+
|
||||
|
||||
-- A value matcher filters the scan before selecting a sample: the older 10
|
||||
-- remains eligible, unlike the post-selection comparison above.
|
||||
TQL EVAL (1, 1, '1s') instant_last_field_filter{val="10.0"};
|
||||
|
||||
+---------------------+------+--------+------------+---------------------------+
|
||||
| ts | val | host | instance | __name__ |
|
||||
+---------------------+------+--------+------------+---------------------------+
|
||||
| 1970-01-01T00:00:01 | 10.0 | host-a | instance-a | instant_last_field_filter |
|
||||
+---------------------+------+--------+------------+---------------------------+
|
||||
|
||||
-- SQL filters rows before aggregation, so the older matching value remains.
|
||||
-- Expected value: 10.
|
||||
SELECT last_value(val ORDER BY ts) FROM instant_last_field_filter WHERE val > 5;
|
||||
|
||||
+--------------------------------------------------------------------------------------------------+
|
||||
| last_value(instant_last_field_filter.val) ORDER BY [instant_last_field_filter.ts ASC NULLS LAST] |
|
||||
+--------------------------------------------------------------------------------------------------+
|
||||
| 10.0 |
|
||||
+--------------------------------------------------------------------------------------------------+
|
||||
|
||||
DROP TABLE instant_last_field_filter;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Range evaluation is a control: range functions need their complete windows,
|
||||
-- not a single last row. At 10s and 20s, [11s] contains two samples.
|
||||
CREATE TABLE instant_last_range_control (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
series STRING PRIMARY KEY
|
||||
) ENGINE=mito;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO instant_last_range_control VALUES
|
||||
(0, 0, 'range'),
|
||||
(10000, 10, 'range'),
|
||||
(20000, 20, 'range');
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
ADMIN FLUSH_TABLE('instant_last_range_control');
|
||||
|
||||
+-------------------------------------------------+
|
||||
| ADMIN FLUSH_TABLE('instant_last_range_control') |
|
||||
+-------------------------------------------------+
|
||||
| 0 |
|
||||
+-------------------------------------------------+
|
||||
|
||||
-- Expected instant values at 0s, 10s, and 20s: 0, 10, and 20.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '10s') instant_last_range_control;
|
||||
|
||||
+---------------------+------+--------+----------------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+----------------------------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | range | instant_last_range_control |
|
||||
| 1970-01-01T00:00:10 | 10.0 | range | instant_last_range_control |
|
||||
| 1970-01-01T00:00:20 | 20.0 | range | instant_last_range_control |
|
||||
+---------------------+------+--------+----------------------------+
|
||||
|
||||
-- Expected last values at 0s, 10s, and 20s: 0, 10, and 20.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '10s') last_over_time(instant_last_range_control[11s]);
|
||||
|
||||
+---------------------+------+--------+----------------------------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+------+--------+----------------------------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | range | instant_last_range_control |
|
||||
| 1970-01-01T00:00:10 | 10.0 | range | instant_last_range_control |
|
||||
| 1970-01-01T00:00:20 | 20.0 | range | instant_last_range_control |
|
||||
+---------------------+------+--------+----------------------------+
|
||||
|
||||
-- At 10s, rate is 10/11 because counter-zero extrapolation stops at 0s;
|
||||
-- at 20s it is 1. The 0s window has only one sample.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '10s') rate(instant_last_range_control[11s]);
|
||||
|
||||
+---------------------+--------------------+--------+----------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+--------------------+--------+----------+
|
||||
| 1970-01-01T00:00:10 | 0.9090909090909092 | range | |
|
||||
| 1970-01-01T00:00:20 | 1.0 | range | |
|
||||
+---------------------+--------------------+--------+----------+
|
||||
|
||||
-- Expected rate at 20s: 1 from both points in the [11s] window.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (20, 20, '1s') rate(instant_last_range_control[11s]);
|
||||
|
||||
+---------------------+-----+--------+----------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+-----+--------+----------+
|
||||
| 1970-01-01T00:00:20 | 1.0 | range | |
|
||||
+---------------------+-----+--------+----------+
|
||||
|
||||
DROP TABLE instant_last_range_control;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/instant_last_row.sql
|
||||
@@ -0,0 +1,535 @@
|
||||
CREATE TABLE test (
|
||||
ts timestamp(3) time index,
|
||||
host STRING,
|
||||
idc STRING,
|
||||
val BIGINT,
|
||||
PRIMARY KEY(host, idc),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE test VALUES
|
||||
(0, 'host1', 'idc1', 1),
|
||||
(0, 'host2', 'idc1', 2),
|
||||
(5000, 'host1', 'idc2:zone1',3),
|
||||
(5000, 'host2', 'idc2',4),
|
||||
(10000, 'host1', 'idc3:zone2',5),
|
||||
(10000, 'host2', 'idc3',6),
|
||||
(15000, 'host1', 'idc4:zone3',7),
|
||||
(15000, 'host2', 'idc4',8);
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
-- Missing source labels --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_join(test{host="host1"}, "new_host", "-");
|
||||
|
||||
+---------------------+-----+----------+-------+------------+
|
||||
| ts | val | new_host | host | idc |
|
||||
+---------------------+-----+----------+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | | host1 | idc4:zone3 |
|
||||
+---------------------+-----+----------+-------+------------+
|
||||
|
||||
-- dst_label is equal to source label --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_join(test{host="host1"}, "host", "-", "host");
|
||||
|
||||
+---------------------+-----+-------+------------+
|
||||
| ts | val | host | idc |
|
||||
+---------------------+-----+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | host1 | idc4:zone3 |
|
||||
+---------------------+-----+-------+------------+
|
||||
|
||||
-- dst_label is in source labels --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_join(test{host="host1"}, "host", "-", "idc", "host");
|
||||
|
||||
+---------------------+-----+------------------+------------+
|
||||
| ts | val | host | idc |
|
||||
+---------------------+-----+------------------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | idc1-host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | idc1-host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | idc2:zone1-host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | idc1-host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | idc2:zone1-host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | idc3:zone2-host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | idc1-host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | idc2:zone1-host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | idc3:zone2-host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | idc4:zone3-host1 | idc4:zone3 |
|
||||
+---------------------+-----+------------------+------------+
|
||||
|
||||
-- Absent labels join as empty strings and keep their separators --
|
||||
TQL EVAL (0, 15, '5s') label_join(label_join(vector(1), "a", "", "missing"), "b", "-", "a", "a");
|
||||
|
||||
+---------------------+-------+---+---+----------+
|
||||
| time | value | a | b | __name__ |
|
||||
+---------------------+-------+---+---+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | | - | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | | - | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | | - | |
|
||||
| 1970-01-01T00:00:15 | 1.0 | | - | |
|
||||
+---------------------+-------+---+---+----------+
|
||||
|
||||
-- An empty source label name is invalid --
|
||||
TQL EVAL (0, 15, '5s') label_join(test{host="host1"}, "host", "-", "");
|
||||
|
||||
Error: 1004(InvalidArguments), Invalid function argument for label_join
|
||||
|
||||
-- Both hosts are joined to the same `host` at 0s, leaving two series with the same label set --
|
||||
TQL EVAL (0, 15, '5s') label_join(test, "host", "-", "idc");
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: vector cannot contain metrics with the same labelset
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_join(test{host="host1"}, "new_host", "-", "idc", "host");
|
||||
|
||||
+---------------------+-----+------------------+-------+------------+
|
||||
| ts | val | new_host | host | idc |
|
||||
+---------------------+-----+------------------+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | idc1-host1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | idc1-host1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | idc2:zone1-host1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | idc1-host1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | idc2:zone1-host1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | idc3:zone2-host1 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | idc1-host1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | idc2:zone1-host1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | idc3:zone2-host1 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | idc4:zone3-host1 | host1 | idc4:zone3 |
|
||||
+---------------------+-----+------------------+-------+------------+
|
||||
|
||||
-- Should return empty result instead of error
|
||||
tql eval label_join(demo_num_cpus, "new_label", "-", "instance", "job");
|
||||
|
||||
+------+-------+-----------+
|
||||
| time | value | new_label |
|
||||
+------+-------+-----------+
|
||||
+------+-------+-----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{host="host1"}, "new_idc", "$2", "idc", "(.*):(.*)");
|
||||
|
||||
+---------------------+-----+---------+-------+------------+
|
||||
| ts | val | new_idc | host | idc |
|
||||
+---------------------+-----+---------+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | zone1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | zone1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | zone2 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | zone1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | zone2 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | zone3 | host1 | idc4:zone3 |
|
||||
+---------------------+-----+---------+-------+------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{host="host1"}, "new_idc", "idc99", "idc", "idc2.*");
|
||||
|
||||
+---------------------+-----+---------+-------+------------+
|
||||
| ts | val | new_idc | host | idc |
|
||||
+---------------------+-----+---------+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | idc99 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | idc99 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | idc99 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | | host1 | idc4:zone3 |
|
||||
+---------------------+-----+---------+-------+------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{host="host2"}, "new_idc", "$2", "idc", "(.*):(.*)");
|
||||
|
||||
+---------------------+-----+---------+-------+------+
|
||||
| ts | val | new_idc | host | idc |
|
||||
+---------------------+-----+---------+-------+------+
|
||||
| 1970-01-01T00:00:00 | 2 | | host2 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 2 | | host2 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 4 | | host2 | idc2 |
|
||||
| 1970-01-01T00:00:10 | 2 | | host2 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 4 | | host2 | idc2 |
|
||||
| 1970-01-01T00:00:10 | 6 | | host2 | idc3 |
|
||||
| 1970-01-01T00:00:15 | 2 | | host2 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 4 | | host2 | idc2 |
|
||||
| 1970-01-01T00:00:15 | 6 | | host2 | idc3 |
|
||||
| 1970-01-01T00:00:15 | 8 | | host2 | idc4 |
|
||||
+---------------------+-----+---------+-------+------+
|
||||
|
||||
-- dst_label is equal to source label --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{host="host2"}, "idc", "$2", "idc", "(.*):(.*)");
|
||||
|
||||
+---------------------+-----+------+-------+
|
||||
| ts | val | idc | host |
|
||||
+---------------------+-----+------+-------+
|
||||
| 1970-01-01T00:00:00 | 2 | idc1 | host2 |
|
||||
| 1970-01-01T00:00:05 | 2 | idc1 | host2 |
|
||||
| 1970-01-01T00:00:05 | 4 | idc2 | host2 |
|
||||
| 1970-01-01T00:00:10 | 2 | idc1 | host2 |
|
||||
| 1970-01-01T00:00:10 | 4 | idc2 | host2 |
|
||||
| 1970-01-01T00:00:10 | 6 | idc3 | host2 |
|
||||
| 1970-01-01T00:00:15 | 2 | idc1 | host2 |
|
||||
| 1970-01-01T00:00:15 | 4 | idc2 | host2 |
|
||||
| 1970-01-01T00:00:15 | 6 | idc3 | host2 |
|
||||
| 1970-01-01T00:00:15 | 8 | idc4 | host2 |
|
||||
+---------------------+-----+------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{host="host1"}, "idc", "$2", "idc", "(.*):(.*)");
|
||||
|
||||
+---------------------+-----+-------+-------+
|
||||
| ts | val | idc | host |
|
||||
+---------------------+-----+-------+-------+
|
||||
| 1970-01-01T00:00:00 | 1 | idc1 | host1 |
|
||||
| 1970-01-01T00:00:05 | 1 | idc1 | host1 |
|
||||
| 1970-01-01T00:00:05 | 3 | zone1 | host1 |
|
||||
| 1970-01-01T00:00:10 | 1 | idc1 | host1 |
|
||||
| 1970-01-01T00:00:10 | 3 | zone1 | host1 |
|
||||
| 1970-01-01T00:00:10 | 5 | zone2 | host1 |
|
||||
| 1970-01-01T00:00:15 | 1 | idc1 | host1 |
|
||||
| 1970-01-01T00:00:15 | 3 | zone1 | host1 |
|
||||
| 1970-01-01T00:00:15 | 5 | zone2 | host1 |
|
||||
| 1970-01-01T00:00:15 | 7 | zone3 | host1 |
|
||||
+---------------------+-----+-------+-------+
|
||||
|
||||
-- Both hosts are rewritten to the same `host`, leaving two series with the same label set --
|
||||
TQL EVAL (0, 15, '5s') label_replace(test, "host", "x", "host", ".*");
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: vector cannot contain metrics with the same labelset
|
||||
|
||||
-- test the empty source label --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{host="host2"}, "idc2", "", "", "");
|
||||
|
||||
+---------------------+-----+-------+------+
|
||||
| ts | val | host | idc |
|
||||
+---------------------+-----+-------+------+
|
||||
| 1970-01-01T00:00:00 | 2 | host2 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 2 | host2 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 4 | host2 | idc2 |
|
||||
| 1970-01-01T00:00:10 | 2 | host2 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 4 | host2 | idc2 |
|
||||
| 1970-01-01T00:00:10 | 6 | host2 | idc3 |
|
||||
| 1970-01-01T00:00:15 | 2 | host2 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 4 | host2 | idc2 |
|
||||
| 1970-01-01T00:00:15 | 6 | host2 | idc3 |
|
||||
| 1970-01-01T00:00:15 | 8 | host2 | idc4 |
|
||||
+---------------------+-----+-------+------+
|
||||
|
||||
-- Issue 5726 --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') label_replace(vector(1), "host", "host1", "", "");
|
||||
|
||||
+---------------------+-------+-------+----------+
|
||||
| time | value | host | __name__ |
|
||||
+---------------------+-------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | host1 | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | host1 | |
|
||||
| 1970-01-01T00:00:10 | 1.0 | host1 | |
|
||||
| 1970-01-01T00:00:15 | 1.0 | host1 | |
|
||||
+---------------------+-------+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') {__name__="test",host="host1"} * label_replace(vector(1), "host", "host1", "", "");
|
||||
|
||||
+------+------+----------------------------+
|
||||
| host | time | test.val * .greptime_value |
|
||||
+------+------+----------------------------+
|
||||
+------+------+----------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') {__name__="test",host="host1"} + label_replace(vector(1), "host", "host1", "", "");
|
||||
|
||||
+------+------+----------------------------+
|
||||
| host | time | test.val + .greptime_value |
|
||||
+------+------+----------------------------+
|
||||
+------+------+----------------------------+
|
||||
|
||||
-- Empty regex with existing source label
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') label_replace(test{host="host1"}, "host2", "host2", "host", "");
|
||||
|
||||
+---------------------+-----+-------+-------+------------+
|
||||
| ts | val | host2 | host | idc |
|
||||
+---------------------+-----+-------+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | | host1 | idc4:zone3 |
|
||||
+---------------------+-----+-------+-------+------------+
|
||||
|
||||
-- Empty regex with not existing source label
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') label_replace(test{host="host1"}, "host2", "host2", "instance", "");
|
||||
|
||||
+---------------------+-----+-------+-------+------------+
|
||||
| ts | val | host2 | host | idc |
|
||||
+---------------------+-----+-------+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | host2 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | host2 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | host2 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | host2 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | host2 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | host2 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | host2 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | host2 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | host2 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | host2 | host1 | idc4:zone3 |
|
||||
+---------------------+-----+-------+-------+------------+
|
||||
|
||||
-- Empty regex with not existing source label, but replacement is empty
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') label_replace(test{host="host1"}, "host2", "", "instance", "");
|
||||
|
||||
+---------------------+-----+-------+------------+
|
||||
| ts | val | host | idc |
|
||||
+---------------------+-----+-------+------------+
|
||||
| 1970-01-01T00:00:00 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 3 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 3 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 5 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 1 | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 3 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 5 | host1 | idc3:zone2 |
|
||||
| 1970-01-01T00:00:15 | 7 | host1 | idc4:zone3 |
|
||||
+---------------------+-----+-------+------------+
|
||||
|
||||
-- An empty replacement removes an existing label --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{idc="idc1"}, "idc", "", "instance", "");
|
||||
|
||||
+---------------------+-----+-----+-------+
|
||||
| ts | val | idc | host |
|
||||
+---------------------+-----+-----+-------+
|
||||
| 1970-01-01T00:00:00 | 1 | | host1 |
|
||||
| 1970-01-01T00:00:00 | 2 | | host2 |
|
||||
| 1970-01-01T00:00:05 | 1 | | host1 |
|
||||
| 1970-01-01T00:00:05 | 2 | | host2 |
|
||||
| 1970-01-01T00:00:10 | 1 | | host1 |
|
||||
| 1970-01-01T00:00:10 | 2 | | host2 |
|
||||
| 1970-01-01T00:00:15 | 1 | | host1 |
|
||||
| 1970-01-01T00:00:15 | 2 | | host2 |
|
||||
+---------------------+-----+-----+-------+
|
||||
|
||||
-- Empty regex and different label value
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') {__name__="test",host="host1"} * label_replace(vector(1), "host", "host2", "host", "");
|
||||
|
||||
+------+------+----------------------------+
|
||||
| host | time | test.val * .greptime_value |
|
||||
+------+------+----------------------------+
|
||||
+------+------+----------------------------+
|
||||
|
||||
-- Empty regex and not existing label in left expression
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL(0, 15, '5s') {__name__="test",host="host1"} * label_replace(vector(1), "addr", "host1", "instance", "");
|
||||
|
||||
+------+------+----------------------------+
|
||||
| addr | time | test.val * .greptime_value |
|
||||
+------+------+----------------------------+
|
||||
+------+------+----------------------------+
|
||||
|
||||
TQL EVAL label_replace(demo_num_cpus, "~invalid", "", "src", "(.*)");
|
||||
|
||||
Error: 1004(InvalidArguments), Invalid destination label name in label_replace(): ~invalid
|
||||
|
||||
TQL EVAL label_replace(demo_num_cpus, "job", "value", "src", "(.*");
|
||||
|
||||
Error: 1004(InvalidArguments), Invalid regular expression in label_replace(): (.*
|
||||
|
||||
-- Issue 6438 --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_replace(test{host="host1"}, "new_idc", "idc99", "idc", "idc2.*") == 1.0;
|
||||
|
||||
+---------------------+-----+---------+-------+------+
|
||||
| ts | val | new_idc | host | idc |
|
||||
+---------------------+-----+---------+-------+------+
|
||||
| 1970-01-01T00:00:00 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:05 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:10 | 1 | | host1 | idc1 |
|
||||
| 1970-01-01T00:00:15 | 1 | | host1 | idc1 |
|
||||
+---------------------+-----+---------+-------+------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') label_join(test{host="host1"}, "new_host", "-", "idc", "host") == 3;
|
||||
|
||||
+---------------------+-----+------------------+-------+------------+
|
||||
| ts | val | new_host | host | idc |
|
||||
+---------------------+-----+------------------+-------+------------+
|
||||
| 1970-01-01T00:00:05 | 3 | idc2:zone1-host1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:10 | 3 | idc2:zone1-host1 | host1 | idc2:zone1 |
|
||||
| 1970-01-01T00:00:15 | 3 | idc2:zone1-host1 | host1 | idc2:zone1 |
|
||||
+---------------------+-----+------------------+-------+------------+
|
||||
|
||||
-- Issue 8969 --
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') sum by (foo) (label_replace(test, "foo", "$1", "host", "(.*)")) * 0.8;
|
||||
|
||||
+-------+---------------------+------------------------------+
|
||||
| foo | ts | sum(test.val) * Float64(0.8) |
|
||||
+-------+---------------------+------------------------------+
|
||||
| host1 | 1970-01-01T00:00:00 | 0.8 |
|
||||
| host1 | 1970-01-01T00:00:05 | 3.2 |
|
||||
| host1 | 1970-01-01T00:00:10 | 7.2 |
|
||||
| host1 | 1970-01-01T00:00:15 | 12.8 |
|
||||
| host2 | 1970-01-01T00:00:00 | 1.6 |
|
||||
| host2 | 1970-01-01T00:00:05 | 4.800000000000001 |
|
||||
| host2 | 1970-01-01T00:00:10 | 9.600000000000001 |
|
||||
| host2 | 1970-01-01T00:00:15 | 16.0 |
|
||||
+-------+---------------------+------------------------------+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE test (
|
||||
ts timestamp(3) time index,
|
||||
host STRING,
|
||||
val BIGINT,
|
||||
PRIMARY KEY(host),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE test VALUES
|
||||
(0, 'host1', 1),
|
||||
(0, 'host2', 2);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
SELECT * FROM test;
|
||||
|
||||
+---------------------+-------+-----+
|
||||
| ts | host | val |
|
||||
+---------------------+-------+-----+
|
||||
| 1970-01-01T00:00:00 | host1 | 1 |
|
||||
| 1970-01-01T00:00:00 | host2 | 2 |
|
||||
+---------------------+-------+-----+
|
||||
|
||||
-- test the non-existent matchers --
|
||||
TQL EVAL (0, 1, '5s') test{job=~"host1|host3"};
|
||||
|
||||
+----+------+-----+
|
||||
| ts | host | val |
|
||||
+----+------+-----+
|
||||
+----+------+-----+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 1, '5s') test{job=~".*"};
|
||||
|
||||
+---------------------+-------+-----+
|
||||
| ts | host | val |
|
||||
+---------------------+-------+-----+
|
||||
| 1970-01-01T00:00:00 | host1 | 1 |
|
||||
| 1970-01-01T00:00:00 | host2 | 2 |
|
||||
+---------------------+-------+-----+
|
||||
|
||||
TQL EVAL (0, 1, '5s') test{job=~".+"};
|
||||
|
||||
+----+------+-----+
|
||||
| ts | host | val |
|
||||
+----+------+-----+
|
||||
+----+------+-----+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 1, '5s') test{job=""};
|
||||
|
||||
+---------------------+-------+-----+
|
||||
| ts | host | val |
|
||||
+---------------------+-------+-----+
|
||||
| 1970-01-01T00:00:00 | host1 | 1 |
|
||||
| 1970-01-01T00:00:00 | host2 | 2 |
|
||||
+---------------------+-------+-----+
|
||||
|
||||
TQL EVAL (0, 1, '5s') test{job!=""};
|
||||
|
||||
+----+------+-----+
|
||||
| ts | host | val |
|
||||
+----+------+-----+
|
||||
+----+------+-----+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Issue 9444 --
|
||||
-- Normalizing mixed histogram boundary representations must not be rejected while
|
||||
-- another label still tells the series apart.
|
||||
CREATE TABLE demo_bucket (
|
||||
ts timestamp(3) time index,
|
||||
instance STRING,
|
||||
le STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY(instance, le),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE demo_bucket VALUES
|
||||
(3000000, 'a', '10', 40),
|
||||
(3000000, 'a', '100', 50),
|
||||
(3000000, 'a', '+Inf', 50),
|
||||
(3000000, 'b', '10.0', 40),
|
||||
(3000000, 'b', '100.0', 50),
|
||||
(3000000, 'b', '1000.0', 50),
|
||||
(3000000, 'b', '+Inf', 50);
|
||||
|
||||
Affected Rows: 7
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (3000, 3000, '5s') label_replace(demo_bucket, "le", "$1", "le", "([0-9]+)[.]0+");
|
||||
|
||||
+---------------------+------+----------+------+-------------+
|
||||
| ts | val | instance | le | __name__ |
|
||||
+---------------------+------+----------+------+-------------+
|
||||
| 1970-01-01T00:50:00 | 40.0 | a | 10 | demo_bucket |
|
||||
| 1970-01-01T00:50:00 | 40.0 | b | 10 | demo_bucket |
|
||||
| 1970-01-01T00:50:00 | 50.0 | a | +Inf | demo_bucket |
|
||||
| 1970-01-01T00:50:00 | 50.0 | a | 100 | demo_bucket |
|
||||
| 1970-01-01T00:50:00 | 50.0 | b | +Inf | demo_bucket |
|
||||
| 1970-01-01T00:50:00 | 50.0 | b | 100 | demo_bucket |
|
||||
| 1970-01-01T00:50:00 | 50.0 | b | 1000 | demo_bucket |
|
||||
+---------------------+------+----------+------+-------------+
|
||||
|
||||
-- Aggregating `instance` away first makes the same rewrite collapse two series into
|
||||
-- one label set, which is a genuine duplicate and must still fail.
|
||||
TQL EVAL (3000, 3000, '5s') label_replace(sum by (le) (demo_bucket), "le", "$1", "le", "([0-9]+)[.]0+");
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: vector cannot contain metrics with the same labelset {le="10"}: two series hold a value of field 0 at position 0 (Run { start: 0, end: 1 } and Run { start: 0, end: 1 })
|
||||
|
||||
DROP TABLE demo_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/label.sql
|
||||
@@ -0,0 +1,140 @@
|
||||
CREATE TABLE matching_groups_left (
|
||||
host STRING NULL,
|
||||
"zone" STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, "zone")
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE matching_groups_right (
|
||||
host STRING NULL,
|
||||
"zone" STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, "zone")
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO matching_groups_left VALUES
|
||||
('x', 'a', 0, 12), ('x', 'b', 0, 24), ('y', 'a', 0, 36),
|
||||
('', 'a', 0, 48), (NULL, 'a', 0, 60);
|
||||
|
||||
Affected Rows: 5
|
||||
|
||||
INSERT INTO matching_groups_right VALUES
|
||||
('x', 'a', 0, 2), ('x', 'b', 0, 4), ('y', 'a', 0, 100),
|
||||
('', 'a', 0, 8), (NULL, 'a', 0, 10);
|
||||
|
||||
Affected Rows: 5
|
||||
|
||||
-- Filtering whole ranking partitions preserves the aggregate and scalar arithmetic.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') (8 * matching_groups_left{host="x"}) / on(host) group_left topk by(host)(1, max by(host)(matching_groups_right));
|
||||
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| ts | greptime_value | host | zone | __name__ |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 24.0 | x | a | |
|
||||
| 1970-01-01T00:00:00 | 48.0 | x | b | |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') sum by(host)(matching_groups_left) / on(host) group_right() (matching_groups_right{host="x"} * 2);
|
||||
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| ts | greptime_value | host | zone | __name__ |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 4.5 | x | b | |
|
||||
| 1970-01-01T00:00:00 | 9.0 | x | a | |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host!="y"} / on(host) group_left max by(host)(matching_groups_right);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: multiple matches for labels {zone="a"} at 0 ms: grouping labels must ensure unique matches
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host=~"x|y"} / on(host) group_left max by(host)(matching_groups_right);
|
||||
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| ts | greptime_value | host | zone | __name__ |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.36 | y | a | |
|
||||
| 1970-01-01T00:00:00 | 3.0 | x | a | |
|
||||
| 1970-01-01T00:00:00 | 6.0 | x | b | |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host=""} / on(host) group_left max by(host)(matching_groups_right);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: multiple matches for labels {zone="a"} at 0 ms: grouping labels must ensure unique matches
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host!~"x|y"} / on(host) group_left max by(host)(matching_groups_right);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: multiple matches for labels {zone="a"} at 0 ms: grouping labels must ensure unique matches
|
||||
|
||||
-- bottomk partitions by host when zone is excluded from grouping.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') bottomk without(zone)(1, matching_groups_left) / on(host,zone) matching_groups_right{host="x"};
|
||||
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| ts | greptime_value | host | zone | __name__ |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 6.0 | x | a | |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
|
||||
-- A matcher can leave a global ranking operand without changing its candidates.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') topk(1, matching_groups_left{host="x"}) / on(host,zone) matching_groups_right;
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: found duplicate series for the match group {zone="a"} on the right hand-side of the operation at 0 ms; many-to-many matching not allowed: matching labels must be unique on one side
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left / on(host,zone) bottomk(1, matching_groups_right{host="x"});
|
||||
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| ts | greptime_value | host | zone | __name__ |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 6.0 | x | a | |
|
||||
+---------------------+----------------+------+------+----------+
|
||||
|
||||
-- The global winner is host y. Pushing host=x below either topk would change the result.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host="x"} / on(host) group_left topk(1, max by(host)(matching_groups_right));
|
||||
|
||||
+----+----------------+------+------+----------+
|
||||
| ts | greptime_value | host | zone | __name__ |
|
||||
+----+----------------+------+------+----------+
|
||||
+----+----------------+------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host="x"} / on(host) group_left topk by(host)(1, topk(1, max by(host)(matching_groups_right)));
|
||||
|
||||
+----+----------------+------+------+----------+
|
||||
| ts | greptime_value | host | zone | __name__ |
|
||||
+----+----------------+------+------+----------+
|
||||
+----+----------------+------+------+----------+
|
||||
|
||||
-- Both one-sides carry two series per `host`, which the matching cannot resolve.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host="x"} / on(host) group_left matching_groups_right;
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: found duplicate series for the match group {host="x"} on the right hand-side of the operation at 0 ms; many-to-many matching not allowed: matching labels must be unique on one side
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '1s') matching_groups_left{host="x"} / on(host) group_left max by(host,zone)(matching_groups_right);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: found duplicate series for the match group {host="x"} on the right hand-side of the operation at 0 ms; many-to-many matching not allowed: matching labels must be unique on one side
|
||||
|
||||
DROP TABLE matching_groups_left;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE matching_groups_right;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/matching_groups.sql
|
||||
@@ -0,0 +1,354 @@
|
||||
CREATE TABLE angles (
|
||||
ts timestamp(3) time index,
|
||||
unit STRING PRIMARY KEY,
|
||||
val DOUBLE,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE angles VALUES
|
||||
(0, 'radians', 0),
|
||||
(0, 'degrees', 0),
|
||||
(5000, 'radians', 1.5708), -- π/2
|
||||
(5000, 'degrees', 90),
|
||||
(10000, 'radians', 3.1416), -- π
|
||||
(10000, 'degrees', 180),
|
||||
(15000, 'radians', 4.7124), -- 3π/2
|
||||
(15000, 'degrees', 270),
|
||||
(20000, 'radians', 6.2832), -- 2π
|
||||
(20000, 'degrees', 360),
|
||||
(25000, 'positive', 42.5),
|
||||
(25000, 'negative', -17.3),
|
||||
(30000, 'zero', 0),
|
||||
(30000, 'small_pos', 0.001),
|
||||
(35000, 'small_neg', -0.001);
|
||||
|
||||
Affected Rows: 15
|
||||
|
||||
-- Test pi() function (returns constant π ≈ 3.141592653589793)
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') pi();
|
||||
|
||||
+---------------------+-------------------+
|
||||
| time | pi() |
|
||||
+---------------------+-------------------+
|
||||
| 1970-01-01T00:00:00 | 3.141592653589793 |
|
||||
| 1970-01-01T00:00:05 | 3.141592653589793 |
|
||||
| 1970-01-01T00:00:10 | 3.141592653589793 |
|
||||
| 1970-01-01T00:00:15 | 3.141592653589793 |
|
||||
| 1970-01-01T00:00:20 | 3.141592653589793 |
|
||||
+---------------------+-------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') pi() + 1;
|
||||
|
||||
+---------------------+-------------------+
|
||||
| time | pi() + Float64(1) |
|
||||
+---------------------+-------------------+
|
||||
| 1970-01-01T00:00:00 | 4.141592653589793 |
|
||||
| 1970-01-01T00:00:05 | 4.141592653589793 |
|
||||
| 1970-01-01T00:00:10 | 4.141592653589793 |
|
||||
| 1970-01-01T00:00:15 | 4.141592653589793 |
|
||||
| 1970-01-01T00:00:20 | 4.141592653589793 |
|
||||
+---------------------+-------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') angles{unit="radians"} * pi();
|
||||
|
||||
+---------+---------------------+--------------------+
|
||||
| unit | ts | angles.val * .pi() |
|
||||
+---------+---------------------+--------------------+
|
||||
| radians | 1970-01-01T00:00:00 | 0.0 |
|
||||
| radians | 1970-01-01T00:00:05 | 4.934813740258847 |
|
||||
| radians | 1970-01-01T00:00:10 | 9.869627480517694 |
|
||||
| radians | 1970-01-01T00:00:15 | 14.80444122077654 |
|
||||
| radians | 1970-01-01T00:00:20 | 19.73925496103539 |
|
||||
+---------+---------------------+--------------------+
|
||||
|
||||
-- Test rad() function (converts degrees to radians)
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') rad(angles{unit="degrees"});
|
||||
|
||||
+---------------------+--------------------+---------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+--------------------+---------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | degrees | |
|
||||
| 1970-01-01T00:00:05 | 1.5707963267948966 | degrees | |
|
||||
| 1970-01-01T00:00:10 | 3.141592653589793 | degrees | |
|
||||
| 1970-01-01T00:00:15 | 4.71238898038469 | degrees | |
|
||||
| 1970-01-01T00:00:20 | 6.283185307179586 | degrees | |
|
||||
+---------------------+--------------------+---------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') rad(angles);
|
||||
|
||||
+---------------------+---------------------+---------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+---------------------+---------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | degrees | |
|
||||
| 1970-01-01T00:00:00 | 0.0 | radians | |
|
||||
| 1970-01-01T00:00:05 | 0.02741563189032693 | radians | |
|
||||
| 1970-01-01T00:00:05 | 1.5707963267948966 | degrees | |
|
||||
| 1970-01-01T00:00:10 | 0.05483126378065386 | radians | |
|
||||
| 1970-01-01T00:00:10 | 3.141592653589793 | degrees | |
|
||||
| 1970-01-01T00:00:15 | 0.08224689567098079 | radians | |
|
||||
| 1970-01-01T00:00:15 | 4.71238898038469 | degrees | |
|
||||
| 1970-01-01T00:00:20 | 0.10966252756130772 | radians | |
|
||||
| 1970-01-01T00:00:20 | 6.283185307179586 | degrees | |
|
||||
+---------------------+---------------------+---------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') scalar(rad(angles{unit="degrees"}));
|
||||
|
||||
+---------------------+--------------------+
|
||||
| ts | value |
|
||||
+---------------------+--------------------+
|
||||
| 1970-01-01T00:00:00 | 0.0 |
|
||||
| 1970-01-01T00:00:05 | 1.5707963267948966 |
|
||||
| 1970-01-01T00:00:10 | 3.141592653589793 |
|
||||
| 1970-01-01T00:00:15 | 4.71238898038469 |
|
||||
| 1970-01-01T00:00:20 | 6.283185307179586 |
|
||||
+---------------------+--------------------+
|
||||
|
||||
-- Test deg() function (converts radians to degrees)
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') deg(angles{unit="radians"});
|
||||
|
||||
+---------------------+-------------------+---------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+-------------------+---------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | radians | |
|
||||
| 1970-01-01T00:00:05 | 90.0002104591497 | radians | |
|
||||
| 1970-01-01T00:00:10 | 180.0004209182994 | radians | |
|
||||
| 1970-01-01T00:00:15 | 270.0006313774491 | radians | |
|
||||
| 1970-01-01T00:00:20 | 360.0008418365988 | radians | |
|
||||
+---------------------+-------------------+---------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') deg(angles);
|
||||
|
||||
+---------------------+--------------------+---------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+--------------------+---------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | degrees | |
|
||||
| 1970-01-01T00:00:00 | 0.0 | radians | |
|
||||
| 1970-01-01T00:00:05 | 5156.620156177409 | degrees | |
|
||||
| 1970-01-01T00:00:05 | 90.0002104591497 | radians | |
|
||||
| 1970-01-01T00:00:10 | 10313.240312354817 | degrees | |
|
||||
| 1970-01-01T00:00:10 | 180.0004209182994 | radians | |
|
||||
| 1970-01-01T00:00:15 | 15469.860468532228 | degrees | |
|
||||
| 1970-01-01T00:00:15 | 270.0006313774491 | radians | |
|
||||
| 1970-01-01T00:00:20 | 20626.480624709635 | degrees | |
|
||||
| 1970-01-01T00:00:20 | 360.0008418365988 | radians | |
|
||||
+---------------------+--------------------+---------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') scalar(deg(angles{unit="radians"}));
|
||||
|
||||
+---------------------+-------------------+
|
||||
| ts | value |
|
||||
+---------------------+-------------------+
|
||||
| 1970-01-01T00:00:00 | 0.0 |
|
||||
| 1970-01-01T00:00:05 | 90.0002104591497 |
|
||||
| 1970-01-01T00:00:10 | 180.0004209182994 |
|
||||
| 1970-01-01T00:00:15 | 270.0006313774491 |
|
||||
| 1970-01-01T00:00:20 | 360.0008418365988 |
|
||||
+---------------------+-------------------+
|
||||
|
||||
-- Test conversions with pi()
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') rad(deg(pi()));
|
||||
|
||||
Error: 2000(InvalidSyntax), expected type vector in call to function 'deg', got scalar
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') deg(rad(pi()));
|
||||
|
||||
Error: 2000(InvalidSyntax), expected type vector in call to function 'rad', got scalar
|
||||
|
||||
-- Test with arithmetic operations
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') deg(angles{unit="radians"}) + rad(angles{unit="degrees"});
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') deg(pi() * 2);
|
||||
|
||||
Error: 2000(InvalidSyntax), expected type vector in call to function 'deg', got scalar
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 20, '5s') rad(180 * angles{unit="radians"});
|
||||
|
||||
+---------------------+--------------------+---------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+--------------------+---------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | radians | |
|
||||
| 1970-01-01T00:00:05 | 4.934813740258846 | radians | |
|
||||
| 1970-01-01T00:00:10 | 9.869627480517693 | radians | |
|
||||
| 1970-01-01T00:00:15 | 14.80444122077654 | radians | |
|
||||
| 1970-01-01T00:00:20 | 19.739254961035385 | radians | |
|
||||
+---------------------+--------------------+---------+----------+
|
||||
|
||||
-- Test sgn() function (returns sign of values: -1, 0, or 1)
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 35, '5s') sgn(angles{unit="positive"});
|
||||
|
||||
+---------------------+-----+----------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+-----+----------+----------+
|
||||
| 1970-01-01T00:00:25 | 1.0 | positive | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | positive | |
|
||||
| 1970-01-01T00:00:35 | 1.0 | positive | |
|
||||
+---------------------+-----+----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 35, '5s') sgn(angles{unit="negative"});
|
||||
|
||||
+---------------------+------+----------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+------+----------+----------+
|
||||
| 1970-01-01T00:00:25 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:30 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | negative | |
|
||||
+---------------------+------+----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 35, '5s') sgn(angles{unit="zero"});
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 0.0 | zero | |
|
||||
| 1970-01-01T00:00:35 | 0.0 | zero | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 35, '5s') sgn(angles{unit="small_pos"});
|
||||
|
||||
+---------------------+-----+-----------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+-----+-----------+----------+
|
||||
| 1970-01-01T00:00:30 | 1.0 | small_pos | |
|
||||
| 1970-01-01T00:00:35 | 1.0 | small_pos | |
|
||||
+---------------------+-----+-----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 35, '5s') sgn(angles{unit="small_neg"});
|
||||
|
||||
+---------------------+------+-----------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+------+-----------+----------+
|
||||
| 1970-01-01T00:00:35 | -1.0 | small_neg | |
|
||||
+---------------------+------+-----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (25, 35, '5s') sgn(angles);
|
||||
|
||||
+---------------------+------+-----------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+------+-----------+----------+
|
||||
| 1970-01-01T00:00:25 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:25 | 1.0 | degrees | |
|
||||
| 1970-01-01T00:00:25 | 1.0 | positive | |
|
||||
| 1970-01-01T00:00:25 | 1.0 | radians | |
|
||||
| 1970-01-01T00:00:30 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:30 | 0.0 | zero | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | degrees | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | positive | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | radians | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | small_pos | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | small_neg | |
|
||||
| 1970-01-01T00:00:35 | 0.0 | zero | |
|
||||
| 1970-01-01T00:00:35 | 1.0 | degrees | |
|
||||
| 1970-01-01T00:00:35 | 1.0 | positive | |
|
||||
| 1970-01-01T00:00:35 | 1.0 | radians | |
|
||||
| 1970-01-01T00:00:35 | 1.0 | small_pos | |
|
||||
+---------------------+------+-----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (25, 35, '5s') scalar(sgn(angles{unit="positive"}));
|
||||
|
||||
+---------------------+-------+
|
||||
| ts | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:25 | 1.0 |
|
||||
| 1970-01-01T00:00:30 | 1.0 |
|
||||
| 1970-01-01T00:00:35 | 1.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
-- FIXME: test sgn with arithmetic operations
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (25, 35, '5s') sgn(angles - 42.5);
|
||||
|
||||
+---------------------+------+-----------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+------+-----------+----------+
|
||||
| 1970-01-01T00:00:25 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:25 | -1.0 | radians | |
|
||||
| 1970-01-01T00:00:25 | 0.0 | positive | |
|
||||
| 1970-01-01T00:00:25 | 1.0 | degrees | |
|
||||
| 1970-01-01T00:00:30 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:30 | -1.0 | radians | |
|
||||
| 1970-01-01T00:00:30 | -1.0 | small_pos | |
|
||||
| 1970-01-01T00:00:30 | -1.0 | zero | |
|
||||
| 1970-01-01T00:00:30 | 0.0 | positive | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | degrees | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | negative | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | radians | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | small_neg | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | small_pos | |
|
||||
| 1970-01-01T00:00:35 | -1.0 | zero | |
|
||||
| 1970-01-01T00:00:35 | 0.0 | positive | |
|
||||
| 1970-01-01T00:00:35 | 1.0 | degrees | |
|
||||
+---------------------+------+-----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 35, '5s') sgn(angles{unit="radians"} - pi());
|
||||
|
||||
+---------------------+----------------------------+---------+
|
||||
| ts | signum(angles.val - .pi()) | unit |
|
||||
+---------------------+----------------------------+---------+
|
||||
| 1970-01-01T00:00:00 | -1.0 | radians |
|
||||
| 1970-01-01T00:00:05 | -1.0 | radians |
|
||||
| 1970-01-01T00:00:10 | 1.0 | radians |
|
||||
| 1970-01-01T00:00:15 | 1.0 | radians |
|
||||
| 1970-01-01T00:00:20 | 1.0 | radians |
|
||||
| 1970-01-01T00:00:25 | 1.0 | radians |
|
||||
| 1970-01-01T00:00:30 | 1.0 | radians |
|
||||
| 1970-01-01T00:00:35 | 1.0 | radians |
|
||||
+---------------------+----------------------------+---------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (25, 35, '5s') sgn(angles) * angles;
|
||||
|
||||
+---------------------+--------+-----------+----------+
|
||||
| ts | val | unit | __name__ |
|
||||
+---------------------+--------+-----------+----------+
|
||||
| 1970-01-01T00:00:25 | 17.3 | negative | |
|
||||
| 1970-01-01T00:00:25 | 360.0 | degrees | |
|
||||
| 1970-01-01T00:00:25 | 42.5 | positive | |
|
||||
| 1970-01-01T00:00:25 | 6.2832 | radians | |
|
||||
| 1970-01-01T00:00:30 | 0.0 | zero | |
|
||||
| 1970-01-01T00:00:30 | 0.001 | small_pos | |
|
||||
| 1970-01-01T00:00:30 | 17.3 | negative | |
|
||||
| 1970-01-01T00:00:30 | 360.0 | degrees | |
|
||||
| 1970-01-01T00:00:30 | 42.5 | positive | |
|
||||
| 1970-01-01T00:00:30 | 6.2832 | radians | |
|
||||
| 1970-01-01T00:00:35 | 0.0 | zero | |
|
||||
| 1970-01-01T00:00:35 | 0.001 | small_neg | |
|
||||
| 1970-01-01T00:00:35 | 0.001 | small_pos | |
|
||||
| 1970-01-01T00:00:35 | 17.3 | negative | |
|
||||
| 1970-01-01T00:00:35 | 360.0 | degrees | |
|
||||
| 1970-01-01T00:00:35 | 42.5 | positive | |
|
||||
| 1970-01-01T00:00:35 | 6.2832 | radians | |
|
||||
+---------------------+--------+-----------+----------+
|
||||
|
||||
Drop table angles;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/math.sql
|
||||
@@ -0,0 +1,262 @@
|
||||
-- NULL fields are missing samples, not zero-valued samples.
|
||||
CREATE TABLE null_samples (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
host STRING PRIMARY KEY,
|
||||
val DOUBLE,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO null_samples VALUES
|
||||
(0, 'a', 1.0),
|
||||
(1000, 'a', NULL),
|
||||
(2000, 'a', NULL),
|
||||
(3000, 'a', 4.0),
|
||||
(0, 'b', NULL),
|
||||
(1000, 'b', NULL),
|
||||
(2000, 'b', NULL),
|
||||
(3000, 'b', NULL);
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
-- At t=2 the trailing NULLs must not hide 1; at t=3 count must be 2.
|
||||
-- At t=7 the left-open window is empty. Valid results must disappear.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (2, 7, '1s') count_over_time(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:02 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:03 | 2.0 | a | |
|
||||
| 1970-01-01T00:00:04 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:06 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (2, 7, '1s') last_over_time(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+--------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+--------------+
|
||||
| 1970-01-01T00:00:02 | 1.0 | a | null_samples |
|
||||
| 1970-01-01T00:00:03 | 4.0 | a | null_samples |
|
||||
| 1970-01-01T00:00:04 | 4.0 | a | null_samples |
|
||||
| 1970-01-01T00:00:05 | 4.0 | a | null_samples |
|
||||
| 1970-01-01T00:00:06 | 4.0 | a | null_samples |
|
||||
+---------------------+-----+------+--------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (2, 7, '1s') present_over_time(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:02 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:03 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:04 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:05 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:06 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (2, 7, '1s') absent_over_time(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:07 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- All-NULL windows have no samples: only absent_over_time returns 1.
|
||||
TQL EVAL (3, 3, '1s') count_over_time(null_samples{host="b"}[4s]);
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') last_over_time(null_samples{host="b"}[4s]);
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') present_over_time(null_samples{host="b"}[4s]);
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') absent_over_time(null_samples{host="b"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 1.0 | b | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Every function below sees the same two samples, 1.0 at 0s and 4.0 at 3s.
|
||||
TQL EVAL (3, 3, '1s') rate(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') increase(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 4.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') delta(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 4.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') idelta(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 3.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') irate(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') changes(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') resets(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 0.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') avg_over_time(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 2.5 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') stddev_over_time(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 1.5 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') stdvar_over_time(null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:00:03 | 2.25 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
TQL EVAL (3, 3, '1s') quantile_over_time(0.5, null_samples{host="a"}[4s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 2.5 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- A window whose only slot is NULL holds no sample, like a window with no row.
|
||||
TQL EVAL (1, 1, '1s') rate(null_samples{host="a"}[1s]);
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
-- Prometheus returns an empty vector for a range without samples, not NaN.
|
||||
TQL EVAL (1, 1, '1s') quantile_over_time(0.5, null_samples{host="a"}[1s]);
|
||||
|
||||
+----+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+----+-----+------+----------+
|
||||
+----+-----+------+----------+
|
||||
|
||||
-- `b` never has a sample, so it must not reach the aggregation.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '1s') avg by (host) (rate(null_samples[4s]));
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:03 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
DROP TABLE null_samples;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE multi_field (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
host STRING PRIMARY KEY,
|
||||
f1 DOUBLE,
|
||||
f2 DOUBLE
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO multi_field VALUES
|
||||
(0, 'a', 1.0, 10.0),
|
||||
(1000, 'a', 2.0, NULL),
|
||||
(2000, 'a', 3.0, NULL),
|
||||
(3000, 'a', 4.0, 40.0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
-- f1 has two samples in this window and f2 only one, so f1 keeps its result while f2 is NULL.
|
||||
-- Dropping the whole row would take f1's samples with it.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1, 1, '1s') rate(multi_field[4s]);
|
||||
|
||||
+---------------------+-------+----+------+----------+
|
||||
| ts | f1 | f2 | host | __name__ |
|
||||
+---------------------+-------+----+------+----------+
|
||||
| 1970-01-01T00:00:01 | 0.375 | | a | |
|
||||
+---------------------+-------+----+------+----------+
|
||||
|
||||
-- A selector emits the same shape: the row stays, the field without a sample is NULL.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (1, 1, '1s') multi_field;
|
||||
|
||||
+---------------------+-----+----+------+-------------+
|
||||
| ts | f1 | f2 | host | __name__ |
|
||||
+---------------------+-----+----+------+-------------+
|
||||
| 1970-01-01T00:00:01 | 2.0 | | a | multi_field |
|
||||
+---------------------+-----+----+------+-------------+
|
||||
|
||||
DROP TABLE multi_field;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/null_samples.sql
|
||||
@@ -0,0 +1,123 @@
|
||||
-- Referenced from https://github.com/prometheus/prometheus/blob/a48d348811619ba4e8eae9c3eaae4857749a1578/promql/promqltest/testdata/functions.test#L172-L185
|
||||
create table calculate_rate_offset_total (
|
||||
ts timestamp time index,
|
||||
val double,
|
||||
x string primary key
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into calculate_rate_offset_total values
|
||||
(0, 0.0, 'a'),
|
||||
(300000, 10.0, 'a'),
|
||||
(600000, 20.0, 'a'),
|
||||
(900000, 30.0, 'a'),
|
||||
(1200000, 40.0, 'a'),
|
||||
(1500000, 50.0, 'a'),
|
||||
(1800000, 60.0, 'a'),
|
||||
(2100000, 70.0, 'a'),
|
||||
(2400000, 80.0, 'a'),
|
||||
(2700000, 90.0, 'a'),
|
||||
(3000000, 100.0, 'a'),
|
||||
(0, 0.0, 'b'),
|
||||
(300000, 20.0, 'b'),
|
||||
(600000, 40.0, 'b'),
|
||||
(900000, 60.0, 'b'),
|
||||
(1200000, 80.0, 'b'),
|
||||
(1500000, 100.0, 'b'),
|
||||
(1800000, 120.0, 'b'),
|
||||
(2100000, 140.0, 'b'),
|
||||
(2400000, 160.0, 'b'),
|
||||
(2700000, 180.0, 'b'),
|
||||
(3000000, 200.0, 'b');
|
||||
|
||||
Affected Rows: 22
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1500, 1500, '1s') calculate_rate_offset_total;
|
||||
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
| ts | val | x | __name__ |
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
| 1970-01-01T00:25:00 | 100.0 | b | calculate_rate_offset_total |
|
||||
| 1970-01-01T00:25:00 | 50.0 | a | calculate_rate_offset_total |
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1500, 1500, '1s') calculate_rate_offset_total offset 10m;
|
||||
|
||||
+---------------------+------+---+-----------------------------+
|
||||
| ts | val | x | __name__ |
|
||||
+---------------------+------+---+-----------------------------+
|
||||
| 1970-01-01T00:25:00 | 30.0 | a | calculate_rate_offset_total |
|
||||
| 1970-01-01T00:25:00 | 60.0 | b | calculate_rate_offset_total |
|
||||
+---------------------+------+---+-----------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1500, 1500, '1s') calculate_rate_offset_total offset -10m;
|
||||
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
| ts | val | x | __name__ |
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
| 1970-01-01T00:25:00 | 140.0 | b | calculate_rate_offset_total |
|
||||
| 1970-01-01T00:25:00 | 70.0 | a | calculate_rate_offset_total |
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') calculate_rate_offset_total offset 10m;
|
||||
|
||||
+----+-----+---+----------+
|
||||
| ts | val | x | __name__ |
|
||||
+----+-----+---+----------+
|
||||
+----+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 0, '1s') calculate_rate_offset_total offset -10m;
|
||||
|
||||
+---------------------+------+---+-----------------------------+
|
||||
| ts | val | x | __name__ |
|
||||
+---------------------+------+---+-----------------------------+
|
||||
| 1970-01-01T00:00:00 | 20.0 | a | calculate_rate_offset_total |
|
||||
| 1970-01-01T00:00:00 | 40.0 | b | calculate_rate_offset_total |
|
||||
+---------------------+------+---+-----------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') calculate_rate_offset_total offset 10m;
|
||||
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
| ts | val | x | __name__ |
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
| 1970-01-01T00:50:00 | 160.0 | b | calculate_rate_offset_total |
|
||||
| 1970-01-01T00:50:00 | 80.0 | a | calculate_rate_offset_total |
|
||||
+---------------------+-------+---+-----------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') calculate_rate_offset_total offset -10m;
|
||||
|
||||
+----+-----+---+----------+
|
||||
| ts | val | x | __name__ |
|
||||
+----+-----+---+----------+
|
||||
+----+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') rate(calculate_rate_window_total[10m]);
|
||||
|
||||
+------+------------------------------------------------+
|
||||
| time | prom_rate(time_range,value,time,Int64(600000)) |
|
||||
+------+------------------------------------------------+
|
||||
+------+------------------------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') rate(calculate_rate_offset_total[10m] offset 5m);
|
||||
|
||||
+---------------------+---------------------+---+----------+
|
||||
| ts | val | x | __name__ |
|
||||
+---------------------+---------------------+---+----------+
|
||||
| 1970-01-01T00:50:00 | 0.03333333333333333 | a | |
|
||||
| 1970-01-01T00:50:00 | 0.06666666666666667 | b | |
|
||||
+---------------------+---------------------+---+----------+
|
||||
|
||||
drop table calculate_rate_offset_total;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/offset.sql
|
||||
@@ -0,0 +1,66 @@
|
||||
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;
|
||||
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
| ts | greptime_value | job | instance | env | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
| 1970-01-01T00:50:00 | 205.0 | api | 0 | production | |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
|
||||
tql eval (3000, 3000, '1s') http_requests{job="web",instance="1",env="production"} * 5;
|
||||
|
||||
+----+----------------+-----+----------+-----+----------+
|
||||
| ts | greptime_value | job | instance | env | __name__ |
|
||||
+----+----------------+-----+----------+-----+----------+
|
||||
+----+----------------+-----+----------+-----+----------+
|
||||
|
||||
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 | greptime_value | job | instance | env | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
| 1970-01-01T00:50:00 | 205.0 | api | 0 | production | |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
|
||||
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 | greptime_value | job | instance | env | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
| 1970-01-01T00:50:00 | 205.0 | api | 0 | production | |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
|
||||
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 | greptime_value | job | instance | env | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
| 1970-01-01T00:50:00 | 205.0 | api | 0 | production | |
|
||||
+---------------------+----------------+-----+----------+------------+----------+
|
||||
|
||||
drop table http_requests;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/or_operation.sql
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
-- Test: Sparse samples with intermediate empty windows and a valid trailing sample.
|
||||
--
|
||||
-- Two samples at t=0ms and t=100000ms (100s). A range vector with 25s window
|
||||
-- should produce results at t=0s (the first sample) and t=120s (the trailing
|
||||
-- sample), with the three intermediate steps returning no data (empty).
|
||||
CREATE TABLE range_sparse_empty_trailing (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
val DOUBLE,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO range_sparse_empty_trailing (ts, val) VALUES
|
||||
(0, 1.0),
|
||||
(100000, 1.0);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 120, '30s') count_over_time(range_sparse_empty_trailing[25s]);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | |
|
||||
| 1970-01-01T00:02:00 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
DROP TABLE range_sparse_empty_trailing;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/range_sparse_empty_trailing.sql
|
||||
@@ -0,0 +1,143 @@
|
||||
-- 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
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
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');
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (30, 30, '1s') range_vector_result[20s];
|
||||
|
||||
+---------------------+------+------+
|
||||
| ts | val | host |
|
||||
+---------------------+------+------+
|
||||
| 1970-01-01T00:00:20 | 3.0 | a |
|
||||
| 1970-01-01T00:00:20 | 30.0 | b |
|
||||
| 1970-01-01T00:00:30 | 4.0 | a |
|
||||
+---------------------+------+------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (30, 30, '1s') range_vector_result[20s] offset 10s;
|
||||
|
||||
+---------------------+------+------+
|
||||
| ts | val | host |
|
||||
+---------------------+------+------+
|
||||
| 1970-01-01T00:00:10 | 2.0 | a |
|
||||
| 1970-01-01T00:00:20 | 3.0 | a |
|
||||
| 1970-01-01T00:00:20 | 30.0 | b |
|
||||
+---------------------+------+------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (30, 30, '1s') range_vector_result[15s] @ 20;
|
||||
|
||||
+---------------------+------+------+
|
||||
| ts | val | host |
|
||||
+---------------------+------+------+
|
||||
| 1970-01-01T00:00:10 | 2.0 | a |
|
||||
| 1970-01-01T00:00:20 | 3.0 | a |
|
||||
| 1970-01-01T00:00:20 | 30.0 | b |
|
||||
+---------------------+------+------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (30, 30, '1s') range_vector_result[30s:10s];
|
||||
|
||||
+---------------------+------+------+---------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+---------------------+
|
||||
| 1970-01-01T00:00:10 | 10.0 | b | range_vector_result |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | range_vector_result |
|
||||
| 1970-01-01T00:00:20 | 3.0 | a | range_vector_result |
|
||||
| 1970-01-01T00:00:20 | 30.0 | b | range_vector_result |
|
||||
| 1970-01-01T00:00:30 | 30.0 | b | range_vector_result |
|
||||
| 1970-01-01T00:00:30 | 4.0 | a | range_vector_result |
|
||||
+---------------------+------+------+---------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (30, 30, '1s') range_vector_result[35s:10s] offset 5s;
|
||||
|
||||
+---------------------+------+------+---------------------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+---------------------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | range_vector_result |
|
||||
| 1970-01-01T00:00:00 | 10.0 | b | range_vector_result |
|
||||
| 1970-01-01T00:00:10 | 10.0 | b | range_vector_result |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | range_vector_result |
|
||||
| 1970-01-01T00:00:20 | 3.0 | a | range_vector_result |
|
||||
| 1970-01-01T00:00:20 | 30.0 | b | range_vector_result |
|
||||
+---------------------+------+------+---------------------+
|
||||
|
||||
tql eval (35, 35, '1s') range_vector_result[4s:10s];
|
||||
|
||||
+----+-----+------+
|
||||
| ts | val | host |
|
||||
+----+-----+------+
|
||||
+----+-----+------+
|
||||
|
||||
tql eval (0, 30, '10s') range_vector_result[20s];
|
||||
|
||||
Error: 1004(InvalidArguments), invalid expression type "range vector" for range query, must be Scalar or instant Vector
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (30, 30, '1s') range_vector_result[20s] as v;
|
||||
|
||||
+------+------+---------------------+
|
||||
| v | host | ts |
|
||||
+------+------+---------------------+
|
||||
| 3.0 | a | 1970-01-01T00:00:20 |
|
||||
| 30.0 | b | 1970-01-01T00:00:20 |
|
||||
| 4.0 | a | 1970-01-01T00:00:30 |
|
||||
+------+------+---------------------+
|
||||
|
||||
-- SQLNESS REPLACE (peers.*) REDACTED
|
||||
-- SQLNESS REPLACE (partitioning.*) REDACTED
|
||||
tql explain (30, 30, '1s') range_vector_result[20s];
|
||||
|
||||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| plan_type | plan |
|
||||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| logical_plan | MergeScan [is_placeholder=false, remote_input=[ |
|
||||
| | PromSeriesNormalize: offset=[0], time index=[ts], filter NaN: [true] |
|
||||
| | PromSeriesDivide: tags=["host"] |
|
||||
| | Sort: range_vector_result.host ASC NULLS FIRST, range_vector_result.ts ASC NULLS FIRST |
|
||||
| | Filter: range_vector_result.ts >= TimestampMillisecond(10001, None) AND range_vector_result.ts <= TimestampMillisecond(30000, None) |
|
||||
| | TableScan: range_vector_result, partial_filters=[range_vector_result.ts >= TimestampMillisecond(10001, None), range_vector_result.ts <= TimestampMillisecond(30000, None)] |
|
||||
| | ]] |
|
||||
| physical_plan | CooperativeExec |
|
||||
| | MergeScanExec: REDACTED
|
||||
| | |
|
||||
+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
|
||||
tql eval (30, 30, '1s') range_vector_result[30s:0.0001];
|
||||
|
||||
Error: 3000(PlanQuery), Internal error during building DataFusion plan: Error during planning: the subquery's step is 0ms, and a step has to be longer than zero
|
||||
|
||||
-- A subquery without a step uses the one-minute default, not the query step.
|
||||
tql eval (300, 300, '1s') vector(1)[5m:];
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | |
|
||||
| 1970-01-01T00:02:00 | 1.0 | |
|
||||
| 1970-01-01T00:03:00 | 1.0 | |
|
||||
| 1970-01-01T00:04:00 | 1.0 | |
|
||||
| 1970-01-01T00:05:00 | 1.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
drop table range_vector_result;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/range_vector_result.sql
|
||||
@@ -0,0 +1,651 @@
|
||||
CREATE TABLE host (
|
||||
ts timestamp(3) time index,
|
||||
host STRING PRIMARY KEY,
|
||||
val BIGINT,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE host VALUES
|
||||
(0, 'host1', 1),
|
||||
(0, 'host2', 2),
|
||||
(5000, 'host1', 3),
|
||||
(5000, 'host2', 4),
|
||||
(10000, 'host1', 5),
|
||||
(10000, 'host2', 6),
|
||||
(15000, 'host1', 7),
|
||||
(15000, 'host2', 8);
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
-- case only have one time series, scalar return value
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host{host="host1"});
|
||||
|
||||
+---------------------+-------------+
|
||||
| ts | scalar(val) |
|
||||
+---------------------+-------------+
|
||||
| 1970-01-01T00:00:00 | 1.0 |
|
||||
| 1970-01-01T00:00:05 | 3.0 |
|
||||
| 1970-01-01T00:00:10 | 5.0 |
|
||||
| 1970-01-01T00:00:15 | 7.0 |
|
||||
+---------------------+-------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host{host="host1"}) + 1;
|
||||
|
||||
+---------------------+--------------------------+
|
||||
| ts | scalar(val) + Float64(1) |
|
||||
+---------------------+--------------------------+
|
||||
| 1970-01-01T00:00:00 | 2.0 |
|
||||
| 1970-01-01T00:00:05 | 4.0 |
|
||||
| 1970-01-01T00:00:10 | 6.0 |
|
||||
| 1970-01-01T00:00:15 | 8.0 |
|
||||
+---------------------+--------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') 1 + scalar(host{host="host1"});
|
||||
|
||||
+---------------------+--------------------------+
|
||||
| ts | Float64(1) + scalar(val) |
|
||||
+---------------------+--------------------------+
|
||||
| 1970-01-01T00:00:00 | 2.0 |
|
||||
| 1970-01-01T00:00:05 | 4.0 |
|
||||
| 1970-01-01T00:00:10 | 6.0 |
|
||||
| 1970-01-01T00:00:15 | 8.0 |
|
||||
+---------------------+--------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host{host="host1"}) + scalar(host{host="host2"});
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | lhs.scalar(val) + rhs.scalar(val) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:00 | 3.0 |
|
||||
| 1970-01-01T00:00:05 | 7.0 |
|
||||
| 1970-01-01T00:00:10 | 11.0 |
|
||||
| 1970-01-01T00:00:15 | 15.0 |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') host{host="host1"} + scalar(host{host="host2"});
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.val + rhs.scalar(val) |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host1 | 1970-01-01T00:00:00 | 3.0 |
|
||||
| host1 | 1970-01-01T00:00:05 | 7.0 |
|
||||
| host1 | 1970-01-01T00:00:10 | 11.0 |
|
||||
| host1 | 1970-01-01T00:00:15 | 15.0 |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host{host="host1"}) + host{host="host2"};
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.scalar(val) + rhs.val |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host2 | 1970-01-01T00:00:00 | 3.0 |
|
||||
| host2 | 1970-01-01T00:00:05 | 7.0 |
|
||||
| host2 | 1970-01-01T00:00:10 | 11.0 |
|
||||
| host2 | 1970-01-01T00:00:15 | 15.0 |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') host + scalar(host{host="host2"});
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.val + rhs.scalar(val) |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host1 | 1970-01-01T00:00:00 | 3.0 |
|
||||
| host1 | 1970-01-01T00:00:05 | 7.0 |
|
||||
| host1 | 1970-01-01T00:00:10 | 11.0 |
|
||||
| host1 | 1970-01-01T00:00:15 | 15.0 |
|
||||
| host2 | 1970-01-01T00:00:00 | 4.0 |
|
||||
| host2 | 1970-01-01T00:00:05 | 8.0 |
|
||||
| host2 | 1970-01-01T00:00:10 | 12.0 |
|
||||
| host2 | 1970-01-01T00:00:15 | 16.0 |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
|
||||
TQL EVAL (0, 15, '5s') scalar(host{host="host1"}) + host;
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.scalar(val) + rhs.val |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host1 | 1970-01-01T00:00:00 | 2.0 |
|
||||
| host1 | 1970-01-01T00:00:05 | 6.0 |
|
||||
| host1 | 1970-01-01T00:00:10 | 10.0 |
|
||||
| host1 | 1970-01-01T00:00:15 | 14.0 |
|
||||
| host2 | 1970-01-01T00:00:00 | 3.0 |
|
||||
| host2 | 1970-01-01T00:00:05 | 7.0 |
|
||||
| host2 | 1970-01-01T00:00:10 | 11.0 |
|
||||
| host2 | 1970-01-01T00:00:15 | 15.0 |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(count(count(host) by (host)));
|
||||
|
||||
+---------------------+--------------------------------+
|
||||
| ts | scalar(count(count(host.val))) |
|
||||
+---------------------+--------------------------------+
|
||||
| 1970-01-01T00:00:00 | 2.0 |
|
||||
| 1970-01-01T00:00:05 | 2.0 |
|
||||
| 1970-01-01T00:00:10 | 2.0 |
|
||||
| 1970-01-01T00:00:15 | 2.0 |
|
||||
+---------------------+--------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(count(sum(host) by (host)));
|
||||
|
||||
+---------------------+------------------------------+
|
||||
| ts | scalar(count(sum(host.val))) |
|
||||
+---------------------+------------------------------+
|
||||
| 1970-01-01T00:00:00 | 2.0 |
|
||||
| 1970-01-01T00:00:05 | 2.0 |
|
||||
| 1970-01-01T00:00:10 | 2.0 |
|
||||
| 1970-01-01T00:00:15 | 2.0 |
|
||||
+---------------------+------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(count(avg(host) by (host)));
|
||||
|
||||
+---------------------+------------------------------+
|
||||
| ts | scalar(count(avg(host.val))) |
|
||||
+---------------------+------------------------------+
|
||||
| 1970-01-01T00:00:00 | 2.0 |
|
||||
| 1970-01-01T00:00:05 | 2.0 |
|
||||
| 1970-01-01T00:00:10 | 2.0 |
|
||||
| 1970-01-01T00:00:15 | 2.0 |
|
||||
+---------------------+------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(count(stddev(host) by (host)));
|
||||
|
||||
+---------------------+-------------------------------------+
|
||||
| ts | scalar(count(stddev_pop(host.val))) |
|
||||
+---------------------+-------------------------------------+
|
||||
| 1970-01-01T00:00:00 | 2.0 |
|
||||
| 1970-01-01T00:00:05 | 2.0 |
|
||||
| 1970-01-01T00:00:10 | 2.0 |
|
||||
| 1970-01-01T00:00:15 | 2.0 |
|
||||
+---------------------+-------------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host{host="host1"} + scalar(host{host="host2"}));
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | scalar(lhs.val + rhs.scalar(val)) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:00 | 3.0 |
|
||||
| 1970-01-01T00:00:05 | 7.0 |
|
||||
| 1970-01-01T00:00:10 | 11.0 |
|
||||
| 1970-01-01T00:00:15 | 15.0 |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(scalar(host{host="host2"}) + host{host="host1"});
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | scalar(lhs.scalar(val) + rhs.val) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:00 | 3.0 |
|
||||
| 1970-01-01T00:00:05 | 7.0 |
|
||||
| 1970-01-01T00:00:10 | 11.0 |
|
||||
| 1970-01-01T00:00:15 | 15.0 |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host + scalar(host{host="host2"}));
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | scalar(lhs.val + rhs.scalar(val)) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:00:05 | NaN |
|
||||
| 1970-01-01T00:00:10 | NaN |
|
||||
| 1970-01-01T00:00:15 | NaN |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(scalar(host{host="host2"}) + host);
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | scalar(lhs.scalar(val) + rhs.val) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:00:05 | NaN |
|
||||
| 1970-01-01T00:00:10 | NaN |
|
||||
| 1970-01-01T00:00:15 | NaN |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- case have multiple time series, scalar return NaN
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host);
|
||||
|
||||
+---------------------+-------------+
|
||||
| ts | scalar(val) |
|
||||
+---------------------+-------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:00:05 | NaN |
|
||||
| 1970-01-01T00:00:10 | NaN |
|
||||
| 1970-01-01T00:00:15 | NaN |
|
||||
+---------------------+-------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host) + 1;
|
||||
|
||||
+---------------------+--------------------------+
|
||||
| ts | scalar(val) + Float64(1) |
|
||||
+---------------------+--------------------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:00:05 | NaN |
|
||||
| 1970-01-01T00:00:10 | NaN |
|
||||
| 1970-01-01T00:00:15 | NaN |
|
||||
+---------------------+--------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') 1 + scalar(host);
|
||||
|
||||
+---------------------+--------------------------+
|
||||
| ts | Float64(1) + scalar(val) |
|
||||
+---------------------+--------------------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:00:05 | NaN |
|
||||
| 1970-01-01T00:00:10 | NaN |
|
||||
| 1970-01-01T00:00:15 | NaN |
|
||||
+---------------------+--------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host) + scalar(host);
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | lhs.scalar(val) + rhs.scalar(val) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:00:05 | NaN |
|
||||
| 1970-01-01T00:00:10 | NaN |
|
||||
| 1970-01-01T00:00:15 | NaN |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') host + scalar(host);
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.val + rhs.scalar(val) |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host1 | 1970-01-01T00:00:00 | NaN |
|
||||
| host1 | 1970-01-01T00:00:05 | NaN |
|
||||
| host1 | 1970-01-01T00:00:10 | NaN |
|
||||
| host1 | 1970-01-01T00:00:15 | NaN |
|
||||
| host2 | 1970-01-01T00:00:00 | NaN |
|
||||
| host2 | 1970-01-01T00:00:05 | NaN |
|
||||
| host2 | 1970-01-01T00:00:10 | NaN |
|
||||
| host2 | 1970-01-01T00:00:15 | NaN |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host) + host;
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.scalar(val) + rhs.val |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host1 | 1970-01-01T00:00:00 | NaN |
|
||||
| host1 | 1970-01-01T00:00:05 | NaN |
|
||||
| host1 | 1970-01-01T00:00:10 | NaN |
|
||||
| host1 | 1970-01-01T00:00:15 | NaN |
|
||||
| host2 | 1970-01-01T00:00:00 | NaN |
|
||||
| host2 | 1970-01-01T00:00:05 | NaN |
|
||||
| host2 | 1970-01-01T00:00:10 | NaN |
|
||||
| host2 | 1970-01-01T00:00:15 | NaN |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') host{host="host2"} + scalar(host);
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.val + rhs.scalar(val) |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host2 | 1970-01-01T00:00:00 | NaN |
|
||||
| host2 | 1970-01-01T00:00:05 | NaN |
|
||||
| host2 | 1970-01-01T00:00:10 | NaN |
|
||||
| host2 | 1970-01-01T00:00:15 | NaN |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host) + host{host="host2"};
|
||||
|
||||
+-------+---------------------+---------------------------+
|
||||
| host | ts | lhs.scalar(val) + rhs.val |
|
||||
+-------+---------------------+---------------------------+
|
||||
| host2 | 1970-01-01T00:00:00 | NaN |
|
||||
| host2 | 1970-01-01T00:00:05 | NaN |
|
||||
| host2 | 1970-01-01T00:00:10 | NaN |
|
||||
| host2 | 1970-01-01T00:00:15 | NaN |
|
||||
+-------+---------------------+---------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(host{host="host1"} + scalar(host));
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | scalar(lhs.val + rhs.scalar(val)) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:00:05 | NaN |
|
||||
| 1970-01-01T00:00:10 | NaN |
|
||||
| 1970-01-01T00:00:15 | NaN |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- No data input in scalar
|
||||
TQL EVAL (350, 360, '5s') scalar(host{host="host1"});
|
||||
|
||||
+---------------------+-------------+
|
||||
| ts | scalar(val) |
|
||||
+---------------------+-------------+
|
||||
| 1970-01-01T00:05:50 | NaN |
|
||||
| 1970-01-01T00:05:55 | NaN |
|
||||
| 1970-01-01T00:06:00 | NaN |
|
||||
+---------------------+-------------+
|
||||
|
||||
DELETE from host where ts = 0;
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
-- Under this case, InstantManipulate will input a valid record batch but output a empty record batch (because no data will be selected in this batch)
|
||||
-- Test input a empty record batch to ScalarCalculate plan
|
||||
TQL EVAL (0, 1600, '6m40s') scalar(host{host="host1"});
|
||||
|
||||
+---------------------+-------------+
|
||||
| ts | scalar(val) |
|
||||
+---------------------+-------------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:06:40 | NaN |
|
||||
| 1970-01-01T00:13:20 | NaN |
|
||||
| 1970-01-01T00:20:00 | NaN |
|
||||
| 1970-01-01T00:26:40 | NaN |
|
||||
+---------------------+-------------+
|
||||
|
||||
-- error case
|
||||
TQL EVAL (0, 15, '5s') scalar(1 + scalar(host{host="host2"}));
|
||||
|
||||
Error: 2000(InvalidSyntax), expected type vector in call to function 'scalar', got scalar
|
||||
|
||||
TQL EVAL (0, 15, '5s') scalar(scalar(host{host="host2"}) + 1);
|
||||
|
||||
Error: 2000(InvalidSyntax), expected type vector in call to function 'scalar', got scalar
|
||||
|
||||
TQL EVAL (0, 15, '5s') scalar(scalar(host{host="host1"}) + scalar(host{host="host2"}));
|
||||
|
||||
Error: 2000(InvalidSyntax), expected type vector in call to function 'scalar', got scalar
|
||||
|
||||
-- Test clamp functions with vector input and scalar bounds
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp(host, 0, 12);
|
||||
|
||||
+---------------------+-----------------------------------+-------+
|
||||
| ts | clamp(val,Float64(0),Float64(12)) | host |
|
||||
+---------------------+-----------------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:05 | 4.0 | host2 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 6.0 | host2 |
|
||||
| 1970-01-01T00:00:15 | 7.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 8.0 | host2 |
|
||||
+---------------------+-----------------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp(host, 6 - 6, 6 + 6);
|
||||
|
||||
+---------------------+------------------------------------------------------------+-------+
|
||||
| ts | clamp(val,Float64(6) - Float64(6),Float64(6) + Float64(6)) | host |
|
||||
+---------------------+------------------------------------------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:05 | 4.0 | host2 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 6.0 | host2 |
|
||||
| 1970-01-01T00:00:15 | 7.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 8.0 | host2 |
|
||||
+---------------------+------------------------------------------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp(host, 12, 0);
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: min '12' > max '0'
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp(host{host="host1"}, -1, 6);
|
||||
|
||||
+---------------------+-----------------------------------+-------+
|
||||
| ts | clamp(val,Float64(-1),Float64(6)) | host |
|
||||
+---------------------+-----------------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 6.0 | host1 |
|
||||
+---------------------+-----------------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp_min(host{host="host1"}, 10);
|
||||
|
||||
+---------------------+----------------------------+-------+
|
||||
| ts | clamp_min(val,Float64(10)) | host |
|
||||
+---------------------+----------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 10.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 10.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 10.0 | host1 |
|
||||
+---------------------+----------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp_min(host{host="host1"}, 1);
|
||||
|
||||
+---------------------+---------------------------+-------+
|
||||
| ts | clamp_min(val,Float64(1)) | host |
|
||||
+---------------------+---------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 7.0 | host1 |
|
||||
+---------------------+---------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp_max(host{host="host1"}, 1);
|
||||
|
||||
+---------------------+---------------------------+-------+
|
||||
| ts | clamp_max(val,Float64(1)) | host |
|
||||
+---------------------+---------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 1.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 1.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 1.0 | host1 |
|
||||
+---------------------+---------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp_max(host{host="host1"}, 10);
|
||||
|
||||
+---------------------+----------------------------+-------+
|
||||
| ts | clamp_max(val,Float64(10)) | host |
|
||||
+---------------------+----------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 7.0 | host1 |
|
||||
+---------------------+----------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp_min(host, 1);
|
||||
|
||||
+---------------------+---------------------------+-------+
|
||||
| ts | clamp_min(val,Float64(1)) | host |
|
||||
+---------------------+---------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:05 | 4.0 | host2 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 6.0 | host2 |
|
||||
| 1970-01-01T00:00:15 | 7.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 8.0 | host2 |
|
||||
+---------------------+---------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp_max(host, 10);
|
||||
|
||||
+---------------------+----------------------------+-------+
|
||||
| ts | clamp_max(val,Float64(10)) | host |
|
||||
+---------------------+----------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:05 | 4.0 | host2 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 6.0 | host2 |
|
||||
| 1970-01-01T00:00:15 | 7.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 8.0 | host2 |
|
||||
+---------------------+----------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(clamp(host{host="host1"}, 0, 6));
|
||||
|
||||
+---------------------+------------------------------------------+
|
||||
| ts | scalar(clamp(val,Float64(0),Float64(6))) |
|
||||
+---------------------+------------------------------------------+
|
||||
| 1970-01-01T00:00:05 | 3.0 |
|
||||
| 1970-01-01T00:00:10 | 5.0 |
|
||||
| 1970-01-01T00:00:15 | 6.0 |
|
||||
+---------------------+------------------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(clamp_min(host{host="host1"}, 1));
|
||||
|
||||
+---------------------+-----------------------------------+
|
||||
| ts | scalar(clamp_min(val,Float64(1))) |
|
||||
+---------------------+-----------------------------------+
|
||||
| 1970-01-01T00:00:05 | 3.0 |
|
||||
| 1970-01-01T00:00:10 | 5.0 |
|
||||
| 1970-01-01T00:00:15 | 7.0 |
|
||||
+---------------------+-----------------------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') scalar(clamp_max(host{host="host1"}, 10));
|
||||
|
||||
+---------------------+------------------------------------+
|
||||
| ts | scalar(clamp_max(val,Float64(10))) |
|
||||
+---------------------+------------------------------------+
|
||||
| 1970-01-01T00:00:05 | 3.0 |
|
||||
| 1970-01-01T00:00:10 | 5.0 |
|
||||
| 1970-01-01T00:00:15 | 7.0 |
|
||||
+---------------------+------------------------------------+
|
||||
|
||||
-- Test nested clamp functions
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp(clamp_min(host{host="host1"}, 1), 0, 12);
|
||||
|
||||
+---------------------+---------------------------------------------------------+-------+
|
||||
| ts | clamp(clamp_min(val,Float64(1)),Float64(0),Float64(12)) | host |
|
||||
+---------------------+---------------------------------------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 7.0 | host1 |
|
||||
+---------------------+---------------------------------------------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 15, '5s') clamp_max(clamp(host{host="host1"}, 0, 15), 6);
|
||||
|
||||
+---------------------+---------------------------------------------------------+-------+
|
||||
| ts | clamp_max(clamp(val,Float64(0),Float64(15)),Float64(6)) | host |
|
||||
+---------------------+---------------------------------------------------------+-------+
|
||||
| 1970-01-01T00:00:05 | 3.0 | host1 |
|
||||
| 1970-01-01T00:00:10 | 5.0 | host1 |
|
||||
| 1970-01-01T00:00:15 | 6.0 | host1 |
|
||||
+---------------------+---------------------------------------------------------+-------+
|
||||
|
||||
DROP TABLE host;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE presence_metric (
|
||||
ts timestamp(3) time index,
|
||||
instance STRING,
|
||||
cpu STRING,
|
||||
shard STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY (instance, cpu, shard),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO TABLE presence_metric VALUES
|
||||
(0, 'i1', 'cpu0', 'a', 1.0),
|
||||
(0, 'i1', 'cpu0', 'b', 2.0),
|
||||
(0, 'i1', 'cpu1', 'a', 10.0),
|
||||
(0, 'i1', 'cpu2', 'a', 20.0),
|
||||
(0, 'i2', 'cpu9', 'a', 100.0),
|
||||
(200000, 'i1', 'cpu0', 'a', 'NAN'::DOUBLE),
|
||||
(200000, 'i1', 'cpu0', 'b', 'NAN'::DOUBLE),
|
||||
(200000, 'i1', 'cpu1', 'a', 11.0),
|
||||
(200000, 'i1', 'cpu2', 'a', NULL),
|
||||
(200000, 'i2', 'cpu9', 'a', 101.0),
|
||||
(400000, 'i1', 'cpu1', 'a', 12.0),
|
||||
(400000, 'i2', 'cpu9', 'a', 102.0),
|
||||
(600000, 'i1', 'cpu0', 'a', 7.0),
|
||||
(600000, 'i1', 'cpu0', 'b', 8.0),
|
||||
(600000, 'i2', 'cpu9', 'a', 103.0);
|
||||
|
||||
Affected Rows: 15
|
||||
|
||||
-- Ordinary NaN keeps `cpu0` present in the grouped count, while the NULL sample
|
||||
-- on `cpu2` still leaves a zero-valued row in `count(...) by (cpu)`.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 600, '200s') count(presence_metric{instance="i1"}) by (cpu);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | cpu | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | cpu1 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | cpu2 | |
|
||||
| 1970-01-01T00:00:00 | 2.0 | cpu0 | |
|
||||
| 1970-01-01T00:03:20 | 1.0 | cpu1 | |
|
||||
| 1970-01-01T00:03:20 | 2.0 | cpu0 | |
|
||||
| 1970-01-01T00:06:40 | 1.0 | cpu1 | |
|
||||
| 1970-01-01T00:06:40 | 2.0 | cpu0 | |
|
||||
| 1970-01-01T00:10:00 | 1.0 | cpu1 | |
|
||||
| 1970-01-01T00:10:00 | 2.0 | cpu0 | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Nested-count rewrite should preserve grouped presence after stale-marker filtering
|
||||
-- and null-value pruning.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 600, '200s') scalar(count(count(presence_metric{instance="i1"}) by (cpu)));
|
||||
|
||||
+---------------------+-------+
|
||||
| ts | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 3.0 |
|
||||
| 1970-01-01T00:03:20 | 2.0 |
|
||||
| 1970-01-01T00:06:40 | 2.0 |
|
||||
| 1970-01-01T00:10:00 | 2.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
-- Non-count inner aggregates must drop NULL-only groups before the outer count.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 600, '200s') scalar(count(sum(presence_metric{instance="i1"}) by (cpu)));
|
||||
|
||||
+---------------------+-------+
|
||||
| ts | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 3.0 |
|
||||
| 1970-01-01T00:03:20 | 2.0 |
|
||||
| 1970-01-01T00:06:40 | 2.0 |
|
||||
| 1970-01-01T00:10:00 | 2.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
-- False case: outer `by (instance)` keeps multiple series at the scalar input, so scalar should still yield NaN.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 600, '200s') scalar(count(count(presence_metric) by (instance, cpu)) by (instance));
|
||||
|
||||
+---------------------+-------+
|
||||
| ts | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | NaN |
|
||||
| 1970-01-01T00:03:20 | NaN |
|
||||
| 1970-01-01T00:06:40 | NaN |
|
||||
| 1970-01-01T00:10:00 | NaN |
|
||||
+---------------------+-------+
|
||||
|
||||
DROP TABLE presence_metric;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/scalar.sql
|
||||
@@ -0,0 +1,61 @@
|
||||
-- Legacy SQLness regression: these TQL EVAL cases pin the legacy PromQL planner.
|
||||
-- The native fused-series route is verified by test_prometheus_native_promql_route and
|
||||
-- test_native_promql_route_plans_the_query in tests-integration/tests/http.rs.
|
||||
CREATE TABLE native_scalar_entry (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
host STRING PRIMARY KEY,
|
||||
val DOUBLE,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO native_scalar_entry VALUES
|
||||
(0, 'host1', 1.0),
|
||||
(0, 'host2', 2.0),
|
||||
(1000, 'host1', 3.0),
|
||||
(1000, 'host2', 4.0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
TQL EVAL (0, 2, '1s') 1 + 2;
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 3.0 |
|
||||
| 1970-01-01T00:00:01 | 3.0 |
|
||||
| 1970-01-01T00:00:02 | 3.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 2, '1s') native_scalar_entry * 100;
|
||||
|
||||
+---------------------+-------+-------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 100.0 | host1 | |
|
||||
| 1970-01-01T00:00:00 | 200.0 | host2 | |
|
||||
| 1970-01-01T00:00:01 | 300.0 | host1 | |
|
||||
| 1970-01-01T00:00:01 | 400.0 | host2 | |
|
||||
| 1970-01-01T00:00:02 | 300.0 | host1 | |
|
||||
| 1970-01-01T00:00:02 | 400.0 | host2 | |
|
||||
+---------------------+-------+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 2, '1s') -native_scalar_entry;
|
||||
|
||||
+---------------------+------+-------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | -1.0 | host1 | |
|
||||
| 1970-01-01T00:00:00 | -2.0 | host2 | |
|
||||
| 1970-01-01T00:00:01 | -3.0 | host1 | |
|
||||
| 1970-01-01T00:00:01 | -4.0 | host2 | |
|
||||
| 1970-01-01T00:00:02 | -3.0 | host1 | |
|
||||
| 1970-01-01T00:00:02 | -4.0 | host2 | |
|
||||
+---------------------+------+-------+----------+
|
||||
|
||||
DROP TABLE native_scalar_entry;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/scalar_entry.sql
|
||||
@@ -0,0 +1,830 @@
|
||||
-- from promql/testdata/operators.test
|
||||
-- cases related to AND/OR/UNLESS
|
||||
-- group_left() and group_right() are not included
|
||||
create table http_requests (
|
||||
ts timestamp time index,
|
||||
job string,
|
||||
instance string,
|
||||
g string, -- for `group`
|
||||
greptime_value double,
|
||||
primary key (job, instance, g)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into http_requests values
|
||||
(3000000, "api", "0", "production", 100),
|
||||
(3000000, "api", "1", "production", 200),
|
||||
(3000000, "api", "0", "canary", 300),
|
||||
(3000000, "api", "1", "canary", 400),
|
||||
(3000000, "app", "0", "production", 500),
|
||||
(3000000, "app", "1", "production", 600),
|
||||
(3000000, "app", "0", "canary", 700),
|
||||
(3000000, "app", "1", "canary", 800);
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
-- empty metric
|
||||
create table cpu_count(ts timestamp time index, greptime_value double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table vector_matching_a(
|
||||
ts timestamp time index,
|
||||
l string primary key,
|
||||
greptime_value double,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into vector_matching_a values
|
||||
(3000000, "x", 10);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- eval instant at 50m http_requests{group="canary"} and http_requests{instance="0"}
|
||||
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
||||
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') http_requests{g="canary"} and http_requests{instance="0"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| 1970-01-01T00:50:00 | 300.0 | api | 0 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 700.0 | app | 0 | canary | http_requests |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) and http_requests{instance="0"}
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and http_requests{instance="0"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) and on(instance, job) http_requests{instance="0", group="production"}
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and on(instance, job) http_requests{instance="0", g="production"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) and on(instance) http_requests{instance="0", group="production"}
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and on(instance) http_requests{instance="0", g="production"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) and ignoring(group) http_requests{instance="0", group="production"}
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and ignoring(g) http_requests{instance="0", g="production"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) and ignoring(group, job) http_requests{instance="0", group="production"}
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and ignoring(g, job) http_requests{instance="0", g="production"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | |
|
||||
+---------------------+----------------+-----+----------+--------+----------+
|
||||
|
||||
-- eval instant at 50m http_requests{group="canary"} or http_requests{group="production"}
|
||||
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
||||
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
||||
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
||||
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
||||
-- http_requests{group="production", instance="0", job="api-server"} 100
|
||||
-- http_requests{group="production", instance="0", job="app-server"} 500
|
||||
-- http_requests{group="production", instance="1", job="api-server"} 200
|
||||
-- http_requests{group="production", instance="1", job="app-server"} 600
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') http_requests{g="canary"} or http_requests{g="production"};
|
||||
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| 1970-01-01T00:50:00 | 100.0 | api | 0 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 200.0 | api | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 300.0 | api | 0 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 400.0 | api | 1 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 500.0 | app | 0 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 600.0 | app | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 700.0 | app | 0 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 800.0 | app | 1 | canary | http_requests |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
|
||||
-- # On overlap the rhs samples must be dropped.
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) or http_requests{instance="1"}
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- {group="canary", instance="1", job="api-server"} 401
|
||||
-- {group="canary", instance="1", job="app-server"} 801
|
||||
-- http_requests{group="production", instance="1", job="api-server"} 200
|
||||
-- http_requests{group="production", instance="1", job="app-server"} 600
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) or http_requests{instance="1"};
|
||||
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| 1970-01-01T00:50:00 | 200.0 | api | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | |
|
||||
| 1970-01-01T00:50:00 | 401.0 | api | 1 | canary | |
|
||||
| 1970-01-01T00:50:00 | 600.0 | app | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | |
|
||||
| 1970-01-01T00:50:00 | 801.0 | app | 1 | canary | |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
|
||||
-- # Matching only on instance excludes everything that has instance=0/1 but includes
|
||||
-- # entries without the instance label.
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) or on(instance) (http_requests or cpu_count or vector_matching_a)
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- {group="canary", instance="1", job="api-server"} 401
|
||||
-- {group="canary", instance="1", job="app-server"} 801
|
||||
-- vector_matching_a{l="x"} 10
|
||||
-- vector_matching_a{l="y"} 20
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) or on(instance) (http_requests or cpu_count or vector_matching_a);
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+---+-------------------+
|
||||
| ts | greptime_value | job | instance | g | l | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+---+-------------------+
|
||||
| 1970-01-01T00:50:00 | 10.0 | | | | x | vector_matching_a |
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | | |
|
||||
| 1970-01-01T00:50:00 | 401.0 | api | 1 | canary | | |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | | |
|
||||
| 1970-01-01T00:50:00 | 801.0 | app | 1 | canary | | |
|
||||
+---------------------+----------------+-----+----------+--------+---+-------------------+
|
||||
|
||||
-- eval instant at 50m (http_requests{group="canary"} + 1) or ignoring(l, group, job) (http_requests or cpu_count or vector_matching_a)
|
||||
-- {group="canary", instance="0", job="api-server"} 301
|
||||
-- {group="canary", instance="0", job="app-server"} 701
|
||||
-- {group="canary", instance="1", job="api-server"} 401
|
||||
-- {group="canary", instance="1", job="app-server"} 801
|
||||
-- vector_matching_a{l="x"} 10
|
||||
-- vector_matching_a{l="y"} 20
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) or ignoring(l, g, job) (http_requests or cpu_count or vector_matching_a);
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+---+-------------------+
|
||||
| ts | greptime_value | job | instance | g | l | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+---+-------------------+
|
||||
| 1970-01-01T00:50:00 | 10.0 | | | | x | vector_matching_a |
|
||||
| 1970-01-01T00:50:00 | 301.0 | api | 0 | canary | | |
|
||||
| 1970-01-01T00:50:00 | 401.0 | api | 1 | canary | | |
|
||||
| 1970-01-01T00:50:00 | 701.0 | app | 0 | canary | | |
|
||||
| 1970-01-01T00:50:00 | 801.0 | app | 1 | canary | | |
|
||||
+---------------------+----------------+-----+----------+--------+---+-------------------+
|
||||
|
||||
-- eval instant at 50m http_requests{group="canary"} unless http_requests{instance="0"}
|
||||
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
||||
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless http_requests{instance="0"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| 1970-01-01T00:50:00 | 400.0 | api | 1 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 800.0 | app | 1 | canary | http_requests |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
|
||||
-- eval instant at 50m http_requests{group="canary"} unless on(job) http_requests{instance="0"}
|
||||
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless on(job) http_requests{instance="0"};
|
||||
|
||||
+----+----------------+-----+----------+---+----------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+----+----------------+-----+----------+---+----------+
|
||||
+----+----------------+-----+----------+---+----------+
|
||||
|
||||
-- eval instant at 50m http_requests{group="canary"} unless on(job, instance) http_requests{instance="0"}
|
||||
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
||||
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless on(job, instance) http_requests{instance="0"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| 1970-01-01T00:50:00 | 400.0 | api | 1 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 800.0 | app | 1 | canary | http_requests |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
|
||||
-- eval instant at 50m http_requests{group="canary"} unless ignoring(group, instance) http_requests{instance="0"}
|
||||
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless ignoring(g, instance) http_requests{instance="0"};
|
||||
|
||||
+----+----------------+-----+----------+---+----------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+----+----------------+-----+----------+---+----------+
|
||||
+----+----------------+-----+----------+---+----------+
|
||||
|
||||
-- eval instant at 50m http_requests{group="canary"} unless ignoring(group) http_requests{instance="0"}
|
||||
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
||||
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless ignoring(g) http_requests{instance="0"};
|
||||
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
| 1970-01-01T00:50:00 | 400.0 | api | 1 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 800.0 | app | 1 | canary | http_requests |
|
||||
+---------------------+----------------+-----+----------+--------+---------------+
|
||||
|
||||
-- # https://github.com/prometheus/prometheus/issues/1489
|
||||
-- eval instant at 50m http_requests AND ON (dummy) vector(1)
|
||||
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
||||
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
||||
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
||||
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
||||
-- http_requests{group="production", instance="0", job="api-server"} 100
|
||||
-- http_requests{group="production", instance="0", job="app-server"} 500
|
||||
-- http_requests{group="production", instance="1", job="api-server"} 200
|
||||
-- http_requests{group="production", instance="1", job="app-server"} 600
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') http_requests AND ON (dummy) vector(1);
|
||||
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| 1970-01-01T00:50:00 | 100.0 | api | 0 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 200.0 | api | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 300.0 | api | 0 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 400.0 | api | 1 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 500.0 | app | 0 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 600.0 | app | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 700.0 | app | 0 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 800.0 | app | 1 | canary | http_requests |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
|
||||
-- eval instant at 50m http_requests AND IGNORING (group, instance, job) vector(1)
|
||||
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
||||
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
||||
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
||||
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
||||
-- http_requests{group="production", instance="0", job="api-server"} 100
|
||||
-- http_requests{group="production", instance="0", job="app-server"} 500
|
||||
-- http_requests{group="production", instance="1", job="api-server"} 200
|
||||
-- http_requests{group="production", instance="1", job="app-server"} 600
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') http_requests AND IGNORING (g, instance, job) vector(1);
|
||||
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| ts | greptime_value | job | instance | g | __name__ |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
| 1970-01-01T00:50:00 | 100.0 | api | 0 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 200.0 | api | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 300.0 | api | 0 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 400.0 | api | 1 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 500.0 | app | 0 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 600.0 | app | 1 | production | http_requests |
|
||||
| 1970-01-01T00:50:00 | 700.0 | app | 0 | canary | http_requests |
|
||||
| 1970-01-01T00:50:00 | 800.0 | app | 1 | canary | http_requests |
|
||||
+---------------------+----------------+-----+----------+------------+---------------+
|
||||
|
||||
-- https://github.com/GreptimeTeam/greptimedb/issues/5392
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') vector(1) * http_requests;
|
||||
|
||||
+----+-------+----------+
|
||||
| ts | value | __name__ |
|
||||
+----+-------+----------+
|
||||
+----+-------+----------+
|
||||
|
||||
drop table http_requests;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table cpu_count;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table vector_matching_a;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- the following cases are not from Prometheus.
|
||||
create table t1 (ts timestamp time index, job string primary key, greptime_value double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into t1 values (0, "a", 1.0), (500000, "b", 2.0), (1000000, "a", 3.0), (1500000, "c", 4.0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
create table t2 (ts timestamp time index, greptime_value double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into t2 values (0, 0), (300000, 0), (600000, 0), (900000, 0), (1200000, 0), (1500000, 0), (1800000, 0);
|
||||
|
||||
Affected Rows: 7
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') t1 or t2;
|
||||
|
||||
+---------------------+----------------+-----+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+----------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | t1 |
|
||||
| 1970-01-01T00:06:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:13:20 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 3.0 | a | t1 |
|
||||
| 1970-01-01T00:26:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:26:40 | 4.0 | c | t1 |
|
||||
| 1970-01-01T00:33:20 | 0.0 | | t2 |
|
||||
+---------------------+----------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') t1 or on () t2;
|
||||
|
||||
+---------------------+----------------+-----+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+----------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | t1 |
|
||||
| 1970-01-01T00:06:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:13:20 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 3.0 | a | t1 |
|
||||
| 1970-01-01T00:26:40 | 4.0 | c | t1 |
|
||||
| 1970-01-01T00:33:20 | 0.0 | | t2 |
|
||||
+---------------------+----------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') t1 or on (job) t2;
|
||||
|
||||
+---------------------+----------------+-----+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+----------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | t1 |
|
||||
| 1970-01-01T00:06:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:13:20 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 3.0 | a | t1 |
|
||||
| 1970-01-01T00:26:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:26:40 | 4.0 | c | t1 |
|
||||
| 1970-01-01T00:33:20 | 0.0 | | t2 |
|
||||
+---------------------+----------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') t2 or t1;
|
||||
|
||||
+---------------------+----------------+-----+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+----------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | t1 |
|
||||
| 1970-01-01T00:06:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:13:20 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 3.0 | a | t1 |
|
||||
| 1970-01-01T00:26:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:26:40 | 4.0 | c | t1 |
|
||||
| 1970-01-01T00:33:20 | 0.0 | | t2 |
|
||||
+---------------------+----------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') t2 or on () t1;
|
||||
|
||||
+---------------------+----------------+-----+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+----------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:06:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:13:20 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:26:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:33:20 | 0.0 | | t2 |
|
||||
+---------------------+----------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') t2 or on(job) t1;
|
||||
|
||||
+---------------------+----------------+-----+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+----------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | t1 |
|
||||
| 1970-01-01T00:06:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:13:20 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:20:00 | 3.0 | a | t1 |
|
||||
| 1970-01-01T00:26:40 | 0.0 | | t2 |
|
||||
| 1970-01-01T00:26:40 | 4.0 | c | t1 |
|
||||
| 1970-01-01T00:33:20 | 0.0 | | t2 |
|
||||
+---------------------+----------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') sum(t1{job="a"});
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | |
|
||||
| 1970-01-01T00:20:00 | 3.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') sum(t1{job="a"}) - sum(t1{job="e"} or vector(1));
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:20:00 | 2.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
drop table t1;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table t2;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table stats_used_bytes (
|
||||
ts timestamp time index,
|
||||
namespace string,
|
||||
greptime_value double,
|
||||
primary key (namespace)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table stats_capacity_bytes (
|
||||
ts timestamp time index,
|
||||
namespace string,
|
||||
greptime_value double,
|
||||
primary key (namespace)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into stats_used_bytes values
|
||||
(0, "namespace1", 1.0),
|
||||
(0, "namespace2", 2.0),
|
||||
(500000, "namespace1", 10.0),
|
||||
(500000, "namespace2", 20.0),
|
||||
(1000000, "namespace1", 25.0),
|
||||
(1000000, "namespace2", 26.0);
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
insert into stats_capacity_bytes values
|
||||
(0, "namespace1", 30.0),
|
||||
(0, "namespace2", 30.0),
|
||||
(500000, "namespace1", 30.0),
|
||||
(500000, "namespace2", 30.0),
|
||||
(1000000, "namespace1", 30.0),
|
||||
(1000000, "namespace2", 30.0);
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') max by (namespace) (stats_used_bytes{namespace=~".+"}) / max by (namespace) (stats_capacity_bytes{namespace=~".+"}) >= (80 / 100);
|
||||
|
||||
+---------------------+--------------------+------------+----------+
|
||||
| ts | greptime_value | namespace | __name__ |
|
||||
+---------------------+--------------------+------------+----------+
|
||||
| 1970-01-01T00:20:00 | 0.8333333333333334 | namespace1 | |
|
||||
| 1970-01-01T00:20:00 | 0.8666666666666667 | namespace2 | |
|
||||
+---------------------+--------------------+------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') max by (namespace) (stats_used_bytes{namespace=~".+"}) and (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100));
|
||||
|
||||
+---------------------+----------------+------------+----------+
|
||||
| ts | greptime_value | namespace | __name__ |
|
||||
+---------------------+----------------+------------+----------+
|
||||
| 1970-01-01T00:20:00 | 25.0 | namespace1 | |
|
||||
| 1970-01-01T00:20:00 | 26.0 | namespace2 | |
|
||||
+---------------------+----------------+------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') count(max by (namespace) (stats_used_bytes{namespace=~".+"}) and (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100))) or vector(0);
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:06:40 | 0.0 | |
|
||||
| 1970-01-01T00:13:20 | 0.0 | |
|
||||
| 1970-01-01T00:20:00 | 2.0 | |
|
||||
| 1970-01-01T00:26:40 | 0.0 | |
|
||||
| 1970-01-01T00:33:20 | 0.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') count(max by (namespace) (stats_used_bytes{namespace=~".+"}) and (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100)));
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:20:00 | 2.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 2000, '400') count(max by (namespace) (stats_used_bytes{namespace=~".+"}) unless (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100)));
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 2.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
drop table stats_used_bytes;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table stats_capacity_bytes;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table cache_hit (
|
||||
ts timestamp time index,
|
||||
job string,
|
||||
greptime_value double,
|
||||
primary key (job)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table cache_miss (
|
||||
ts timestamp time index,
|
||||
job string,
|
||||
greptime_value double,
|
||||
primary key (job)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into cache_hit values
|
||||
(3000, "read", 1.0),
|
||||
(3000, "write", 2.0),
|
||||
(4000, "read", 3.0),
|
||||
(4000, "write", 4.0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
insert into cache_miss values
|
||||
(3000, "read", 1.0),
|
||||
(3000, "write", 2.0),
|
||||
(4000, "read", 1.0),
|
||||
(4000, "write", 2.0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 4, '1s') cache_hit / (cache_miss + cache_hit);
|
||||
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| 1970-01-01T00:00:03 | 0.5 | read | |
|
||||
| 1970-01-01T00:00:03 | 0.5 | write | |
|
||||
| 1970-01-01T00:00:04 | 0.6666666666666666 | write | |
|
||||
| 1970-01-01T00:00:04 | 0.75 | read | |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
|
||||
drop table cache_hit;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table cache_miss;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table cache_hit_with_null_label (
|
||||
ts timestamp time index,
|
||||
job string,
|
||||
null_label string null,
|
||||
greptime_value double,
|
||||
primary key (job, null_label)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
create table cache_miss_with_null_label (
|
||||
ts timestamp time index,
|
||||
job string,
|
||||
null_label string null,
|
||||
greptime_value double,
|
||||
primary key (job, null_label)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into cache_hit_with_null_label values
|
||||
(3000, "read", null, 1.0),
|
||||
(3000, "write", null, 2.0),
|
||||
(4000, "read", null, 3.0),
|
||||
(4000, "write", null, 4.0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
insert into cache_miss_with_null_label values
|
||||
(3000, "read", null, 1.0),
|
||||
(3000, "write", null, 2.0),
|
||||
(4000, "read", null, 1.0),
|
||||
(4000, "write", null, 2.0);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 4, '1s') cache_hit_with_null_label / (cache_miss_with_null_label + cache_hit_with_null_label);
|
||||
|
||||
+---------------------+--------------------+-------+------------+----------+
|
||||
| ts | greptime_value | job | null_label | __name__ |
|
||||
+---------------------+--------------------+-------+------------+----------+
|
||||
| 1970-01-01T00:00:03 | 0.5 | read | | |
|
||||
| 1970-01-01T00:00:03 | 0.5 | write | | |
|
||||
| 1970-01-01T00:00:04 | 0.6666666666666666 | write | | |
|
||||
| 1970-01-01T00:00:04 | 0.75 | read | | |
|
||||
+---------------------+--------------------+-------+------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 4, '1s') cache_hit_with_null_label / ignoring(null_label) (cache_miss_with_null_label + ignoring(null_label) cache_hit_with_null_label);
|
||||
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| 1970-01-01T00:00:03 | 0.5 | read | |
|
||||
| 1970-01-01T00:00:03 | 0.5 | write | |
|
||||
| 1970-01-01T00:00:04 | 0.6666666666666666 | write | |
|
||||
| 1970-01-01T00:00:04 | 0.75 | read | |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3, 4, '1s') cache_hit_with_null_label / on(job) (cache_miss_with_null_label + on(job) cache_hit_with_null_label);
|
||||
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| ts | greptime_value | job | __name__ |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| 1970-01-01T00:00:03 | 0.5 | read | |
|
||||
| 1970-01-01T00:00:03 | 0.5 | write | |
|
||||
| 1970-01-01T00:00:04 | 0.6666666666666666 | write | |
|
||||
| 1970-01-01T00:00:04 | 0.75 | read | |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
|
||||
drop table cache_hit_with_null_label;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table cache_miss_with_null_label;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Physical table for test
|
||||
CREATE TABLE test_physical (greptime_timestamp timestamp time index, greptime_value double) engine=metric with ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE IF NOT EXISTS node_network_transmit_bytes_total (
|
||||
cloud STRING NULL,
|
||||
dest_port STRING NULL,
|
||||
dest STRING NULL,
|
||||
greptime_timestamp TIMESTAMP(3) NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
host STRING NULL,
|
||||
job STRING NULL,
|
||||
node STRING NULL,
|
||||
"region" STRING NULL,
|
||||
src_port STRING NULL,
|
||||
src STRING NULL,
|
||||
src_namespace STRING NULL,
|
||||
src_node STRING NULL,
|
||||
src_pod STRING NULL,
|
||||
az STRING NULL,
|
||||
TIME INDEX (greptime_timestamp),
|
||||
PRIMARY KEY (cloud, dest_port, dest, host, job, node, region, src_port, src, src_namespace, src_node, src_pod, az)
|
||||
)
|
||||
ENGINE=metric
|
||||
WITH(
|
||||
on_physical_table = 'test_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO node_network_transmit_bytes_total (
|
||||
cloud, dest_port, dest, greptime_timestamp, greptime_value, host, job, node, region, src_port, src, src_namespace, src_node, src_pod, az
|
||||
) VALUES
|
||||
('cloud-1', '443', '10.0.0.2', 1000000, 1000, 'host-1', 'greptimedb', 'node-a', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-1', 'pod-1', 'us-west-6'),
|
||||
('cloud-1', '443', '10.0.0.2', 1200000, 2000, 'host-1', 'greptimedb', 'node-a', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-1', 'pod-1', 'us-west-6'),
|
||||
('cloud-1', '443', '10.0.0.3', 1000000, 1500, 'host-2', 'greptimedb', 'node-b', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-2', 'pod-2', 'us-west-6'),
|
||||
('cloud-1', '443', '10.0.0.3', 1200000, 2500, 'host-2', 'greptimedb', 'node-b', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-2', 'pod-2', 'us-west-6'),
|
||||
('cloud-2', '80', '10.0.0.5', 1000000, 800, 'host-3', 'greptimedb', 'node-c', 'us-west', '9000', '10.0.0.4', 'namespace-2', 'node-3', 'pod-3', 'us-west-6'),
|
||||
('cloud-2', '80', '10.0.0.5', 1200000, 1800, 'host-3', 'greptimedb', 'node-c', 'us-west', '9000', '10.0.0.4', 'namespace-2', 'node-3', 'pod-3', 'us-west-6');
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
-- Or with unknown label and metric.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(1000, 2000, '300s') unknown_metric or node_network_transmit_bytes_total;
|
||||
|
||||
+---------------------+-----------+---------+----------+-----------+--------+------------+--------+---------+----------+---------------+----------+---------+----------+--------+
|
||||
| time | az | cloud | dest | dest_port | host | job | node | region | src | src_namespace | src_node | src_pod | src_port | value |
|
||||
+---------------------+-----------+---------+----------+-----------+--------+------------+--------+---------+----------+---------------+----------+---------+----------+--------+
|
||||
| 1970-01-01T00:16:40 | us-west-6 | cloud-1 | 10.0.0.2 | 443 | host-1 | greptimedb | node-a | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | 8080 | 1000.0 |
|
||||
| 1970-01-01T00:16:40 | us-west-6 | cloud-1 | 10.0.0.3 | 443 | host-2 | greptimedb | node-b | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | 8080 | 1500.0 |
|
||||
| 1970-01-01T00:16:40 | us-west-6 | cloud-2 | 10.0.0.5 | 80 | host-3 | greptimedb | node-c | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | 9000 | 800.0 |
|
||||
| 1970-01-01T00:21:40 | us-west-6 | cloud-1 | 10.0.0.2 | 443 | host-1 | greptimedb | node-a | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | 8080 | 2000.0 |
|
||||
| 1970-01-01T00:21:40 | us-west-6 | cloud-1 | 10.0.0.3 | 443 | host-2 | greptimedb | node-b | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | 8080 | 2500.0 |
|
||||
| 1970-01-01T00:21:40 | us-west-6 | cloud-2 | 10.0.0.5 | 80 | host-3 | greptimedb | node-c | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | 9000 | 1800.0 |
|
||||
+---------------------+-----------+---------+----------+-----------+--------+------------+--------+---------+----------+---------------+----------+---------+----------+--------+
|
||||
|
||||
-- Or with unknown label and metric.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(1000, 2000, '300s') sum by (cloud, tag0, tag1) (node_network_transmit_bytes_total) or unknown_metric;
|
||||
|
||||
+---------------------+---------+-------------------------------------------------------+
|
||||
| greptime_timestamp | cloud | sum(node_network_transmit_bytes_total.greptime_value) |
|
||||
+---------------------+---------+-------------------------------------------------------+
|
||||
| 1970-01-01T00:16:40 | cloud-1 | 2500.0 |
|
||||
| 1970-01-01T00:16:40 | cloud-2 | 800.0 |
|
||||
| 1970-01-01T00:21:40 | cloud-1 | 4500.0 |
|
||||
| 1970-01-01T00:21:40 | cloud-2 | 1800.0 |
|
||||
+---------------------+---------+-------------------------------------------------------+
|
||||
|
||||
-- Or with unknown label and metric.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(1000, 2000, '300s') unknown_metric or unknown_metric1 or sum by (cloud, tag0, tag1) (node_network_transmit_bytes_total);
|
||||
|
||||
+---------------------+---------+--------+
|
||||
| time | cloud | value |
|
||||
+---------------------+---------+--------+
|
||||
| 1970-01-01T00:16:40 | cloud-1 | 2500.0 |
|
||||
| 1970-01-01T00:16:40 | cloud-2 | 800.0 |
|
||||
| 1970-01-01T00:21:40 | cloud-1 | 4500.0 |
|
||||
| 1970-01-01T00:21:40 | cloud-2 | 1800.0 |
|
||||
+---------------------+---------+--------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(1000, 2000, '300s') sum by (cloud, tag0, tag1) (node_network_transmit_bytes_total) or sum by (cloud, tag0, tag1) (unknown_metric);
|
||||
|
||||
+---------------------+---------+-------------------------------------------------------+
|
||||
| greptime_timestamp | cloud | sum(node_network_transmit_bytes_total.greptime_value) |
|
||||
+---------------------+---------+-------------------------------------------------------+
|
||||
| 1970-01-01T00:16:40 | cloud-1 | 2500.0 |
|
||||
| 1970-01-01T00:16:40 | cloud-2 | 800.0 |
|
||||
| 1970-01-01T00:21:40 | cloud-1 | 4500.0 |
|
||||
| 1970-01-01T00:21:40 | cloud-2 | 1800.0 |
|
||||
+---------------------+---------+-------------------------------------------------------+
|
||||
|
||||
-- Or with unknown label dst_namespace.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(1000, 2000, '300s') sum by (src, src_pod, src_namespace, src_node, dest, dst_pod, dst_namespace, dst_node, cloud, region, az) (increase(node_network_transmit_bytes_total{src_node!="", job=~"greptimedb", region=~"us-west", az=~"us-west-6"}[900s])>0) or sum by (src, src_pod, src_namespace, src_node, dest, dst_pod, dst_namespace, dst_node, cloud, region, az) (increase(node_network_transmit_bytes_total{dst_node!="", job=~"greptimedb", region=~"us-west", az=~"us-west-6"}[900s])>0);
|
||||
|
||||
+---------------------+----------------+-----------+---------+----------+---------+----------+---------------+----------+---------+----------+
|
||||
| greptime_timestamp | greptime_value | az | cloud | dest | region | src | src_namespace | src_node | src_pod | __name__ |
|
||||
+---------------------+----------------+-----------+---------+----------+---------+----------+---------------+----------+---------+----------+
|
||||
| 1970-01-01T00:21:40 | 2000.0 | us-west-6 | cloud-1 | 10.0.0.2 | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | |
|
||||
| 1970-01-01T00:21:40 | 2000.0 | us-west-6 | cloud-1 | 10.0.0.3 | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | |
|
||||
| 1970-01-01T00:21:40 | 2000.0 | us-west-6 | cloud-2 | 10.0.0.5 | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | |
|
||||
| 1970-01-01T00:26:40 | 2000.0 | us-west-6 | cloud-1 | 10.0.0.2 | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | |
|
||||
| 1970-01-01T00:26:40 | 2000.0 | us-west-6 | cloud-1 | 10.0.0.3 | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | |
|
||||
| 1970-01-01T00:26:40 | 2000.0 | us-west-6 | cloud-2 | 10.0.0.5 | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | |
|
||||
+---------------------+----------------+-----------+---------+----------+---------+----------+---------------+----------+---------+----------+
|
||||
|
||||
DROP TABLE node_network_transmit_bytes_total;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE test_physical;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/set_operation.sql
|
||||
@@ -0,0 +1,527 @@
|
||||
-- from prometheus/promql/testdata/histograms.test
|
||||
-- cases related to metric `testhistogram_bucket`
|
||||
create table histogram_bucket (
|
||||
ts timestamp time index,
|
||||
le string,
|
||||
s string,
|
||||
val double,
|
||||
primary key (s, le),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into histogram_bucket values
|
||||
(3000000, "0.1", "positive", 50),
|
||||
(3000000, ".2", "positive", 70),
|
||||
(3000000, "1e0", "positive", 110),
|
||||
(3000000, "+Inf", "positive", 120),
|
||||
(3000000, "-.2", "negative", 10),
|
||||
(3000000, "-0.1", "negative", 20),
|
||||
(3000000, "0.3", "negative", 20),
|
||||
(3000000, "+Inf", "negative", 30);
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
-- Quantile too low.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(-0.1, histogram_bucket);
|
||||
|
||||
+---------------------+------+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+------+----------+----------+
|
||||
| 1970-01-01T00:50:00 | -inf | negative | |
|
||||
| 1970-01-01T00:50:00 | -inf | positive | |
|
||||
+---------------------+------+----------+----------+
|
||||
|
||||
-- Quantile too high.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(1.01, histogram_bucket);
|
||||
|
||||
+---------------------+-----+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+-----+----------+----------+
|
||||
| 1970-01-01T00:50:00 | inf | negative | |
|
||||
| 1970-01-01T00:50:00 | inf | positive | |
|
||||
+---------------------+-----+----------+----------+
|
||||
|
||||
-- Quantile invalid.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(NaN, histogram_bucket);
|
||||
|
||||
+---------------------+-----+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+-----+----------+----------+
|
||||
| 1970-01-01T00:50:00 | NaN | negative | |
|
||||
| 1970-01-01T00:50:00 | NaN | positive | |
|
||||
+---------------------+-----+----------+----------+
|
||||
|
||||
-- Quantile value in lowest bucket, which is positive.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0, histogram_bucket{s="positive"});
|
||||
|
||||
+---------------------+-----+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+-----+----------+----------+
|
||||
| 1970-01-01T00:50:00 | 0.0 | positive | |
|
||||
+---------------------+-----+----------+----------+
|
||||
|
||||
-- Quantile value in lowest bucket, which is negative.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0, histogram_bucket{s="negative"});
|
||||
|
||||
+---------------------+------+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+------+----------+----------+
|
||||
| 1970-01-01T00:50:00 | -0.2 | negative | |
|
||||
+---------------------+------+----------+----------+
|
||||
|
||||
-- Quantile value in highest bucket.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(1, histogram_bucket);
|
||||
|
||||
+---------------------+-----+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+-----+----------+----------+
|
||||
| 1970-01-01T00:50:00 | 0.3 | negative | |
|
||||
| 1970-01-01T00:50:00 | 1.0 | positive | |
|
||||
+---------------------+-----+----------+----------+
|
||||
|
||||
-- Finally some useful quantiles.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0.2, histogram_bucket);
|
||||
|
||||
+---------------------+-------+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+-------+----------+----------+
|
||||
| 1970-01-01T00:50:00 | -0.2 | negative | |
|
||||
| 1970-01-01T00:50:00 | 0.048 | positive | |
|
||||
+---------------------+-------+----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0.5, histogram_bucket);
|
||||
|
||||
+---------------------+----------------------+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+----------------------+----------+----------+
|
||||
| 1970-01-01T00:50:00 | -0.15000000000000002 | negative | |
|
||||
| 1970-01-01T00:50:00 | 0.15000000000000002 | positive | |
|
||||
+---------------------+----------------------+----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0.8, histogram_bucket);
|
||||
|
||||
+---------------------+------+----------+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+------+----------+----------+
|
||||
| 1970-01-01T00:50:00 | 0.3 | negative | |
|
||||
| 1970-01-01T00:50:00 | 0.72 | positive | |
|
||||
+---------------------+------+----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') label_replace(histogram_quantile(0.8, histogram_bucket), "s2", "$1", "s", "(.*)tive");
|
||||
|
||||
+---------------------+------+----------+------+----------+
|
||||
| ts | val | s | s2 | __name__ |
|
||||
+---------------------+------+----------+------+----------+
|
||||
| 1970-01-01T00:50:00 | 0.3 | negative | nega | |
|
||||
| 1970-01-01T00:50:00 | 0.72 | positive | posi | |
|
||||
+---------------------+------+----------+------+----------+
|
||||
|
||||
-- More realistic with rates.
|
||||
-- This case doesn't contains value because other point are not inserted.
|
||||
-- Prometheus `v3.9.1` updates the range to 10m to avoid the (t-r) boundary.
|
||||
-- Quantile with rate is covered in other cases.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0.2, rate(histogram_bucket[10m]));
|
||||
|
||||
+----+-----+---+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+----+-----+---+----------+
|
||||
+----+-----+---+----------+
|
||||
|
||||
drop table histogram_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- cases related to `testhistogram2_bucket`
|
||||
create table histogram2_bucket (
|
||||
ts timestamp time index,
|
||||
le string,
|
||||
val double,
|
||||
primary key (le),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into histogram2_bucket values
|
||||
(0, "0", 0),
|
||||
(300000, "0", 0),
|
||||
(600000, "0", 0),
|
||||
(900000, "0", 0),
|
||||
(1200000, "0", 0),
|
||||
(1500000, "0", 0),
|
||||
(1800000, "0", 0),
|
||||
(2100000, "0", 0),
|
||||
(2400000, "0", 0),
|
||||
(2700000, "0", 0),
|
||||
(0, "2", 1),
|
||||
(300000, "2", 2),
|
||||
(600000, "2", 3),
|
||||
(900000, "2", 4),
|
||||
(1200000, "2", 5),
|
||||
(1500000, "2", 6),
|
||||
(1800000, "2", 7),
|
||||
(2100000, "2", 8),
|
||||
(2400000, "2", 9),
|
||||
(2700000, "2", 10),
|
||||
(0, "4", 2),
|
||||
(300000, "4", 4),
|
||||
(600000, "4", 6),
|
||||
(900000, "4", 8),
|
||||
(1200000, "4", 10),
|
||||
(1500000, "4", 12),
|
||||
(1800000, "4", 14),
|
||||
(2100000, "4", 16),
|
||||
(2400000, "4", 18),
|
||||
(2700000, "4", 20),
|
||||
(0, "6", 3),
|
||||
(300000, "6", 6),
|
||||
(600000, "6", 9),
|
||||
(900000, "6", 12),
|
||||
(1200000, "6", 15),
|
||||
(1500000, "6", 18),
|
||||
(1800000, "6", 21),
|
||||
(2100000, "6", 24),
|
||||
(2400000, "6", 27),
|
||||
(2700000, "6", 30),
|
||||
(0, "+Inf", 3),
|
||||
(300000, "+Inf", 6),
|
||||
(600000, "+Inf", 9),
|
||||
(900000, "+Inf", 12),
|
||||
(1200000, "+Inf", 15),
|
||||
(1500000, "+Inf", 18),
|
||||
(1800000, "+Inf", 21),
|
||||
(2100000, "+Inf", 24),
|
||||
(2400000, "+Inf", 27),
|
||||
(2700000, "+Inf", 30);
|
||||
|
||||
Affected Rows: 50
|
||||
|
||||
-- Want results exactly in the middle of the bucket.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (420, 420, '1s') histogram_quantile(0.166, histogram2_bucket);
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:07:00 | 0.996 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (420, 420, '1s') histogram_quantile(0.5, histogram2_bucket);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:07:00 | 3.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (420, 420, '1s') histogram_quantile(0.833, histogram2_bucket);
|
||||
|
||||
+---------------------+-------------------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------------------+----------+
|
||||
| 1970-01-01T00:07:00 | 4.997999999999999 | |
|
||||
+---------------------+-------------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (2820, 2820, '1s') histogram_quantile(0.166, rate(histogram2_bucket[15m]));
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:47:00 | 0.996 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (2820, 2820, '1s') histogram_quantile(0.5, rate(histogram2_bucket[15m]));
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:47:00 | 3.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (2820, 2820, '1s') histogram_quantile(0.833, rate(histogram2_bucket[15m]));
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:47:00 | 4.998 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
drop table histogram2_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- not from Prometheus
|
||||
-- makesure the sort expr works as expected
|
||||
create table histogram3_bucket (
|
||||
ts timestamp time index,
|
||||
le string,
|
||||
s string,
|
||||
val double,
|
||||
primary key (s, le),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into histogram3_bucket values
|
||||
(2900000, "0.1", "a", 0),
|
||||
(2900000, "1", "a", 0),
|
||||
(2900000, "5", "a", 0),
|
||||
(2900000, "+Inf", "a", 0),
|
||||
(3000000, "0.1", "a", 50),
|
||||
(3000000, "1", "a", 70),
|
||||
(3000000, "5", "a", 110),
|
||||
(3000000, "+Inf", "a", 120),
|
||||
(3005000, "0.1", "a", 10),
|
||||
(3005000, "1", "a", 20),
|
||||
(3005000, "5", "a", 20),
|
||||
(3005000, "+Inf", "a", 30);
|
||||
|
||||
Affected Rows: 12
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3005, '3s') histogram_quantile(0.5, sum by(le, s) (rate(histogram3_bucket[5m])));
|
||||
|
||||
+---------------------+--------------------+---+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+--------------------+---+----------+
|
||||
| 1970-01-01T00:50:00 | 0.55 | a | |
|
||||
| 1970-01-01T00:50:03 | 0.5500000000000003 | a | |
|
||||
+---------------------+--------------------+---+----------+
|
||||
|
||||
drop table histogram3_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- test with invalid data (unaligned buckets)
|
||||
create table histogram4_bucket (
|
||||
ts timestamp time index,
|
||||
le string,
|
||||
s string,
|
||||
val double,
|
||||
primary key (s, le),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into histogram4_bucket values
|
||||
(2900000, "0.1", "a", 0),
|
||||
(2900000, "1", "a", 10),
|
||||
(2900000, "5", "a", 20),
|
||||
(2900000, "+Inf", "a", 150),
|
||||
(3000000, "0.1", "a", 50),
|
||||
(3000000, "1", "a", 70),
|
||||
(3000000, "5", "a", 120),
|
||||
-- INF here is missing
|
||||
;
|
||||
|
||||
Affected Rows: 7
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (2900, 3000, '100s') histogram_quantile(0.9, histogram4_bucket);
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:48:20 | 5.0 | a | |
|
||||
| 1970-01-01T00:50:00 | 5.0 | a | |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
drop table histogram4_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(0, 10, '10s') histogram_quantile(0.99, sum by(pod,instance, fff) (rate(greptime_servers_postgres_query_elapsed_bucket{instance=~"xxx"}[1m])));
|
||||
|
||||
+------+----------------------------------------------------+
|
||||
| time | sum(prom_rate(time_range,value,time,Int64(60000))) |
|
||||
+------+----------------------------------------------------+
|
||||
+------+----------------------------------------------------+
|
||||
|
||||
-- test case where table exists but doesn't have 'le' column should raise error
|
||||
CREATE TABLE greptime_servers_postgres_query_elapsed_no_le (
|
||||
pod STRING,
|
||||
instance STRING,
|
||||
t TIMESTAMP TIME INDEX,
|
||||
v DOUBLE,
|
||||
PRIMARY KEY (pod, instance)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- should return empty result instead of error when 'le' column is missin
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(0, 10, '10s') histogram_quantile(0.99, sum by(pod,instance, le) (rate(greptime_servers_postgres_query_elapsed_no_le{instance=~"xxx"}[1m])));
|
||||
|
||||
+---+---+-----+----------+----------+
|
||||
| t | v | pod | instance | __name__ |
|
||||
+---+---+-----+----------+----------+
|
||||
+---+---+-----+----------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval(0, 10, '10s') histogram_quantile(0.99, sum by(pod,instance, fbf) (rate(greptime_servers_postgres_query_elapsed_no_le{instance=~"xxx"}[1m])));
|
||||
|
||||
+---+---+-----+----------+----------+
|
||||
| t | v | pod | instance | __name__ |
|
||||
+---+---+-----+----------+----------+
|
||||
+---+---+-----+----------+----------+
|
||||
|
||||
drop table greptime_servers_postgres_query_elapsed_no_le;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- test case with some missing buckets
|
||||
create table histogram5_bucket (
|
||||
ts timestamp time index,
|
||||
le string,
|
||||
s string,
|
||||
val double,
|
||||
primary key (s, le),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into histogram5_bucket values
|
||||
(3000000, "0.1", "a", 0),
|
||||
-- (3000000, "1", "a", 0),
|
||||
-- (3000000, "5", "a", 0),
|
||||
-- (3000000, "+Inf", "a", 0),
|
||||
(3005000, "0.1", "a", 50),
|
||||
(3005000, "1", "a", 70),
|
||||
(3005000, "5", "a", 110),
|
||||
(3005000, "+Inf", "a", 120),
|
||||
(3010000, "0.1", "a", 10),
|
||||
-- (3010000, "1", "a", 20),
|
||||
-- (3010000, "5", "a", 20),
|
||||
(3010000, "+Inf", "a", 30),
|
||||
(3015000, "0.1", "a", 10),
|
||||
(3015000, "1", "a", 10),
|
||||
(3015000, "3", "a", 20), --
|
||||
(3015000, "5", "a", 30),
|
||||
(3015000, "+Inf", "a", 50);
|
||||
|
||||
Affected Rows: 12
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3015, '3s') histogram_quantile(0.5, histogram5_bucket);
|
||||
|
||||
+---------------------+-------+---+----------+
|
||||
| ts | val | s | __name__ |
|
||||
+---------------------+-------+---+----------+
|
||||
| 1970-01-01T00:50:00 | NaN | a | |
|
||||
| 1970-01-01T00:50:03 | NaN | a | |
|
||||
| 1970-01-01T00:50:06 | 0.55 | a | |
|
||||
| 1970-01-01T00:50:09 | 0.55 | a | |
|
||||
| 1970-01-01T00:50:12 | 0.775 | a | |
|
||||
| 1970-01-01T00:50:15 | 4.0 | a | |
|
||||
+---------------------+-------+---+----------+
|
||||
|
||||
drop table histogram5_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Issue #9443: string labels stay distinct during aggregation, but equal
|
||||
-- numeric bucket boundaries must be coalesced before monotonicity repair.
|
||||
CREATE TABLE equivalent_bounds_bucket (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
instance STRING,
|
||||
le STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY (instance, le)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO equivalent_bounds_bucket VALUES
|
||||
(3000000, 'a', '10', 40),
|
||||
(3000000, 'a', '100', 50),
|
||||
(3000000, 'a', '+Inf', 50),
|
||||
(3000000, 'b', '10.0', 40),
|
||||
(3000000, 'b', '100.0', 50),
|
||||
(3000000, 'b', '1000.0', 50),
|
||||
(3000000, 'b', '+Inf', 50);
|
||||
|
||||
Affected Rows: 7
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') sum by (le) (equivalent_bounds_bucket);
|
||||
|
||||
+---------------------+-------+--------+----------+
|
||||
| ts | val | le | __name__ |
|
||||
+---------------------+-------+--------+----------+
|
||||
| 1970-01-01T00:50:00 | 100.0 | +Inf | |
|
||||
| 1970-01-01T00:50:00 | 40.0 | 10 | |
|
||||
| 1970-01-01T00:50:00 | 40.0 | 10.0 | |
|
||||
| 1970-01-01T00:50:00 | 50.0 | 100 | |
|
||||
| 1970-01-01T00:50:00 | 50.0 | 100.0 | |
|
||||
| 1970-01-01T00:50:00 | 50.0 | 1000.0 | |
|
||||
+---------------------+-------+--------+----------+
|
||||
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0.95, sum by (le) (equivalent_bounds_bucket));
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:50:00 | 77.5 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0.95, sum by (instance, le) (equivalent_bounds_bucket));
|
||||
|
||||
+---------------------+------+----------+----------+
|
||||
| ts | val | instance | __name__ |
|
||||
+---------------------+------+----------+----------+
|
||||
| 1970-01-01T00:50:00 | 77.5 | a | |
|
||||
| 1970-01-01T00:50:00 | 77.5 | b | |
|
||||
+---------------------+------+----------+----------+
|
||||
|
||||
DROP TABLE equivalent_bounds_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Equivalent infinity labels belong to the same histogram until the group ends.
|
||||
CREATE TABLE infinity_bounds_bucket (
|
||||
ts TIMESTAMP TIME INDEX,
|
||||
le STRING,
|
||||
val DOUBLE,
|
||||
PRIMARY KEY (le)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO infinity_bounds_bucket VALUES
|
||||
(3000000, '10', 20),
|
||||
(3000000, '10.0', 20),
|
||||
(3000000, '+Inf', 25),
|
||||
(3000000, '+inf', 25);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
tql eval (3000, 3000, '1s') histogram_quantile(0.5, infinity_bounds_bucket);
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:50:00 | 6.25 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
DROP TABLE infinity_bounds_bucket;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/simple_histogram.sql
|
||||
@@ -0,0 +1,332 @@
|
||||
create table metric_total (
|
||||
ts timestamp time index,
|
||||
val double,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into metric_total values
|
||||
(0, 1),
|
||||
(10000, 2);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
tql eval (10, 10, '1s') sum_over_time(metric_total[50s:10s]);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:10 | 3.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
tql eval (10, 10, '1s') sum_over_time(metric_total[50s:5s]);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:10 | 4.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
tql eval (300, 300, '1s') sum_over_time(metric_total[50s:10s]);
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:05:00 | 10.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
tql eval (359, 359, '1s') sum_over_time(metric_total[60s:10s]);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:05:59 | 2.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
tql eval (10, 10, '1s') rate(metric_total[20s:10s]);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:10 | 0.1 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
tql eval (20, 20, '1s') rate(metric_total[20s:5s]);
|
||||
|
||||
+---------------------+---------------------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+---------------------+----------+
|
||||
| 1970-01-01T00:00:20 | 0.06666666666666667 | |
|
||||
+---------------------+---------------------+----------+
|
||||
|
||||
drop table metric_total;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Offset on a subquery shifts the subquery's own evaluation window back by the offset.
|
||||
-- Reference: Prometheus `evaluator.subqueryTimeRange` (promql/engine.go).
|
||||
-- The offset cases stay on the subquery step grid so they match Prometheus directly.
|
||||
create table subquery_offset_total (
|
||||
ts timestamp time index,
|
||||
host string primary key,
|
||||
val double,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into subquery_offset_total values
|
||||
(0, 'a', 1),
|
||||
(10000, 'a', 2),
|
||||
(20000, 'a', 3),
|
||||
(30000, 'a', 4),
|
||||
(40000, 'a', 5),
|
||||
(50000, 'a', 6),
|
||||
(60000, 'a', 7);
|
||||
|
||||
Affected Rows: 7
|
||||
|
||||
-- baseline: no offset at t=60 covers the 10s subquery points in (40s, 60s] -> 6 + 7
|
||||
tql eval (60, 60, '1s') sum_over_time(subquery_offset_total[20s:10s]);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 13.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- the same subquery evaluated at t=30 -> 3 + 4
|
||||
tql eval (30, 30, '1s') sum_over_time(subquery_offset_total[20s:10s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- `offset 30s` at t=60 must equal the un-offset subquery at t=30
|
||||
tql eval (60, 60, '1s') sum_over_time(subquery_offset_total[20s:10s] offset 30s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:01:00 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- a negative offset looks ahead of the evaluation time
|
||||
tql eval (30, 30, '1s') sum_over_time(subquery_offset_total[20s:10s] offset -30s);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:00:30 | 13.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- an offset on the inner selector composes additively with the subquery offset: Prometheus
|
||||
-- `subqueryTimes` accumulates "the sum of offsets and ranges of all subqueries in the path",
|
||||
-- and the inner selector subtracts its own offset from the already shifted step timestamps.
|
||||
-- 20s + 10s therefore behaves like the un-offset subquery at t=30.
|
||||
tql eval (60, 60, '1s') sum_over_time((subquery_offset_total offset 10s)[20s:10s] offset 20s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:01:00 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- ... and the inner offset alone accounts for the same total shift
|
||||
tql eval (60, 60, '1s') sum_over_time((subquery_offset_total offset 30s)[20s:10s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:01:00 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- `predict_linear` predicts from the evaluation time: 4 + 0.1 * 30 = 7 and 7 - 0.1 * 30 = 4
|
||||
tql eval (60, 60, '1s') predict_linear(subquery_offset_total[20s:10s] offset 30s, 0);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:01:00 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
tql eval (30, 30, '1s') predict_linear(subquery_offset_total[20s:10s] offset -30s, 0);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 4.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Offset results match the shifted evaluation while retaining outer timestamps.
|
||||
-- Verified against Prometheus v3.14.0.
|
||||
tql eval (30, 60, '30s') sum_over_time(subquery_offset_total[20s:10s] offset 30s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 1.0 | a | |
|
||||
| 1970-01-01T00:01:00 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
tql eval (0, 30, '30s') sum_over_time(subquery_offset_total[20s:10s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | a | |
|
||||
| 1970-01-01T00:00:30 | 7.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
drop table subquery_offset_total;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Off-grid samples expose absolute step anchoring.
|
||||
create table subquery_offset_offgrid (
|
||||
ts timestamp time index,
|
||||
host string primary key,
|
||||
val double,
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into subquery_offset_offgrid values
|
||||
(5000, 'a', 1),
|
||||
(15000, 'a', 2),
|
||||
(25000, 'a', 3),
|
||||
(35000, 'a', 4),
|
||||
(45000, 'a', 5),
|
||||
(55000, 'a', 6);
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
tql eval (30, 30, '1s') sum_over_time(subquery_offset_offgrid[20s:10s] offset 5s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 3.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Offset moves the window without re-phasing its step points.
|
||||
tql eval (30, 30, '1s') sum_over_time(subquery_offset_offgrid[20s:10s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 5.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- The window starts before the first sample.
|
||||
tql eval (30, 30, '1s') sum_over_time(subquery_offset_offgrid[20s:10s] offset 15s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 1.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
tql eval (15, 15, '1s') sum_over_time(subquery_offset_offgrid[20s:10s] offset -5s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:15 | 3.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- Multi-step evaluation uses the non-aligned parent timeline.
|
||||
tql eval (35, 65, '30s') sum_over_time(subquery_offset_offgrid[20s:10s]);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:00:35 | 5.0 | a | |
|
||||
| 1970-01-01T00:01:05 | 11.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- An evaluation instant whose window reaches no sample has no row (30s), unlike 60s -> 2 + 3
|
||||
tql eval (30, 60, '30s') sum_over_time(subquery_offset_offgrid[20s:10s] offset 30s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:01:00 | 5.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- No child point yields no row; the enclosing fallback still fires.
|
||||
tql eval (35, 44, '10s') sum_over_time(subquery_offset_offgrid[5s:10s]);
|
||||
|
||||
+----+----------------------------------+------+
|
||||
| ts | prom_sum_over_time(ts_range,val) | host |
|
||||
+----+----------------------------------+------+
|
||||
+----+----------------------------------+------+
|
||||
|
||||
tql eval (35, 44, '10s') sum_over_time(subquery_offset_offgrid[5s:10s]) or vector(1);
|
||||
|
||||
+---------------------+------+----------------------------------+
|
||||
| ts | host | prom_sum_over_time(ts_range,val) |
|
||||
+---------------------+------+----------------------------------+
|
||||
| 1970-01-01T00:00:35 | | 1.0 |
|
||||
+---------------------+------+----------------------------------+
|
||||
|
||||
-- A negative offset makes the short window reach a child point.
|
||||
tql eval (35, 44, '10s') sum_over_time(subquery_offset_offgrid[5s:10s] offset -5s);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:35 | 4.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- An empty outer window suppresses inner results, but not an outer fallback.
|
||||
tql eval (35, 44, '10s') sum_over_time((sum_over_time(subquery_offset_offgrid[5s:10s]))[5s:10s]);
|
||||
|
||||
+----+---------------------------------------------------------------+------+
|
||||
| ts | prom_sum_over_time(ts_range,prom_sum_over_time(ts_range,val)) | host |
|
||||
+----+---------------------------------------------------------------+------+
|
||||
+----+---------------------------------------------------------------+------+
|
||||
|
||||
tql eval (35, 44, '10s') sum_over_time((sum_over_time(subquery_offset_offgrid[5s:10s]))[5s:10s]) or vector(1);
|
||||
|
||||
+---------------------+------+---------------------------------------------------------------+
|
||||
| ts | host | prom_sum_over_time(ts_range,prom_sum_over_time(ts_range,val)) |
|
||||
+---------------------+------+---------------------------------------------------------------+
|
||||
| 1970-01-01T00:00:35 | | 1.0 |
|
||||
+---------------------+------+---------------------------------------------------------------+
|
||||
|
||||
-- An aligned instant has a child point in the same short range.
|
||||
tql eval (30, 30, '1s') sum_over_time(subquery_offset_offgrid[5s:10s]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:00:30 | 3.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
-- A longer range covers child steps on the off-grid parent timeline.
|
||||
tql eval (35, 65, '10s') sum_over_time(subquery_offset_offgrid[20s:10s]);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:00:35 | 5.0 | a | |
|
||||
| 1970-01-01T00:00:45 | 7.0 | a | |
|
||||
| 1970-01-01T00:00:55 | 9.0 | a | |
|
||||
| 1970-01-01T00:01:05 | 11.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- Zero step parses here but is invalid for planning.
|
||||
tql eval (60, 60, '1s') sum_over_time(subquery_offset_offgrid[5s:0]);
|
||||
|
||||
Error: 3000(PlanQuery), Internal error during building DataFusion plan: Error during planning: the subquery's step is 0ms, and a step has to be longer than zero
|
||||
|
||||
tql eval (44, 35, '10s') sum_over_time(subquery_offset_offgrid[5s:10s]);
|
||||
|
||||
Error: 1004(InvalidArguments), The end time must be greater than start time, start: 44000, end: 35000
|
||||
|
||||
drop table subquery_offset_offgrid;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/subquery.sql
|
||||
@@ -0,0 +1,53 @@
|
||||
-- A subquery without a step uses the evaluation interval (one minute by
|
||||
-- default in Prometheus), not the query step. Expected results are from Prometheus 3.
|
||||
create table subquery_default_step (
|
||||
ts timestamp time index,
|
||||
val double,
|
||||
host string primary key
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into subquery_default_step values
|
||||
(0, 1.0, 'a'),
|
||||
(60000, 1.0, 'a'),
|
||||
(120000, 1.0, 'a'),
|
||||
(180000, 1.0, 'a'),
|
||||
(240000, 1.0, 'a'),
|
||||
(300000, 1.0, 'a');
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
tql eval (300, 300, '1s') count_over_time(subquery_default_step[5m:]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:05:00 | 5.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
tql eval (300, 300, '1s') count_over_time(subquery_default_step[5m:30s]);
|
||||
|
||||
+---------------------+------+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+------+----------+
|
||||
| 1970-01-01T00:05:00 | 10.0 | a | |
|
||||
+---------------------+------+------+----------+
|
||||
|
||||
-- The outer range query keeps its own step around the subquery's default step.
|
||||
tql eval (300, 360, '15s') count_over_time(subquery_default_step[5m:]);
|
||||
|
||||
+---------------------+-----+------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+-----+------+----------+
|
||||
| 1970-01-01T00:05:00 | 5.0 | a | |
|
||||
| 1970-01-01T00:05:15 | 5.0 | a | |
|
||||
| 1970-01-01T00:05:30 | 5.0 | a | |
|
||||
| 1970-01-01T00:05:45 | 5.0 | a | |
|
||||
| 1970-01-01T00:06:00 | 5.0 | a | |
|
||||
+---------------------+-----+------+----------+
|
||||
|
||||
drop table subquery_default_step;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/subquery_default_step.sql
|
||||
@@ -0,0 +1,391 @@
|
||||
-- Test `time()` and related functions.
|
||||
-- Some cases are part of promql/testdata/functions.test, "Test time-related functions" section
|
||||
-- And others are from compliance test
|
||||
-- time() with itself or scalar
|
||||
tql eval (3000, 3000, '1s') time();
|
||||
|
||||
+---------------------+--------+
|
||||
| time | value |
|
||||
+---------------------+--------+
|
||||
| 1970-01-01T00:50:00 | 3000.0 |
|
||||
+---------------------+--------+
|
||||
|
||||
tql eval (0, 0, '1s') time();
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 0.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
tql eval (0.001, 1, '1s') time();
|
||||
|
||||
+-------------------------+-------+
|
||||
| time | value |
|
||||
+-------------------------+-------+
|
||||
| 1970-01-01T00:00:00.001 | 0.001 |
|
||||
+-------------------------+-------+
|
||||
|
||||
tql eval (0, 0, '1s') time() + 1;
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 1.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
tql eval (0, 0, '1s') 1 + time();
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 1.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
tql eval (10000, 10000, '1s') time() * time();
|
||||
|
||||
+---------------------+-------------+
|
||||
| time | value |
|
||||
+---------------------+-------------+
|
||||
| 1970-01-01T02:46:40 | 100000000.0 |
|
||||
+---------------------+-------------+
|
||||
|
||||
tql eval (10000, 10000, '1s') time() / time();
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T02:46:40 | 1.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
-- expect error: parse error: comparisons between scalars must use BOOL modifier
|
||||
tql eval (0, 0, '1s') time() < 1;
|
||||
|
||||
Error: 2000(InvalidSyntax), comparisons between scalars must use BOOL modifier
|
||||
|
||||
tql eval (0, 0, '1s') time() < bool 1;
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 1.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
tql eval (0, 0, '1s') time() > bool 1;
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:00:00 | 0.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
tql eval (1000, 1000, '1s') time() + time();
|
||||
|
||||
+---------------------+--------+
|
||||
| time | value |
|
||||
+---------------------+--------+
|
||||
| 1970-01-01T00:16:40 | 2000.0 |
|
||||
+---------------------+--------+
|
||||
|
||||
-- expect error: parse error: comparisons between scalars must use BOOL modifier
|
||||
tql eval (1000, 1000, '1s') time() == time();
|
||||
|
||||
Error: 2000(InvalidSyntax), comparisons between scalars must use BOOL modifier
|
||||
|
||||
tql eval (1000, 1000, '1s') time() == bool time();
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:16:40 | 1.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
tql eval (1000, 1000, '1s') time() != bool time();
|
||||
|
||||
+---------------------+-------+
|
||||
| time | value |
|
||||
+---------------------+-------+
|
||||
| 1970-01-01T00:16:40 | 0.0 |
|
||||
+---------------------+-------+
|
||||
|
||||
-- time() with table
|
||||
create table metrics (ts timestamp time index, val double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into metrics values (0, 0), (1000, 1), (2000, 2), (3000, 3);
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
tql eval (1, 2, '1s') time() + metrics;
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:01 | 2.0 | |
|
||||
| 1970-01-01T00:00:02 | 4.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 2, '1s') time() == metrics;
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:01 | 1.0 | metrics |
|
||||
| 1970-01-01T00:00:02 | 2.0 | metrics |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 2, '1s') time() == bool metrics;
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:01 | 1.0 | |
|
||||
| 1970-01-01T00:00:02 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 2, '1s') metrics + time();
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:01 | 2.0 | |
|
||||
| 1970-01-01T00:00:02 | 4.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 2, '1s') metrics == time();
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:01 | 1.0 | metrics |
|
||||
| 1970-01-01T00:00:02 | 2.0 | metrics |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (1, 2, '1s') metrics == bool time();
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:01 | 1.0 | |
|
||||
| 1970-01-01T00:00:02 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- other time-related functions
|
||||
tql eval (1, 2, '1s') hour();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:00:01 | 0.0 | |
|
||||
| 1970-01-01T00:00:02 | 0.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
tql eval (1, 2, '1s') hour(metrics);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:01 | 0.0 | |
|
||||
| 1970-01-01T00:00:02 | 0.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- 2023-12-01T06:43:43Z
|
||||
tql eval (1701413023, 1701413023, '1s') hour();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-12-01T06:43:43 | 6.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
tql eval (1701413023, 1701413023, '1s') hour(metrics);
|
||||
|
||||
+----+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+----+-----+----------+
|
||||
+----+-----+----------+
|
||||
|
||||
tql eval (1701413023, 1701413023, '1s') minute();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-12-01T06:43:43 | 43.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
tql eval (1701413023, 1701413023, '1s') month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-12-01T06:43:43 | 12.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
tql eval (1701413023, 1701413023, '1s') year();
|
||||
|
||||
+---------------------+--------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+--------+----------+
|
||||
| 2023-12-01T06:43:43 | 2023.0 | |
|
||||
+---------------------+--------+----------+
|
||||
|
||||
tql eval (1701413023, 1701413023, '1s') day_of_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-12-01T06:43:43 | 1.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
tql eval (1701413023, 1701413023, '1s') day_of_week();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-12-01T06:43:43 | 5.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
tql eval (1701413023, 1701413023, '1s') day_of_year();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-12-01T06:43:43 | 335.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2024-01-01T06:43:43Z leap year
|
||||
tql eval (1704091423, 1704091423, '1s') day_of_year();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2024-01-01T06:43:43 | 1.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-01-01T06:43:43Z
|
||||
tql eval (1672555423, 1672555423, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-01-01T06:43:43 | 31.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-02-01T06:43:43Z
|
||||
tql eval (1675233823, 1675233823, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-02-01T06:43:43 | 28.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2024-02-01T06:43:43Z leap year
|
||||
tql eval (1706769823, 1706769823, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2024-02-01T06:43:43 | 29.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-03-01T06:43:43Z
|
||||
tql eval (1677653023, 1677653023, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-03-01T06:43:43 | 31.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-04-01T06:43:43Z
|
||||
tql eval (1680331423, 1680331423, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-04-01T06:43:43 | 30.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-05-01T06:43:43Z
|
||||
tql eval (1682923423, 1682923423, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-05-01T06:43:43 | 31.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-06-01T06:43:43Z
|
||||
tql eval (1685601823, 1685601823, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-06-01T06:43:43 | 30.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-07-01T06:43:43Z
|
||||
tql eval (1688193823, 1688193823, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-07-01T06:43:43 | 31.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-08-01T06:43:43Z
|
||||
tql eval (1690872223, 1690872223, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-08-01T06:43:43 | 31.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-09-01T06:43:43Z
|
||||
tql eval (1693550623, 1693550623, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-09-01T06:43:43 | 30.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-10-01T06:43:43Z
|
||||
tql eval (1696142623, 1696142623, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-10-01T06:43:43 | 31.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-11-01T06:43:43Z
|
||||
tql eval (1698821023, 1698821023, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-11-01T06:43:43 | 30.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- 2023-12-01T06:43:43Z
|
||||
tql eval (1701413023, 1701413023, '1s') days_in_month();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| time | value | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 2023-12-01T06:43:43 | 31.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
drop table metrics;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/time_fn.sql
|
||||
@@ -0,0 +1,250 @@
|
||||
-- Test `timestamp()` function
|
||||
-- timestamp() returns the timestamp of each sample as seconds since Unix epoch
|
||||
create table timestamp_test (ts timestamp time index, val double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into timestamp_test values
|
||||
(0, 1.0),
|
||||
(1000, 2.0),
|
||||
(60000, 3.0),
|
||||
(3600000, 4.0),
|
||||
-- 2021-01-01 00:00:00
|
||||
(1609459200000, 5.0),
|
||||
-- 2021-01-01 00:01:00
|
||||
(1609459260000, 6.0);
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
-- Test timestamp() with time series
|
||||
tql eval (0, 3600, '30s') timestamp(timestamp_test);
|
||||
|
||||
+---------------------+--------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+--------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | |
|
||||
| 1970-01-01T00:01:00 | 60.0 | |
|
||||
| 1970-01-01T00:01:30 | 60.0 | |
|
||||
| 1970-01-01T00:02:00 | 60.0 | |
|
||||
| 1970-01-01T00:02:30 | 60.0 | |
|
||||
| 1970-01-01T00:03:00 | 60.0 | |
|
||||
| 1970-01-01T00:03:30 | 60.0 | |
|
||||
| 1970-01-01T00:04:00 | 60.0 | |
|
||||
| 1970-01-01T00:04:30 | 60.0 | |
|
||||
| 1970-01-01T00:05:00 | 60.0 | |
|
||||
| 1970-01-01T00:05:30 | 60.0 | |
|
||||
| 1970-01-01T01:00:00 | 3600.0 | |
|
||||
+---------------------+--------+----------+
|
||||
|
||||
-- Test timestamp() with specific time range
|
||||
tql eval (0, 60, '30s') timestamp(timestamp_test);
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | |
|
||||
| 1970-01-01T00:01:00 | 60.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
tql eval (0, 60, '30s') -timestamp(timestamp_test);
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | -0.0 | |
|
||||
| 1970-01-01T00:00:30 | -1.0 | |
|
||||
| 1970-01-01T00:01:00 | -60.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- Test timestamp() with 2021 data
|
||||
tql eval (1609459200, 1609459260, '30s') timestamp(timestamp_test);
|
||||
|
||||
+---------------------+--------------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+--------------+----------+
|
||||
| 2021-01-01T00:00:00 | 1609459200.0 | |
|
||||
| 2021-01-01T00:00:30 | 1609459200.0 | |
|
||||
| 2021-01-01T00:01:00 | 1609459260.0 | |
|
||||
+---------------------+--------------+----------+
|
||||
|
||||
-- Test timestamp() with arithmetic operations
|
||||
tql eval (0, 60, '30s') timestamp(timestamp_test) + 1;
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | |
|
||||
| 1970-01-01T00:00:30 | 2.0 | |
|
||||
| 1970-01-01T00:01:00 | 61.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
-- Test timestamp() with boolean operations
|
||||
tql eval (0, 60, '30s') timestamp(timestamp_test) > bool 30;
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:00:30 | 0.0 | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- Test timestamp() with time functions
|
||||
tql eval (0, 60, '30s') timestamp(timestamp_test) - time();
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:00:30 | -29.0 | |
|
||||
| 1970-01-01T00:01:00 | 0.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- Test timestamp() with other functions
|
||||
tql eval (0, 60, '30s') abs(timestamp(timestamp_test) - avg(timestamp(timestamp_test))) > 20;
|
||||
|
||||
+----+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+----+-----+----------+
|
||||
+----+-----+----------+
|
||||
|
||||
-- Test Issue 6707
|
||||
tql eval timestamp(demo_memory_usage_bytes * 1);
|
||||
|
||||
+------+-------+
|
||||
| time | value |
|
||||
+------+-------+
|
||||
+------+-------+
|
||||
|
||||
tql eval timestamp(-demo_memory_usage_bytes);
|
||||
|
||||
+------+-------+
|
||||
| time | value |
|
||||
+------+-------+
|
||||
+------+-------+
|
||||
|
||||
tql eval (0, 60, '30s') timestamp(timestamp_test) == 60;
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:01:00 | 60.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
-- timestamp() reports the timestamp of the selected sample, not the evaluation time
|
||||
tql eval (60, 60, '1s') timestamp(timestamp_test offset 30s);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
tql eval (60, 60, '1s') timestamp((timestamp_test offset 30s));
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- The result of a function is sampled at the evaluation time
|
||||
tql eval (90, 90, '1s') timestamp(abs(timestamp_test));
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:01:30 | 90.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
-- A row whose fields are all NULL holds no sample and gets no timestamp; a row with any
|
||||
-- non-NULL field does.
|
||||
create table timestamp_null (ts timestamp time index, host string primary key, a double, b double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into timestamp_null values
|
||||
(0, 'none', NULL, NULL),
|
||||
(0, 'only_a', 1.0, NULL),
|
||||
(0, 'only_b', NULL, 2.0);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') timestamp(timestamp_null);
|
||||
|
||||
+---------------------+-------+--------+
|
||||
| ts | value | host |
|
||||
+---------------------+-------+--------+
|
||||
| 1970-01-01T00:01:00 | 0.0 | only_a |
|
||||
| 1970-01-01T00:01:00 | 0.0 | only_b |
|
||||
+---------------------+-------+--------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') timestamp(-timestamp_null);
|
||||
|
||||
+---------------------+-------+--------+
|
||||
| ts | value | host |
|
||||
+---------------------+-------+--------+
|
||||
| 1970-01-01T00:01:00 | 60.0 | only_a |
|
||||
| 1970-01-01T00:01:00 | 60.0 | only_b |
|
||||
+---------------------+-------+--------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (60, 60, '1s') timestamp(abs(timestamp_null));
|
||||
|
||||
+---------------------+-------+--------+
|
||||
| ts | value | host |
|
||||
+---------------------+-------+--------+
|
||||
| 1970-01-01T00:01:00 | 60.0 | only_a |
|
||||
| 1970-01-01T00:01:00 | 60.0 | only_b |
|
||||
+---------------------+-------+--------+
|
||||
|
||||
drop table timestamp_null;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Test timestamp() with multiple metrics
|
||||
create table timestamp_test2 (ts timestamp time index, val double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into timestamp_test2 values
|
||||
(0, 10.0),
|
||||
(1000, 20.0),
|
||||
(60000, 30.0);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 60, '30s') timestamp(timestamp_test) + timestamp(timestamp_test2);
|
||||
|
||||
+---------------------+-------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:00:30 | 2.0 | |
|
||||
| 1970-01-01T00:01:00 | 120.0 | |
|
||||
+---------------------+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 60, '30s') timestamp(timestamp_test) == timestamp(timestamp_test2);
|
||||
|
||||
+---------------------+------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 0.0 | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | |
|
||||
| 1970-01-01T00:01:00 | 60.0 | |
|
||||
+---------------------+------+----------+
|
||||
|
||||
drop table timestamp_test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
drop table timestamp_test2;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/timestamp_fn.sql
|
||||
@@ -0,0 +1,406 @@
|
||||
CREATE TABLE counter_metric (
|
||||
host STRING NULL,
|
||||
device STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, device)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE gauge_metric (
|
||||
host STRING NULL,
|
||||
device STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, device)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO counter_metric VALUES
|
||||
('host1', 'eth0', 0, 10), ('host1', 'eth1', 0, 20), ('host2', 'eth0', 0, 30);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
INSERT INTO gauge_metric VALUES
|
||||
('host1', 'eth0', 0, 2), ('host1', 'eth1', 0, 4), ('host2', 'eth0', 0, 5);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- Matching on the whole tag set keeps it.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric / gauge_metric;
|
||||
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
| ts | greptime_value | host | device | __name__ |
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
| 1970-01-01T00:00:00 | 5.0 | host1 | eth0 | |
|
||||
| 1970-01-01T00:00:00 | 5.0 | host1 | eth1 | |
|
||||
| 1970-01-01T00:00:00 | 6.0 | host2 | eth0 | |
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
|
||||
-- `on(...)` reduces the result to the matching labels.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric{device="eth0"} / on(host) gauge_metric{device="eth0"};
|
||||
|
||||
+---------------------+----------------+-------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+----------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 5.0 | host1 | |
|
||||
| 1970-01-01T00:00:00 | 6.0 | host2 | |
|
||||
+---------------------+----------------+-------+----------+
|
||||
|
||||
-- `ignoring(...)` drops the ignored labels, here from operands that don't even share them.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric{device="eth0"} / ignoring(device) gauge_metric{device="eth1"};
|
||||
|
||||
+---------------------+----------------+-------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+----------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 2.5 | host1 | |
|
||||
+---------------------+----------------+-------+----------+
|
||||
|
||||
-- `on()` matches everything against everything, so both sides must hold a single series.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric{host="host1",device="eth0"} / on() gauge_metric{host="host1",device="eth0"};
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 5.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- A filtering comparison keeps the left sample values and the derived labels.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric{device="eth0"} > on(host) gauge_metric{device="eth0"};
|
||||
|
||||
+---------------------+----------------+-------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+----------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 10.0 | host1 | |
|
||||
| 1970-01-01T00:00:00 | 30.0 | host2 | |
|
||||
+---------------------+----------------+-------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric{device="eth0"} > bool on(host) gauge_metric{device="eth0"};
|
||||
|
||||
+---------------------+----------------+-------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+----------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.0 | host1 | |
|
||||
| 1970-01-01T00:00:00 | 1.0 | host2 | |
|
||||
+---------------------+----------------+-------+----------+
|
||||
|
||||
-- `host1` carries two devices on both sides: the match group repeats on the one side.
|
||||
TQL EVAL (0, 0, '5s') counter_metric / on(host) gauge_metric;
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: found duplicate series for the match group {host="host1"} on the right hand-side of the operation at 0 ms; many-to-many matching not allowed: matching labels must be unique on one side
|
||||
|
||||
-- The one side is unique here, the many side is not, and no group modifier makes it explicit.
|
||||
TQL EVAL (0, 0, '5s') counter_metric / on(host) gauge_metric{device="eth0"};
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: multiple matches for labels {host="host1"} at 0 ms: many-to-one matching must be explicit (group_left/group_right)
|
||||
|
||||
-- `group_left` takes the result labels from the many side.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric / on(host) group_left gauge_metric{device="eth0"};
|
||||
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
| ts | greptime_value | host | device | __name__ |
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
| 1970-01-01T00:00:00 | 10.0 | host1 | eth1 | |
|
||||
| 1970-01-01T00:00:00 | 5.0 | host1 | eth0 | |
|
||||
| 1970-01-01T00:00:00 | 6.0 | host2 | eth0 | |
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
|
||||
-- `group_right` swaps the sides.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric{device="eth0"} / on(host) group_right gauge_metric;
|
||||
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
| ts | greptime_value | host | device | __name__ |
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
| 1970-01-01T00:00:00 | 2.5 | host1 | eth1 | |
|
||||
| 1970-01-01T00:00:00 | 5.0 | host1 | eth0 | |
|
||||
| 1970-01-01T00:00:00 | 6.0 | host2 | eth0 | |
|
||||
+---------------------+----------------+-------+--------+----------+
|
||||
|
||||
-- `group_right` makes the left operand the one side, which `host1` breaks.
|
||||
TQL EVAL (0, 0, '5s') counter_metric / on(host) group_right gauge_metric{device="eth0"};
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: found duplicate series for the match group {host="host1"} on the left hand-side of the operation at 0 ms; many-to-many matching not allowed: matching labels must be unique on one side
|
||||
|
||||
-- `group_left(device)` copies `device` from the one side, so both `host1` rows end up with the
|
||||
-- same labels.
|
||||
TQL EVAL (0, 0, '5s') counter_metric / on(host) group_left(device) gauge_metric{device="eth0"};
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: multiple matches for labels {device="eth0", host="host1"} at 0 ms: grouping labels must ensure unique matches
|
||||
|
||||
-- An included label the one side doesn't carry is dropped from the result.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') counter_metric{device="eth0"} / on(host) group_left(device) sum by(host)(gauge_metric);
|
||||
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 1.6666666666666667 | host1 | |
|
||||
| 1970-01-01T00:00:00 | 6.0 | host2 | |
|
||||
+---------------------+--------------------+-------+----------+
|
||||
|
||||
DROP TABLE counter_metric;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE gauge_metric;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- A label can carry the name the cardinality check generates for its row count.
|
||||
CREATE TABLE collide_left (
|
||||
host STRING NULL,
|
||||
__promql_match_group_count STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, __promql_match_group_count)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE collide_right (
|
||||
host STRING NULL,
|
||||
__promql_match_group_count STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, __promql_match_group_count)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO collide_left VALUES ('host1', 'a', 0, 10);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
INSERT INTO collide_right VALUES ('host1', 'b', 0, 2);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
TQL EVAL (0, 0, '5s') collide_left / on(host) collide_right;
|
||||
|
||||
+---------------------+----------------+-------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+----------------+-------+----------+
|
||||
| 1970-01-01T00:00:00 | 5.0 | host1 | |
|
||||
+---------------------+----------------+-------+----------+
|
||||
|
||||
DROP TABLE collide_left;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE collide_right;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Partitioning on a column outside the match keys puts one match group in several regions. The
|
||||
-- cardinality check counts the merged data, so it must still see the duplicate.
|
||||
CREATE TABLE spread_left (
|
||||
host STRING NULL,
|
||||
device STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, device)
|
||||
)
|
||||
PARTITION ON COLUMNS (device) (
|
||||
device < 'eth1',
|
||||
device >= 'eth1'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE spread_right (
|
||||
host STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO spread_left VALUES ('host1', 'eth0', 0, 10), ('host1', 'eth1', 0, 20);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
INSERT INTO spread_right VALUES ('host1', 0, 2);
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
TQL EVAL (0, 0, '5s') spread_left / on(host) spread_right;
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: multiple matches for labels {host="host1"} at 0 ms: many-to-one matching must be explicit (group_left/group_right)
|
||||
|
||||
TQL EVAL (0, 0, '5s') spread_right / on(host) group_left spread_left;
|
||||
|
||||
Error: 3001(EngineExecuteQuery), Execution error: found duplicate series for the match group {host="host1"} on the right hand-side of the operation at 0 ms; many-to-many matching not allowed: matching labels must be unique on one side
|
||||
|
||||
DROP TABLE spread_left;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE spread_right;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- An outer aggregate groups on the labels the operand has left, not on the ones the scan
|
||||
-- underneath could still produce.
|
||||
CREATE TABLE outer_agg_a (
|
||||
host STRING NULL,
|
||||
device STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host, device)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE outer_agg_b (
|
||||
host STRING NULL,
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
PRIMARY KEY(host)
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO outer_agg_a VALUES ('h1', 'd1', 0, 10), ('h2', 'd2', 0, 20);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
INSERT INTO outer_agg_b VALUES ('h1', 0, 2), ('h2', 0, 4);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
-- `on(host)` leaves only `host`, so `without(host)` groups everything together.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') sum without(host) (outer_agg_a / on(host) outer_agg_b);
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 10.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- `device` is not a label of the operand any more, so it groups everything together too.
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') sum by(device) (outer_agg_a / on(host) outer_agg_b);
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 10.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') sum by(host) (outer_agg_a / on(host) outer_agg_b);
|
||||
|
||||
+---------------------+----------------+------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+----------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 5.0 | h1 | |
|
||||
| 1970-01-01T00:00:00 | 5.0 | h2 | |
|
||||
+---------------------+----------------+------+----------+
|
||||
|
||||
DROP TABLE outer_agg_a;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE outer_agg_b;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Same over the metric engine, whose operands carry `__tsid`.
|
||||
CREATE TABLE outer_agg_physical (
|
||||
ts TIMESTAMP(3) TIME INDEX,
|
||||
greptime_value DOUBLE,
|
||||
) ENGINE = metric WITH ("physical_metric_table" = "");
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE outer_agg_metric_a (
|
||||
host STRING NULL,
|
||||
device STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(host, device),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'outer_agg_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE outer_agg_metric_b (
|
||||
host STRING NULL,
|
||||
ts TIMESTAMP(3) NOT NULL,
|
||||
greptime_value DOUBLE NULL,
|
||||
TIME INDEX (ts),
|
||||
PRIMARY KEY(host),
|
||||
)
|
||||
ENGINE = metric
|
||||
WITH(
|
||||
on_physical_table = 'outer_agg_physical'
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO outer_agg_metric_a (host, device, ts, greptime_value) VALUES
|
||||
('h1', 'd1', 0, 10), ('h2', 'd2', 0, 20);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
INSERT INTO outer_agg_metric_b (host, ts, greptime_value) VALUES
|
||||
('h1', 0, 2), ('h2', 0, 4);
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') sum without(host) (outer_agg_metric_a / on(host) outer_agg_metric_b);
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 10.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') sum by(device) (outer_agg_metric_a / on(host) outer_agg_metric_b);
|
||||
|
||||
+---------------------+----------------+----------+
|
||||
| ts | greptime_value | __name__ |
|
||||
+---------------------+----------------+----------+
|
||||
| 1970-01-01T00:00:00 | 10.0 | |
|
||||
+---------------------+----------------+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
TQL EVAL (0, 0, '5s') sum by(host) (outer_agg_metric_a / on(host) outer_agg_metric_b);
|
||||
|
||||
+---------------------+----------------+------+----------+
|
||||
| ts | greptime_value | host | __name__ |
|
||||
+---------------------+----------------+------+----------+
|
||||
| 1970-01-01T00:00:00 | 5.0 | h1 | |
|
||||
| 1970-01-01T00:00:00 | 5.0 | h2 | |
|
||||
+---------------------+----------------+------+----------+
|
||||
|
||||
DROP TABLE outer_agg_metric_a;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE outer_agg_metric_b;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
DROP TABLE outer_agg_physical;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/promql/vector_matching.sql
|
||||
@@ -0,0 +1,497 @@
|
||||
-- Port from Prometheus `promql/promqltest/testdata/functions.test`.
|
||||
-- Include stddev/stdvar over time
|
||||
-- load 10s
|
||||
-- metric 0 8 8 2 3
|
||||
create table metric (ts timestamp(3) time index, val double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into metric values
|
||||
(0,0),
|
||||
(10000,8),
|
||||
(20000,8),
|
||||
(30000,2),
|
||||
(40000,3);
|
||||
|
||||
Affected Rows: 5
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
select * from metric;
|
||||
|
||||
+---------------------+-----+
|
||||
| ts | val |
|
||||
+---------------------+-----+
|
||||
| 1970-01-01T00:00:00 | 0.0 |
|
||||
| 1970-01-01T00:00:10 | 8.0 |
|
||||
| 1970-01-01T00:00:20 | 8.0 |
|
||||
| 1970-01-01T00:00:30 | 2.0 |
|
||||
| 1970-01-01T00:00:40 | 3.0 |
|
||||
+---------------------+-----+
|
||||
|
||||
-- eval instant at 1m stdvar_over_time(metric[2m])
|
||||
-- {} 10.56
|
||||
tql eval (60, 60, '1s') stdvar_over_time(metric[2m]);
|
||||
|
||||
+---------------------+--------------------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+--------------------+----------+
|
||||
| 1970-01-01T00:01:00 | 10.559999999999999 | |
|
||||
+---------------------+--------------------+----------+
|
||||
|
||||
-- eval instant at 1m stddev_over_time(metric[2m])
|
||||
-- {} 3.249615
|
||||
tql eval (60, 60, '1s') stddev_over_time(metric[2m]);
|
||||
|
||||
+---------------------+-------------------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------------------+----------+
|
||||
| 1970-01-01T00:01:00 | 3.249615361854384 | |
|
||||
+---------------------+-------------------+----------+
|
||||
|
||||
-- eval instant at 1m stddev_over_time((metric[2m]))
|
||||
-- {} 3.249615
|
||||
tql eval (60, 60, '1s') stddev_over_time((metric[2m]));
|
||||
|
||||
+---------------------+-------------------+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-------------------+----------+
|
||||
| 1970-01-01T00:01:00 | 3.249615361854384 | |
|
||||
+---------------------+-------------------+----------+
|
||||
|
||||
drop table metric;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- load 10s
|
||||
-- metric 1.5990505637277868 1.5990505637277868 1.5990505637277868
|
||||
create table metric (ts timestamp(3) time index, val double);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into metric values
|
||||
(0,1.5990505637277868),
|
||||
(10000,1.5990505637277868),
|
||||
(20000,1.5990505637277868);
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- eval instant at 55s stdvar_over_time(metric[1m])
|
||||
-- {} 0
|
||||
tql eval (55, 55, '1s') stdvar_over_time(metric[1m]);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:55 | 0.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
-- eval instant at 55s stddev_over_time(metric[1m])
|
||||
-- {} 0
|
||||
tql eval (55, 55, '1s') stddev_over_time(metric[1m]);
|
||||
|
||||
+---------------------+-----+----------+
|
||||
| ts | val | __name__ |
|
||||
+---------------------+-----+----------+
|
||||
| 1970-01-01T00:00:55 | 0.0 | |
|
||||
+---------------------+-----+----------+
|
||||
|
||||
drop table metric;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Port from functions.test L632 - L680, commit 001ee2620e094970e5657ce39275b2fccdbd1359
|
||||
-- Include quantile over time
|
||||
-- load 10s
|
||||
-- data{test="two samples"} 0 1
|
||||
-- data{test="three samples"} 0 1 2
|
||||
-- data{test="uneven samples"} 0 1 4
|
||||
create table data (ts timestamp(3) time index, val double, test string primary key);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into data values
|
||||
(0, 0, "two samples"),
|
||||
(10000, 1, "two samples"),
|
||||
(0, 0, "three samples"),
|
||||
(10000, 1, "three samples"),
|
||||
(20000, 2, "three samples"),
|
||||
(0, 0, "uneven samples"),
|
||||
(10000, 1, "uneven samples"),
|
||||
(20000, 4, "uneven samples");
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
-- eval instant at 1m quantile_over_time(0, data[2m])
|
||||
-- {test="two samples"} 0
|
||||
-- {test="three samples"} 0
|
||||
-- {test="uneven samples"} 0
|
||||
--
|
||||
-- Prometheus `v3.9.1` updates these cases to use a larger range to avoid the (t-r) boundary.
|
||||
-- See PR #13904 ("left-open and right-closed lookback/matrix selections").
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') quantile_over_time(0, data[2m]);
|
||||
|
||||
+---------------------+-----+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+-----+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.0 | three samples | |
|
||||
| 1970-01-01T00:01:00 | 0.0 | two samples | |
|
||||
| 1970-01-01T00:01:00 | 0.0 | uneven samples | |
|
||||
+---------------------+-----+----------------+----------+
|
||||
|
||||
-- eval instant at 1m quantile_over_time(0.5, data[2m])
|
||||
-- {test="two samples"} 0.5
|
||||
-- {test="three samples"} 1
|
||||
-- {test="uneven samples"} 1
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') quantile_over_time(0.5, data[2m]);
|
||||
|
||||
+---------------------+-----+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+-----+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.5 | two samples | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | three samples | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | uneven samples | |
|
||||
+---------------------+-----+----------------+----------+
|
||||
|
||||
-- eval instant at 1m quantile_over_time(0.75, data[2m])
|
||||
-- {test="two samples"} 0.75
|
||||
-- {test="three samples"} 1.5
|
||||
-- {test="uneven samples"} 2.5
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') quantile_over_time(0.75, data[2m]);
|
||||
|
||||
+---------------------+------+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+------+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.75 | two samples | |
|
||||
| 1970-01-01T00:01:00 | 1.5 | three samples | |
|
||||
| 1970-01-01T00:01:00 | 2.5 | uneven samples | |
|
||||
+---------------------+------+----------------+----------+
|
||||
|
||||
-- eval instant at 1m quantile_over_time(0.8, data[2m])
|
||||
-- {test="two samples"} 0.8
|
||||
-- {test="three samples"} 1.6
|
||||
-- {test="uneven samples"} 2.8
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') quantile_over_time(0.8, data[2m]);
|
||||
|
||||
+---------------------+--------------------+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+--------------------+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.8 | two samples | |
|
||||
| 1970-01-01T00:01:00 | 1.6 | three samples | |
|
||||
| 1970-01-01T00:01:00 | 2.8000000000000003 | uneven samples | |
|
||||
+---------------------+--------------------+----------------+----------+
|
||||
|
||||
-- eval instant at 1m quantile_over_time(1, data[2m])
|
||||
-- {test="two samples"} 1
|
||||
-- {test="three samples"} 2
|
||||
-- {test="uneven samples"} 4
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') quantile_over_time(1, data[2m]);
|
||||
|
||||
+---------------------+-----+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+-----+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | two samples | |
|
||||
| 1970-01-01T00:01:00 | 2.0 | three samples | |
|
||||
| 1970-01-01T00:01:00 | 4.0 | uneven samples | |
|
||||
+---------------------+-----+----------------+----------+
|
||||
|
||||
-- eval instant at 1m quantile_over_time(-1, data[2m])
|
||||
-- {test="two samples"} -Inf
|
||||
-- {test="three samples"} -Inf
|
||||
-- {test="uneven samples"} -Inf
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') quantile_over_time(-1, data[2m]);
|
||||
|
||||
+---------------------+------+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+------+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | -inf | three samples | |
|
||||
| 1970-01-01T00:01:00 | -inf | two samples | |
|
||||
| 1970-01-01T00:01:00 | -inf | uneven samples | |
|
||||
+---------------------+------+----------------+----------+
|
||||
|
||||
-- eval instant at 1m quantile_over_time(2, data[2m])
|
||||
-- {test="two samples"} +Inf
|
||||
-- {test="three samples"} +Inf
|
||||
-- {test="uneven samples"} +Inf
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') quantile_over_time(2, data[2m]);
|
||||
|
||||
+---------------------+-----+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+-----+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | inf | three samples | |
|
||||
| 1970-01-01T00:01:00 | inf | two samples | |
|
||||
| 1970-01-01T00:01:00 | inf | uneven samples | |
|
||||
+---------------------+-----+----------------+----------+
|
||||
|
||||
-- eval instant at 1m (quantile_over_time(2, (data[2m])))
|
||||
-- {test="two samples"} +Inf
|
||||
-- {test="three samples"} +Inf
|
||||
-- {test="uneven samples"} +Inf
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') (quantile_over_time(2, (data[2m])));
|
||||
|
||||
+---------------------+-----+----------------+----------+
|
||||
| ts | val | test | __name__ |
|
||||
+---------------------+-----+----------------+----------+
|
||||
| 1970-01-01T00:01:00 | inf | three samples | |
|
||||
| 1970-01-01T00:01:00 | inf | two samples | |
|
||||
| 1970-01-01T00:01:00 | inf | uneven samples | |
|
||||
+---------------------+-----+----------------+----------+
|
||||
|
||||
drop table data;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Port from functions.test L773 - L802, commit 001ee2620e094970e5657ce39275b2fccdbd1359
|
||||
-- Include max/min/last over time
|
||||
-- load 10s
|
||||
-- data{type="numbers"} 2 0 3
|
||||
-- data{type="some_nan"} 2 0 NaN
|
||||
-- data{type="some_nan2"} 2 NaN 1
|
||||
-- data{type="some_nan3"} NaN 0 1
|
||||
-- data{type="only_nan"} NaN NaN NaN
|
||||
create table data (ts timestamp(3) time index, val double, ty string primary key);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into data values
|
||||
(0, 2::double, 'numbers'),
|
||||
(10000, 0::double, 'numbers'),
|
||||
(20000, 3::double, 'numbers'),
|
||||
(0, 2::double, 'some_nan'),
|
||||
(10000, 0::double, 'some_nan'),
|
||||
(20000, 'NaN'::double, 'some_nan'),
|
||||
(0, 2::double, 'some_nan2'),
|
||||
(10000, 'NaN'::double, 'some_nan2'),
|
||||
(20000, 1::double, 'some_nan2'),
|
||||
(0, 'NaN'::double, 'some_nan3'),
|
||||
(10000, 0::double, 'some_nan3'),
|
||||
(20000, 1::double, 'some_nan3'),
|
||||
(0, 'NaN'::double, 'only_nan'),
|
||||
(10000, 'NaN'::double, 'only_nan'),
|
||||
(20000, 'NaN'::double, 'only_nan');
|
||||
|
||||
Affected Rows: 15
|
||||
|
||||
-- eval instant at 1m min_over_time(data[2m])
|
||||
-- {type="numbers"} 0
|
||||
-- {type="some_nan"} 0
|
||||
-- {type="some_nan2"} 1
|
||||
-- {type="some_nan3"} 0
|
||||
-- {type="only_nan"} NaN
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') min_over_time(data[2m]);
|
||||
|
||||
+---------------------+-----+-----------+----------+
|
||||
| ts | val | ty | __name__ |
|
||||
+---------------------+-----+-----------+----------+
|
||||
| 1970-01-01T00:01:00 | 0.0 | numbers | |
|
||||
| 1970-01-01T00:01:00 | 0.0 | some_nan | |
|
||||
| 1970-01-01T00:01:00 | 0.0 | some_nan3 | |
|
||||
| 1970-01-01T00:01:00 | 1.0 | some_nan2 | |
|
||||
| 1970-01-01T00:01:00 | NaN | only_nan | |
|
||||
+---------------------+-----+-----------+----------+
|
||||
|
||||
-- eval instant at 1m max_over_time(data[2m])
|
||||
-- {type="numbers"} 3
|
||||
-- {type="some_nan"} 2
|
||||
-- {type="some_nan2"} 2
|
||||
-- {type="some_nan3"} 1
|
||||
-- {type="only_nan"} NaN
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') max_over_time(data[2m]);
|
||||
|
||||
+---------------------+-----+-----------+----------+
|
||||
| ts | val | ty | __name__ |
|
||||
+---------------------+-----+-----------+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | some_nan3 | |
|
||||
| 1970-01-01T00:01:00 | 2.0 | some_nan | |
|
||||
| 1970-01-01T00:01:00 | 2.0 | some_nan2 | |
|
||||
| 1970-01-01T00:01:00 | 3.0 | numbers | |
|
||||
| 1970-01-01T00:01:00 | NaN | only_nan | |
|
||||
+---------------------+-----+-----------+----------+
|
||||
|
||||
-- eval instant at 1m last_over_time(data[2m])
|
||||
-- data{type="numbers"} 3
|
||||
-- data{type="some_nan"} NaN
|
||||
-- data{type="some_nan2"} 1
|
||||
-- data{type="some_nan3"} 1
|
||||
-- data{type="only_nan"} NaN
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (60, 60, '1s') last_over_time(data[2m]);
|
||||
|
||||
+---------------------+-----+-----------+----------+
|
||||
| ts | val | ty | __name__ |
|
||||
+---------------------+-----+-----------+----------+
|
||||
| 1970-01-01T00:01:00 | 1.0 | some_nan2 | data |
|
||||
| 1970-01-01T00:01:00 | 1.0 | some_nan3 | data |
|
||||
| 1970-01-01T00:01:00 | 3.0 | numbers | data |
|
||||
| 1970-01-01T00:01:00 | NaN | only_nan | data |
|
||||
| 1970-01-01T00:01:00 | NaN | some_nan | data |
|
||||
+---------------------+-----+-----------+----------+
|
||||
|
||||
drop table data;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Sliding min/max regression: overlapping 30s windows expire extrema at the
|
||||
-- left boundary, retain equal extrema, and end with a sparse empty window.
|
||||
create table moving_extrema (ts timestamp(3) time index, val double, series string primary key);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into moving_extrema values
|
||||
(0, 5::double, 'moving'),
|
||||
(10000, 1::double, 'moving'),
|
||||
(20000, 4::double, 'moving'),
|
||||
(30000, 4::double, 'moving'),
|
||||
(40000, 2::double, 'moving'),
|
||||
(60000, 3::double, 'moving');
|
||||
|
||||
Affected Rows: 6
|
||||
|
||||
-- eval range from 20s to 100s min_over_time(moving_extrema[30s]); 90s and 100s are empty.
|
||||
-- {series="moving"} 1 1 2 2 2 3 3
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (20, 100, '10s') min_over_time(moving_extrema[30s]);
|
||||
|
||||
+---------------------+-----+--------+----------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+-----+--------+----------+
|
||||
| 1970-01-01T00:00:20 | 1.0 | moving | |
|
||||
| 1970-01-01T00:00:30 | 1.0 | moving | |
|
||||
| 1970-01-01T00:00:40 | 2.0 | moving | |
|
||||
| 1970-01-01T00:00:50 | 2.0 | moving | |
|
||||
| 1970-01-01T00:01:00 | 2.0 | moving | |
|
||||
| 1970-01-01T00:01:10 | 3.0 | moving | |
|
||||
| 1970-01-01T00:01:20 | 3.0 | moving | |
|
||||
+---------------------+-----+--------+----------+
|
||||
|
||||
-- eval range from 20s to 100s max_over_time(moving_extrema[30s]); 90s and 100s are empty.
|
||||
-- {series="moving"} 5 4 4 4 3 3 3
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (20, 100, '10s') max_over_time(moving_extrema[30s]);
|
||||
|
||||
+---------------------+-----+--------+----------+
|
||||
| ts | val | series | __name__ |
|
||||
+---------------------+-----+--------+----------+
|
||||
| 1970-01-01T00:00:20 | 5.0 | moving | |
|
||||
| 1970-01-01T00:00:30 | 4.0 | moving | |
|
||||
| 1970-01-01T00:00:40 | 4.0 | moving | |
|
||||
| 1970-01-01T00:00:50 | 4.0 | moving | |
|
||||
| 1970-01-01T00:01:00 | 3.0 | moving | |
|
||||
| 1970-01-01T00:01:10 | 3.0 | moving | |
|
||||
| 1970-01-01T00:01:20 | 3.0 | moving | |
|
||||
+---------------------+-----+--------+----------+
|
||||
|
||||
drop table moving_extrema;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Dense sliding min/max: 40-sample windows advancing 5 samples, the shape the UDF
|
||||
-- reuses candidates for rather than rescanning. Values follow the timestamp, so each
|
||||
-- window's minimum is its oldest sample and its maximum is its newest, and both
|
||||
-- extrema expire on every step.
|
||||
create table dense_extrema (ts timestamp_s time index, val double, series string primary key);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into dense_extrema values (0, 0::double, 'dense');
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
-- Doubling eight times gives 256 rows at a one-second cadence, with val = ts.
|
||||
insert into dense_extrema select to_unixtime(ts) + 1, val + 1, series from dense_extrema;
|
||||
|
||||
Affected Rows: 1
|
||||
|
||||
insert into dense_extrema select to_unixtime(ts) + 2, val + 2, series from dense_extrema;
|
||||
|
||||
Affected Rows: 2
|
||||
|
||||
insert into dense_extrema select to_unixtime(ts) + 4, val + 4, series from dense_extrema;
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
insert into dense_extrema select to_unixtime(ts) + 8, val + 8, series from dense_extrema;
|
||||
|
||||
Affected Rows: 8
|
||||
|
||||
insert into dense_extrema select to_unixtime(ts) + 16, val + 16, series from dense_extrema;
|
||||
|
||||
Affected Rows: 16
|
||||
|
||||
insert into dense_extrema select to_unixtime(ts) + 32, val + 32, series from dense_extrema;
|
||||
|
||||
Affected Rows: 32
|
||||
|
||||
insert into dense_extrema select to_unixtime(ts) + 64, val + 64, series from dense_extrema;
|
||||
|
||||
Affected Rows: 64
|
||||
|
||||
insert into dense_extrema select to_unixtime(ts) + 128, val + 128, series from dense_extrema;
|
||||
|
||||
Affected Rows: 128
|
||||
|
||||
select count(*), min(val), max(val) from dense_extrema;
|
||||
|
||||
+----------+------------------------+------------------------+
|
||||
| count(*) | min(dense_extrema.val) | max(dense_extrema.val) |
|
||||
+----------+------------------------+------------------------+
|
||||
| 256 | 0.0 | 255.0 |
|
||||
+----------+------------------------+------------------------+
|
||||
|
||||
-- {series="dense"} 61 66 71 76 81 86 91 96 101 106 111 116 121
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (100, 160, '5s') min_over_time(dense_extrema[40s]);
|
||||
|
||||
+---------------------+----------------------------------+--------+
|
||||
| ts | prom_min_over_time(ts_range,val) | series |
|
||||
+---------------------+----------------------------------+--------+
|
||||
| 1970-01-01T00:01:40 | 61.0 | dense |
|
||||
| 1970-01-01T00:01:45 | 66.0 | dense |
|
||||
| 1970-01-01T00:01:50 | 71.0 | dense |
|
||||
| 1970-01-01T00:01:55 | 76.0 | dense |
|
||||
| 1970-01-01T00:02:00 | 81.0 | dense |
|
||||
| 1970-01-01T00:02:05 | 86.0 | dense |
|
||||
| 1970-01-01T00:02:10 | 91.0 | dense |
|
||||
| 1970-01-01T00:02:15 | 96.0 | dense |
|
||||
| 1970-01-01T00:02:20 | 101.0 | dense |
|
||||
| 1970-01-01T00:02:25 | 106.0 | dense |
|
||||
| 1970-01-01T00:02:30 | 111.0 | dense |
|
||||
| 1970-01-01T00:02:35 | 116.0 | dense |
|
||||
| 1970-01-01T00:02:40 | 121.0 | dense |
|
||||
+---------------------+----------------------------------+--------+
|
||||
|
||||
-- {series="dense"} 100 105 110 115 120 125 130 135 140 145 150 155 160
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
tql eval (100, 160, '5s') max_over_time(dense_extrema[40s]);
|
||||
|
||||
+---------------------+----------------------------------+--------+
|
||||
| ts | prom_max_over_time(ts_range,val) | series |
|
||||
+---------------------+----------------------------------+--------+
|
||||
| 1970-01-01T00:01:40 | 100.0 | dense |
|
||||
| 1970-01-01T00:01:45 | 105.0 | dense |
|
||||
| 1970-01-01T00:01:50 | 110.0 | dense |
|
||||
| 1970-01-01T00:01:55 | 115.0 | dense |
|
||||
| 1970-01-01T00:02:00 | 120.0 | dense |
|
||||
| 1970-01-01T00:02:05 | 125.0 | dense |
|
||||
| 1970-01-01T00:02:10 | 130.0 | dense |
|
||||
| 1970-01-01T00:02:15 | 135.0 | dense |
|
||||
| 1970-01-01T00:02:20 | 140.0 | dense |
|
||||
| 1970-01-01T00:02:25 | 145.0 | dense |
|
||||
| 1970-01-01T00:02:30 | 150.0 | dense |
|
||||
| 1970-01-01T00:02:35 | 155.0 | dense |
|
||||
| 1970-01-01T00:02:40 | 160.0 | dense |
|
||||
+---------------------+----------------------------------+--------+
|
||||
|
||||
drop table dense_extrema;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/tql/aggr_over_time.sql
|
||||
@@ -0,0 +1,393 @@
|
||||
CREATE TABLE test(i DOUBLE, j TIMESTAMP TIME INDEX, k STRING PRIMARY KEY);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- insert two points at 1ms and one point at 2ms
|
||||
INSERT INTO test VALUES (1, 1, "a"), (1, 1, "b"), (2, 2, "a");
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
-- evaluate at 0s, 5s and 10s. No point at 0s.
|
||||
TQL EVAL (0, 10, '5s') test;
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:05 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') {__name__="test"};
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:05 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') {__name__="test"} AS test_series;
|
||||
|
||||
+-------------+---+---------------------+
|
||||
| test_series | k | j |
|
||||
+-------------+---+---------------------+
|
||||
| 1.0 | b | 1970-01-01T00:00:05 |
|
||||
| 1.0 | b | 1970-01-01T00:00:10 |
|
||||
| 2.0 | a | 1970-01-01T00:00:05 |
|
||||
| 2.0 | a | 1970-01-01T00:00:10 |
|
||||
+-------------+---+---------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') count by (k) (test) AS c;
|
||||
|
||||
+---+---+---------------------+
|
||||
| c | k | j |
|
||||
+---+---+---------------------+
|
||||
| 1 | a | 1970-01-01T00:00:05 |
|
||||
| 1 | a | 1970-01-01T00:00:10 |
|
||||
| 1 | b | 1970-01-01T00:00:05 |
|
||||
| 1 | b | 1970-01-01T00:00:10 |
|
||||
+---+---+---------------------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') test{__schema__="public"};
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:05 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') test{__schema__="greptime_private"};
|
||||
|
||||
+------+-------+
|
||||
| time | value |
|
||||
+------+-------+
|
||||
+------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') test{__database__="public"};
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:05 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') test{__database__="greptime_private"};
|
||||
|
||||
+------+-------+
|
||||
| time | value |
|
||||
+------+-------+
|
||||
+------+-------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') {__name__="test", __field__="i"};
|
||||
|
||||
+-----+---+---------------------+
|
||||
| i | k | j |
|
||||
+-----+---+---------------------+
|
||||
| 1.0 | b | 1970-01-01T00:00:05 |
|
||||
| 1.0 | b | 1970-01-01T00:00:10 |
|
||||
| 2.0 | a | 1970-01-01T00:00:05 |
|
||||
| 2.0 | a | 1970-01-01T00:00:10 |
|
||||
+-----+---+---------------------+
|
||||
|
||||
-- NOT SUPPORTED: `__name__` matcher without equal condition
|
||||
TQL EVAL (0, 10, '5s') {__name__!="test"};
|
||||
|
||||
Error: 2000(InvalidSyntax), vector selector must contain at least one non-empty matcher
|
||||
|
||||
TQL EVAL (0, 10, '5s') {__name__=~"test"};
|
||||
|
||||
Error: 1004(InvalidArguments), Matcher operator =~ is not supported for __name__
|
||||
|
||||
-- the point at 1ms will be shadowed by the point at 2ms
|
||||
TQL EVAL (0, 10, '5s') test{k="a"};
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
TQL EVAL (0, 10, '1s', '2s') test{k="a"};
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:01 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:02 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '0.5') test;
|
||||
|
||||
+-------------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+-------------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:00.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:00.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:01 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:01 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:01.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:01.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:02 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:02 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:02.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:02.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:03 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:03 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:03.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:03.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:04 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:04 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:04.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:04.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:05 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:05.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:06 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:06 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:06.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:06.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:07 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:07 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:07.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:07.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:08 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:08 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:08.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:08.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:09 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:09 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:09.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:09.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+-------------------------+-----+---+----------+
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, 0.5) test;
|
||||
|
||||
+-------------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+-------------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:00.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:00.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:01 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:01 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:01.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:01.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:02 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:02 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:02.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:02.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:03 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:03 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:03.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:03.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:04 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:04 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:04.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:04.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:05 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:05.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:05.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:06 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:06 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:06.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:06.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:07 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:07 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:07.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:07.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:08 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:08 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:08.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:08.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:09 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:09 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:09.500 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:09.500 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 1.0 | b | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+-------------------------+-----+---+----------+
|
||||
|
||||
TQL EVAL ('1970-01-01T00:00:00'::timestamp, '1970-01-01T00:00:00'::timestamp + '10 seconds'::interval, '1s') test{k="a"};
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:01 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:02 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:03 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:04 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:06 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:07 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:08 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:09 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
TQL EVAL (now() - now(), now() - (now() - '10 seconds'::interval), '1s') test{k="a"};
|
||||
|
||||
+---------------------+-----+---+----------+
|
||||
| j | i | k | __name__ |
|
||||
+---------------------+-----+---+----------+
|
||||
| 1970-01-01T00:00:01 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:02 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:03 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:04 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:05 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:06 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:07 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:08 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:09 | 2.0 | a | test |
|
||||
| 1970-01-01T00:00:10 | 2.0 | a | test |
|
||||
+---------------------+-----+---+----------+
|
||||
|
||||
DROP TABLE test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE test (`Field_I` DOUBLE, `Ts_J` TIMESTAMP TIME INDEX, `Tag_K` STRING PRIMARY KEY);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test VALUES (1, 1, "a"), (1, 1, "b"), (2, 2, "a");
|
||||
|
||||
Affected Rows: 3
|
||||
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (0, 10, '5s') test{__field__="Field_I"};
|
||||
|
||||
+---------+-------+---------------------+
|
||||
| Field_I | Tag_K | Ts_J |
|
||||
+---------+-------+---------------------+
|
||||
| 1.0 | b | 1970-01-01T00:00:05 |
|
||||
| 1.0 | b | 1970-01-01T00:00:10 |
|
||||
| 2.0 | a | 1970-01-01T00:00:05 |
|
||||
| 2.0 | a | 1970-01-01T00:00:10 |
|
||||
+---------+-------+---------------------+
|
||||
|
||||
TQL EVAL (0, 10, '5s') test{__field__="field_i"};
|
||||
|
||||
Error: 1004(InvalidArguments), Cannot find column field_i
|
||||
|
||||
drop table test;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
CREATE TABLE metrics(val DOUBLE, ts TIMESTAMP TIME INDEX, host STRING PRIMARY KEY);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
-- Insert sample data with fixed timestamps for predictable testing
|
||||
INSERT INTO metrics VALUES
|
||||
(10.0, '2024-01-01 00:00:00', 'host1'),
|
||||
(15.0, '2024-01-01 06:00:00', 'host1'),
|
||||
(20.0, '2024-01-01 12:00:00', 'host1'),
|
||||
(25.0, '2024-01-01 18:00:00', 'host1'),
|
||||
(30.0, '2024-01-02 00:00:00', 'host1'),
|
||||
(35.0, '2024-01-02 06:00:00', 'host1'),
|
||||
(40.0, '2024-01-02 12:00:00', 'host1'),
|
||||
(12.0, '2024-01-01 02:00:00', 'host2'),
|
||||
(18.0, '2024-01-01 08:00:00', 'host2'),
|
||||
(22.0, '2024-01-01 14:00:00', 'host2');
|
||||
|
||||
Affected Rows: 10
|
||||
|
||||
-- Test TQL with date_trunc function
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (date_trunc('day', '2024-01-01 10:00:00'::timestamp),
|
||||
date_trunc('day', '2024-01-02 10:00:00'::timestamp),
|
||||
'6h') last_over_time(metrics[12h]);
|
||||
|
||||
+---------------------+------+-------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+-------+----------+
|
||||
| 2024-01-01T00:00:00 | 10.0 | host1 | metrics |
|
||||
| 2024-01-01T06:00:00 | 12.0 | host2 | metrics |
|
||||
| 2024-01-01T06:00:00 | 15.0 | host1 | metrics |
|
||||
| 2024-01-01T12:00:00 | 18.0 | host2 | metrics |
|
||||
| 2024-01-01T12:00:00 | 20.0 | host1 | metrics |
|
||||
| 2024-01-01T18:00:00 | 22.0 | host2 | metrics |
|
||||
| 2024-01-01T18:00:00 | 25.0 | host1 | metrics |
|
||||
| 2024-01-02T00:00:00 | 22.0 | host2 | metrics |
|
||||
| 2024-01-02T00:00:00 | 30.0 | host1 | metrics |
|
||||
+---------------------+------+-------+----------+
|
||||
|
||||
-- Test TQL with date_trunc and interval arithmetic (now() - interval '1' day pattern)
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL (date_trunc('day', '2024-01-02 00:00:00'::timestamp) - interval '1' day,
|
||||
date_trunc('day', '2024-01-02 00:00:00'::timestamp),
|
||||
'4h') metrics{host="host1"};
|
||||
|
||||
+---------------------+------+-------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+-------+----------+
|
||||
| 2024-01-01T00:00:00 | 10.0 | host1 | metrics |
|
||||
| 2024-01-01T12:00:00 | 20.0 | host1 | metrics |
|
||||
| 2024-01-02T00:00:00 | 30.0 | host1 | metrics |
|
||||
+---------------------+------+-------+----------+
|
||||
|
||||
-- Test TQL with hour-based queries
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL ('2024-01-01 06:00:00'::timestamp,
|
||||
'2024-01-01 18:00:00'::timestamp,
|
||||
'3h',
|
||||
'6h') metrics;
|
||||
|
||||
+---------------------+------+-------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+-------+----------+
|
||||
| 2024-01-01T06:00:00 | 12.0 | host2 | metrics |
|
||||
| 2024-01-01T06:00:00 | 15.0 | host1 | metrics |
|
||||
| 2024-01-01T09:00:00 | 15.0 | host1 | metrics |
|
||||
| 2024-01-01T09:00:00 | 18.0 | host2 | metrics |
|
||||
| 2024-01-01T12:00:00 | 18.0 | host2 | metrics |
|
||||
| 2024-01-01T12:00:00 | 20.0 | host1 | metrics |
|
||||
| 2024-01-01T15:00:00 | 20.0 | host1 | metrics |
|
||||
| 2024-01-01T15:00:00 | 22.0 | host2 | metrics |
|
||||
| 2024-01-01T18:00:00 | 22.0 | host2 | metrics |
|
||||
| 2024-01-01T18:00:00 | 25.0 | host1 | metrics |
|
||||
+---------------------+------+-------+----------+
|
||||
|
||||
-- Test TQL with complex interval arithmetic
|
||||
-- SQLNESS SORT_RESULT 2 1
|
||||
TQL EVAL ('2024-01-01 00:00:00'::timestamp + interval '12' hour,
|
||||
'2024-01-02 00:00:00'::timestamp - interval '6' hour,
|
||||
'6h',
|
||||
'6h') metrics{host="host2"};
|
||||
|
||||
+---------------------+------+-------+----------+
|
||||
| ts | val | host | __name__ |
|
||||
+---------------------+------+-------+----------+
|
||||
| 2024-01-01T12:00:00 | 18.0 | host2 | metrics |
|
||||
| 2024-01-01T18:00:00 | 22.0 | host2 | metrics |
|
||||
+---------------------+------+-------+----------+
|
||||
|
||||
DROP TABLE metrics;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../../../cases/standalone/common/tql/basic.sql
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user