Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmselect: raising any series to power of 0 in range queries returns non-existing data points #7359

Open
trearcul opened this issue Oct 25, 2024 · 4 comments · May be fixed by VictoriaMetrics/metricsql#36
Assignees
Labels
bug Something isn't working metricsql

Comments

@trearcul
Copy link

Describe the bug

Hi,

I've encountered an issue in VictoriaMetrics. When raising any series to the power of 0 in a range query, the result contains a data point for every step in the queried range - even if the series has only a single data point within that range.

The correct behavior should be similar to the output produced by the group without () function. This means that if the series being raised has no data at a particular step of the range query, it should return no data point for that timestamp.

This issue affects both the clustered and single-node versions of VictoriaMetrics.

Thank you.

To Reproduce

To reproduce the issue, run (hour() == 12)^0 as a range query over a 24-hour time range.

Version

victoria-metrics-20241021-132758-tags-v1.105.0-0-g05f6ea621d

Logs

No response

Screenshots

Result of (hour() == 12)^0
Screenshot 2024-10-25 at 15 23 06

Expected result
Screenshot 2024-10-25 at 15 23 22

Used command-line flags

No response

Additional information

No response

@trearcul trearcul added the bug Something isn't working label Oct 25, 2024
@jiekun jiekun self-assigned this Oct 31, 2024
@jiekun
Copy link
Contributor

jiekun commented Nov 4, 2024

Thanks for the bug report.

I will raise a pull request for this. Please help verifying the result for query (hour() == 12)^0 below with my patch:

image

Also, you can try to update the MetricsQL package like this and build it from source:

go get github.com/VictoriaMetrics/metricsql@ddccb095a91c242290e6db9d2c17e0e6ee02e9ba

@trearcul
Copy link
Author

trearcul commented Nov 4, 2024

Hi! According to the screenshot you provided, it looks like the issue has been fixed by your changes. 👍 Thank you!

@jiekun
Copy link
Contributor

jiekun commented Nov 4, 2024

Thanks. It will be reviewed by maintainers.


And also wanna to clarify the reason behind this.

  1. Currently, the ^ in VictoriaMetrics simply wrapped Go's native implementation. So anything ^ 0 is 1 , you should always observe 1 as output. See example here. This behaviour will be fixed after PR.
    • left time series ^ right time series: [NaN, NaN, 12, NaN] ^ [0, 0, 0, 0] = [1, 1, 1, 1]
  2. However you may observe that when selecting a smaller time range, it may return no data instead of 1. See example here This is because VictoriaMetrics will simplify time series when no valid data point exists.
    • [NaN, NaN, NaN] ^ [0, 0, 0] = Empty ^ [0, 0, 0] = Empty

Line 175 returns empty result.

default:
left = removeEmptySeries(left)
right = removeEmptySeries(right)
}
if len(left) == 0 || len(right) == 0 {
return nil, nil
}

@trearcul
Copy link
Author

trearcul commented Nov 4, 2024

Thank you. That’s the behavior (after the fix) I would expect. I just hope no one is relying on the current behavior in their queries. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working metricsql
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants