Skip to content

$__timeGroup(t,$__interval) fails for millisecond intervals #257

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

Closed
MatinF opened this issue May 10, 2024 · 1 comment · Fixed by #262
Closed

$__timeGroup(t,$__interval) fails for millisecond intervals #257

MatinF opened this issue May 10, 2024 · 1 comment · Fixed by #262
Assignees
Labels
type/bug Something isn't working

Comments

@MatinF
Copy link

MatinF commented May 10, 2024

I have a Grafana-BigQuery dashboard in which I'm using a query as below for time series plots:

SELECT
  $__timeGroup(t,$__interval) as time,  
  ${signal_value:csv}
FROM
  ${dataset}.tbl_${device:csv}_${message:csv}
WHERE
  $__timeFilter(t)
GROUP BY
  $__timeGroup(t,$__interval)

This works perfectly as long as the $__interval is an integer second value. But when it becomes a millisecond interval, e.g. 500 ms, the query fails with this error message:

error querying the database: googleapi: Error 400: No matching signature for function DIV for argument types: INT64, FLOAT64. Supported signatures: DIV(INT64, INT64); DIV(NUMERIC, NUMERIC); DIV(BIGNUMERIC, BIGNUMERIC) at [2:21], invalidQuery

Is there a way to get around this? Our time series data is often microsecond level in terms of resolution - and we would ideally like to be able to continue to 'zoom in' on the data to the sub second level within Grafana.

See also below video of how the issue materializes:

2024-05-10.09-37-43.mp4
@MatinF
Copy link
Author

MatinF commented May 10, 2024

I fixed this by modifying my query as follows - maybe worth considering updating the macro accordingly:

SELECT
  TIMESTAMP_MILLIS(DIV(UNIX_MILLIS(t), $__interval_ms) * $__interval_ms) as time,
  ${signal_value:csv}
FROM
  ${dataset}.tbl_${device:csv}_${message:csv}
WHERE
  $__timeFilter(t)
GROUP BY
  time

@gabor gabor self-assigned this May 21, 2024
@gabor gabor added the type/bug Something isn't working label May 21, 2024
@gabor gabor moved this to In Progress in OSS Big Tent May 21, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Complete in OSS Big Tent May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
Status: Complete
Development

Successfully merging a pull request may close this issue.

2 participants