Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

$__timeGroupAlias(timestamp, $__interval) not working for 1m (minute) -> becomes 1 month instead #343

Closed
simon-verzijl opened this issue Jun 12, 2021 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@simon-verzijl
Copy link

Bug Report

There seems to be an issue translating the interval value of '1m' (which means 1 minute) in $__timeGroupAlias(timestamp, $__interval).
The generated BQ query translates '1m' in $__interval to 1 month instead of 1 minute. (It does translate '1min' to 1 minute, but that only works when hardcoding '1min' in the query, whereas I would like to use the $__interval variable (which holds i.e. 1s / 1m / 10m / 1d/ 10d/ 1y etc.

Expected Behavior

When $__interval=1m I expect the generated query for

$__timeGroupAlias(timestamp, $__interval)
to be:

SELECT
TIMESTAMP_SECONDS(DIV(UNIX_SECONDS(timestamp), 60) * 60) AS time,

Actual Behavior

$__timeGroupAlias(timestamp, $__interval) gets translated to this when $__interval=1m (1 minute) :

SELECT
TIMESTAMP( (PARSE_DATE( "%Y-%m-%d",CONCAT( CAST((EXTRACT(YEAR FROM timestamp)) AS STRING),'-',CAST((EXTRACT(MONTH FROM timestamp)) AS STRING),'-','01')))) AS time,

Steps to Reproduce the Problem

Freshly installed Grafana 8.0.1 (or 7.5.5, same issue) with only Google BigQuery plugin using any query containing timeGroupAlias :

SELECT
$__timeGroupAlias(timestamp, $__interval),
FROM project.bqdataset.table
WHERE
$__timeFilter(timestamp)

Specifications

  • Version: 2.0.2
  • Platform: Google GKE
  • Grafana Version: 7.5.5 or 8.0.1
@ajimix
Copy link

ajimix commented Jun 23, 2021

Having the same issue on a freshly installation with Grafana 8.0.3

It also happens with 24 hours period, it translates to 1 month instead

@ofir5300 ofir5300 added the duplicate This issue or pull request already exists label Jul 27, 2021
ofir5300 added a commit that referenced this issue Aug 4, 2021
fix: minute (m) shift period is casted to month (M) (fixes #306, fixes #343)
@DollarAkshay
Copy link

@ofir5300 I see this issue is fixed but a release has not been made.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants