This repository was archived by the owner on Dec 11, 2022. It is now read-only.
This repository was archived by the owner on Dec 11, 2022. It is now read-only.
Timeshift is not working with partitioned tables #171
Closed
Description
Bug Report
I am using grafana and the bigquery-grafana plugin to graph data from a BigQuery partitioned table. I was unable to graph data using the timeshift macro. I found that the problem is in the query to fetched the shifted data, it is looking for data in the same partitions as the main query. Time range is This month.
Query inspector, two queries as expected. The query for the current month:
SELECT
TIMESTAMP_SECONDS(DIV(UNIX_SECONDS(`t`), 86400) * 86400),
count(`t`) AS total
FROM `..._*`
WHERE `t` BETWEEN TIMESTAMP_MILLIS (1572566400000) AND TIMESTAMP_MILLIS (1575158399999)
AND _TABLE_SUFFIX BETWEEN '20191101' AND '20191130'
GROUP BY 1
ORDER BY 1
LIMIT 1440
The query for the previous month
SELECT
TIMESTAMP_SECONDS(DIV(UNIX_SECONDS(`t`), 86400) * 86400),
count(`t`) AS total_shifted_1m
FROM `..._*`
WHERE `t` BETWEEN TIMESTAMP_MILLIS (1569884400000) AND TIMESTAMP_MILLIS (1572479999999)
AND _TABLE_SUFFIX BETWEEN '20191101' AND '20191130'
GROUP BY 1
ORDER BY 1 LIMIT 1440
Expected Behavior
Automatically adjust the query's "_TABLE_SUFIX" part.
Actual Behavior
The timeshifted query looks for data in the same partitioned tables as the non shifted query.
Steps to Reproduce the Problem
- Build query on partitioned tables using the timeshift macro.
Specifications
- Version: 1.0.2
- Platform: macOS Catalina 10.15.1
- Grafana Version: v6.4.3