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

Timeshift is not working with partitioned tables #171

Closed
anarosagoncalves opened this issue Nov 13, 2019 · 0 comments
Closed

Timeshift is not working with partitioned tables #171

anarosagoncalves opened this issue Nov 13, 2019 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@anarosagoncalves
Copy link

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 builder
timeshift

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

  1. 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
@avivl avivl self-assigned this Nov 13, 2019
@avivl avivl added the bug Something isn't working label Nov 13, 2019
@avivl avivl added this to the 1.0.4 milestone Nov 13, 2019
@avivl avivl closed this as completed in c89ea88 Nov 14, 2019
avivl added a commit that referenced this issue Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants