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

Using the partition column as timeColumn results in that column appearing multiple times in the generated WHERE clause #309

Closed
tanner-bruce opened this issue Jan 21, 2021 · 1 comment · Fixed by #310 or #318
Milestone

Comments

@tanner-bruce
Copy link
Contributor

Bug Report

Using the partition column as timeColumn results in that column appearing multiple times in the generated WHERE clause

Expected Behavior

When the partitioned column is the same as the time column, it only appears once.

SELECT
 TIMESTAMP_SECONDS(DIV(UNIX_SECONDS(`start_time`), 2) * 2) AS time,
  avg(`duration`) AS duration
FROM ``
WHERE
  `start_time` BETWEEN TIMESTAMP_MILLIS (1611246930808) AND TIMESTAMP_MILLIS (1611250530808)
GROUP BY 1 
ORDER BY 1 LIMIT 1230"

Actual Behaviour

When using the query builder, this is the result of having the time column as the partitioned column. The expected result would be only including the first clause.

SELECT
 TIMESTAMP_SECONDS(DIV(UNIX_SECONDS(`start_time`), 2) * 2) AS time,
  avg(`duration`) AS duration
FROM ``
WHERE
  `start_time` BETWEEN TIMESTAMP_MILLIS (1611246930808) AND TIMESTAMP_MILLIS (1611250530808) AND
  start_time >= '2021-01-21 11:33:56' AND
  start_time < '2021-01-21 12:33:56'
GROUP BY 1 
ORDER BY 1 LIMIT 1230"

Steps to Reproduce the Problem

  1. Create a dataset with a TIMESTAMP column that is partitioned on that column
  2. Use that column as the time column in Grafana
@seuf
Copy link

seuf commented Feb 22, 2021

Note : The partitioned column appear in the where clause even if it's not the time Column.

SELECT
 TIMESTAMP_SECONDS(DIV(UNIX_SECONDS(`buildTime`), 86400) * 86400) AS time,
  `name` AS metric,
  count(`id`) AS id
FROM `redacted`
WHERE
  `buildTime` BETWEEN TIMESTAMP_MILLIS (1611413253148) AND TIMESTAMP_MILLIS (1614005253148) AND
  insert_date >= '2021-01-23 15:21:36' AND
  insert_date < '2021-02-22 15:21:36'
GROUP BY 1,2,2 
ORDER BY 1,2 LIMIT 2110"

And the parameters are not correctly casted :

Could not cast literal "2021-01-23 15:21:36" to type DATE

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants