Remove single quote around template variable

I want to provide a template list for tables in a mysql db. So I can do the query like so for the template

show tables in Archives like ‘table_%’

And it will build the list of table_2017_11, table_2017_10 and so on. That part is fine.

When I use the $Table now in my data source query I do something like this:

SELECT
DISTINCT Count(Event),
UNIX_TIMESTAMP(DATE_FORMAT(TimeStamp, ‘%Y-%m-%d %H:%i:%s’)) as time_sec,
Source as metric
FROM Archive.[[Table]]

and the generated sql looks like this:

SELECT
DISTINCT Count(Event),
UNIX_TIMESTAMP(DATE_FORMAT(TimeStamp, ‘%Y-%m-%d %H:%i:%s’)) as time_sec,
Source as metric
FROM Archive.‘table_2017_11’

I have tried using both $Table and [[Table]] and both are wrapped with the single ’ is there a different way to pass these template variables to the query without wrapping them in a single ’ ?

Thanks

1 Like

This is already implemented in the master branch. Your query will work with a nightly build or you can wait for the next major version.

I still do see this issue.
CAST($breakdown AS VARCHAR) -> CAST(‘installgroup’ AS VARCHAR)
Grafana version is 4.6

Version 4.6 is 3 years old.

Current is 7.0.4.

I recommend upgrading:

a) so you get the benefit of all the bug fixes and feature enhancements from the
pst 3 years

b) so you stand a chance of someone else here running the same version as you
and being to help with any problems.

Regards,

Antony.

1 Like

You should try ${Table:raw}, so it prevents Grafana to do string interpolations.

1 Like