You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### What this PR does
This PR fixes two issues in the "remove statically empty expressions"
optimisation pass:
* it is ineffective when applied to queries rewritten by Grafana Cloud's
Adaptive Metrics feature
* it can incorrectly determine that an expression is empty if the
expression is a `timestamp()` function call directly on a selector and
that selector contains an offset or @ modifier
#### Which issue(s) this PR fixes or relates to
#14989
#### Checklist
- [x] Tests updated.
- [n/a] Documentation added.
- [x] `CHANGELOG.md` updated - the order of entries should be
`[CHANGE]`, `[FEATURE]`, `[ENHANCEMENT]`, `[BUGFIX]`. If changelog entry
is not needed, please add the `changelog-not-needed` label to the PR.
- [n/a]
[`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md)
updated with experimental features.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches query-planning optimization logic for `timestamp()`
comparisons; mistakes could change whether parts of queries are skipped,
but the change is narrowly scoped and backed by expanded tests.
>
> **Overview**
> Fixes the MQE `RemoveStaticallyEmptyExpressions` optimization so it no
longer misclassifies `timestamp()` comparisons as empty when
`timestamp()` wraps a selector with `offset`/`@` (now derives the
earliest possible sample time via the selector’s queried time range),
while still optimizing non-selector `timestamp(<expr>)` comparisons
based only on the evaluation start.
>
> Makes the optimization effective for Grafana Cloud Adaptive Metrics
rewrites by unwrapping the reserved wrapper functions around
`timestamp()` calls, adds defensive error handling, and expands
unit/integration tests plus a changelog reference update.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2342b78. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -188,7 +188,7 @@
188
188
* [ENHANCEMENT] Query-frontend: Stream JSON encoding directly to the response body to avoid a full-copy allocation of the serialized payload. #14840
189
189
* [ENHANCEMENT] Activity tracker: Added `activity_tracker_unfinished_activities_loaded` metric to report the number of unfinished activities detected on startup. #14860
190
190
* [ENHANCEMENT] Distributor now uses record validation time as Kafka record timestamp to reduce rejections among consumers. #14921
191
-
* [ENHANCEMENT] MQE: Add optimisation pass to optimise away expressions containing comparisons with `timestamp()` that can't produce results due to the query time range. #14989
191
+
* [ENHANCEMENT] MQE: Add optimisation pass to optimise away expressions containing comparisons with `timestamp()` that can't produce results due to the query time range. #14989 #15014
192
192
* [ENHANCEMENT] Distributor: OTLP endpoint now returns partial success (HTTP 200) instead of HTTP 429 when the usage tracker rejects some series due to the active series limit but other series are successfully ingested. The `RejectedDataPoints` field reports the count of distributor-side rejections (usage tracker filtering). #14789
193
193
* [ENHANCEMENT] MQE: Account for memory consumption of labels returned by binary operations in query memory consumption estimate earlier. #15033
194
194
* [ENHANCEMENT] Query-frontend: Log the number of series and samples returned for queries in `query stats` log lines. #15044
0 commit comments