Skip to content

Conversation

mimir-github-bot[bot]
Copy link
Contributor

Backport dd17406 from #11830

…imestamp()` produce incorrect results (#11830)

#### What this PR does

This PR fixes an issue in common subexpression elimination where an
expression like `timestamp(foo_time) - foo_time` would produce incorrect
results.

This happens because the instant vector selector is incorrectly
deduplicated in this case: at present, the instant vector selector
operator behaves differently if it is wrapped in `timestamp()`, but the
query planner did not take this into consideration when identifying
duplicate expressions.

A future improvement would be to allow the instant vector selector
operator to return both the sample value and sample timestamp to
different consumers, but given queries like this are rare, I've opted
for the simpler approach.

#### Which issue(s) this PR fixes or relates to

#11189

#### Checklist

- [x] Tests updated.
- [n/a] Documentation added.
- [covered by #10067] `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.

(cherry picked from commit dd17406)
@mimir-github-bot mimir-github-bot bot requested a review from a team as a code owner June 24, 2025 08:53
@mimir-github-bot mimir-github-bot bot requested a review from charleskorn June 24, 2025 08:53
@charleskorn charleskorn enabled auto-merge (squash) June 24, 2025 08:53
@charleskorn charleskorn merged commit 985fbcb into r348 Jun 24, 2025
33 checks passed
@charleskorn charleskorn deleted the backport-11830-to-r348 branch June 24, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant