Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 28762d6

Browse files
committed
Do not attempt to push down calls with offsets
We don't correctly handle pushdowns with offsets, so we just skip them instead of returning erroneous results.
1 parent ad20435 commit 28762d6

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ We use the following categories for changes:
1717
### Added
1818
- Add Prometheus metrics support for Tracing [#1102]
1919

20+
### Fixed
21+
- Disable push downs which use `offset`, as they are broken [#1129]
22+
2023
## [0.9.0] - 2022-02-02
2124

2225
### Added

pkg/pgmodel/querier/query_builder.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,13 @@ func canAttemptPushdown(metadata *promqlMetadata) bool {
242242
path := metadata.path // PromQL AST.
243243
queryHints := metadata.queryHints
244244
selectHints := metadata.selectHints
245+
vs, isVectorSelector := queryHints.CurrentNode.(*parser.VectorSelector)
246+
if isVectorSelector {
247+
if vs.Offset != 0 || vs.OriginalOffset != 0 {
248+
// We can't handle offsets in pushdowns
249+
return false
250+
}
251+
}
245252
return extension.ExtensionIsInstalled && queryHints != nil && !hasSubquery(path) && selectHints != nil
246253
}
247254

pkg/tests/end_to_end_tests/promql_query_endpoint_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,10 @@ func TestPromQLQueryEndpoint(t *testing.T) {
25062506
name: "two pushdowns, same metric different matchers",
25072507
query: `sum(rate(metric_2{foo = "bar"}[5m]))/sum(rate(metric_2[5m]))`,
25082508
},
2509+
{
2510+
name: "pushdown with offset and rate smaller than vector selector lookback",
2511+
query: `delta(metric_2[1m] offset 3m)`,
2512+
},
25092513
}
25102514
start := time.Unix(startTime/1000, 0)
25112515
end := time.Unix(endTime/1000, 0)

0 commit comments

Comments
 (0)