vertica / vertica-grafana-datasource

Official Vertica datasource plugin for Grafana.
https://grafana.com/grafana/plugins/vertica-grafana-datasource/
Apache License 2.0
3 stars 9 forks source link

timeFrom and timeTo macros fail when used in function #16

Closed prokopenkopn closed 1 year ago

prokopenkopn commented 2 years ago

This query: "SELECT $__timeFrom()" - works OK. But this: "SELECT LEFT($__timeFrom(), 19)" - fails with error: "_macro _timeFrom should have no arguments"

In grafana.log: t=2021-11-09T10:49:21+0300 lvl=info msg=QueryData logger=plugins.backend pluginId=vertica-grafana-datasource timeR=2021-11-09T04:50:32.303+03:00 t=2021-11-09T10:49:21+0300 lvl=eror msg="Error while replacing the string submatches: macro timeFrom should have no arguments" logger=plugins.backend pluginId=vertica-grafana-datasource t=2021-11-09T10:49:21+0300 lvl=eror msg="Error while sanitizing the query: macro timeFrom should have no arguments" logger=plugins.backend pluginId=vertica-grafana-datasource

oBoMBaYo commented 2 years ago

Any updates, We also faced the same issue.

t=2022-01-07T04:58:54+0000 lvl=eror msg="Error while sanitizing the query: macro __timeFrom should have no arguments" logger=plugins.backend pluginId=vertica-grafana-datasource

Example query that got the above error

select count(1) "No of zzzz"
from xxx.yyy
where TO_TIMESTAMP(time/1000) >= $__timeFrom()
and TO_TIMESTAMP(time/1000) <= $__timeTo()

We found the workaround for this issue.

Screen Shot 2565-01-07 at 14 38 01

jayhyuk commented 2 years ago

Me too

tanvipise commented 2 years ago

The variable is interpolated before the query is sent to the datasource. So in this case the $__timeFrom needs to be resolved prior to passing it inside the LEFT function. Please refer this link for details.