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

Query builder ignores column argument #139

Closed
fermuch opened this issue Sep 13, 2019 · 6 comments
Closed

Query builder ignores column argument #139

fermuch opened this issue Sep 13, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@fermuch
Copy link

fermuch commented Sep 13, 2019

Bug Report

The macros $__timeFilter, $__timeFrom and $__timeTo ignore the column argument.

As an example, the query:

SELECT $__timeFrom(column)

should be converted to:

SELECT `column` > TIMESTAMP_MILLIS (1568360548569)

but instead it is converted to:

SELECT `time` > TIMESTAMP_MILLIS (1568360548569)

The same happens to the other macros.

If instead the column argument is provided as an string 'column' or in any other form (with backticks, for example), the query builder fails to convert it and just passes the string literal to bigquery ($__timeFrom(column))

Specifications

  • Version: 1.0.2
  • Platform: Firefox 69.0 (since it is a frontend bug)
  • Grafana Version: 5.4.2
@avivl
Copy link
Contributor

avivl commented Sep 15, 2019

@fermuch I'm not sure I understand the issue.
The $__timeFilter, $__timeFrom and $__timeTo are only relevant to the Time column

@fermuch
Copy link
Author

fermuch commented Sep 15, 2019

But what if I have events, which have a created_at column (when it was created on the server, which is the time partition) but also two timestamps, started_at and ended_at, for which I want to filter by those instead of created_at?

@avivl
Copy link
Contributor

avivl commented Sep 16, 2019

You will have to do it without the macro

@fermuch
Copy link
Author

fermuch commented Sep 16, 2019

I can't filter without the macro, since I can't get the milliseconds for the start and end of the user chosen time filter

@fermuch
Copy link
Author

fermuch commented Sep 16, 2019

Adding $__from and $__to which only get translated into the millis would solve this problem, and it already is a global built-in in grafana. What's your opinion on that?

An example query would be:

SELECT `started_at` > TIMESTAMP_MILLIS ($__from)

Which is translated into:

SELECT `started_at` > TIMESTAMP_MILLIS (1568360548569)

And if those two are added, also supporting $__interval_ms (returning the $__interval as milliseconds) would be useful, for cases where $__interval() is not enough.

Here are the docs for $__interval_ms

@avivl avivl added the enhancement New feature or request label Sep 18, 2019
@avivl avivl self-assigned this Sep 18, 2019
@avivl avivl added this to the 1.0.3 milestone Sep 18, 2019
@avivl
Copy link
Contributor

avivl commented Sep 18, 2019

Adding $__millisTimeTo and $__millisTimeFrom

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants