Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#9330·greptimedb

PromQL: offset on a subquery is ignored

Author: killme2008Created Sep 23, 2026Updated Sep 23, 2026
LabelsC-bug

What type of bug is this?

Incorrect result

What subsystems are affected?

Query Engine

Minimal reproduce step

sql
CREATE TABLE m (ts TIMESTAMP TIME INDEX, host STRING PRIMARY KEY, val DOUBLE);
INSERT INTO m VALUES (0,'a',1),(10000,'a',2),(20000,'a',3),(30000,'a',4),(40000,'a',5),(50000,'a',6),(60000,'a',7);

TQL EVAL (60, 60, '1s') sum_over_time(m[20s:10s]);             -- 13
TQL EVAL (60, 60, '1s') sum_over_time(m[20s:10s] offset 30s);  -- 13
TQL EVAL (60, 60, '1s') sum_over_time(m[20s] offset 30s);      -- 7
TQL EVAL (30, 30, '1s') sum_over_time(m[20s:10s]);             -- 7

What did you expect to see?

sum_over_time(m[20s:10s] offset 30s) at t=60 should equal the subquery evaluated at t=30, i.e. 7.

What did you see instead?

13, the same as without the offset. The offset is silently ignored. The range-selector form m[20s] offset 30s is correct.

prom_subquery_expr_to_plan destructures SubqueryExpr { expr, range, step, .. } (src/query/src/promql/planner.rs:521-523) and never reads offset (or at).

What operating system did you use?

macOS 26 arm64

What version of GreptimeDB did you use?

v1.2.1 (same code on main @ d910183cc4)

Source: GreptimeTeam/greptimedb

View original on GitHubView discussion on GitHub