Jayclifford345 opened a new issue, #5144: URL: https://github.com/apache/arrow-datafusion/issues/5144
**Is your feature request related to a problem or challenge? Please describe what you are trying to do.** We have created a FlightSQL plugin for grafana: https://github.com/influxdata/grafana-flightsql-datasource. I am currently creating example dashboards based on the FlightSQL dialect but hit a rough patch with global Grafana variables: Here is a query: ``` SELECT DATE_BIN(INTERVAL '$__interval_ms MILLISECONDS', time, '${__to:date}'::TIMESTAMP) AS time, avg(used_percent) AS 'average used_percent' FROM mem WHERE host='${linux_host}' AND time BETWEEN '${__from:date:iso}' AND '${__to:date:iso}' GROUP BY time ``` It would be great instead of utilising `INTERVAL '$__interval_ms MILLISECONDS'` and `time BETWEEN '${__from:date:iso}' AND '${__to:date:iso}'` we could use the following variables Grafana has inbuilt: [$timeFilter or $__timeFilter](https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#timefilter-or-__timefilter) and [$__interval](https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#__interval) **Describe the solution you'd like** If we could support the above variables our query could now look like this: ``` SELECT DATE_BIN(INTERVAL '$__interval', time, '${__to:date}'::TIMESTAMP) AS time, avg(used_percent) AS 'average used_percent' FROM mem WHERE host='${linux_host}' AND $timeFilter GROUP BY time ``` this would become the following query after translation: ``` SELECT DATE_BIN(INTERVAL '30d', time, '2023-02-01T11:21:14.644Z'::TIMESTAMP) AS time, avg(used_percent) AS 'average used_percent' FROM mem WHERE host='foo' AND time > now() - 7d GROUP BY time ``` **Describe alternatives you've considered** Currently using the original query as a work around. **Additional context** <img width="957" alt="Screenshot 2023-02-01 at 11 32 13" src="https://user-images.githubusercontent.com/45856600/216031529-65d33163-b174-44f3-8565-ad4cd7bdd5e8.png"> <img width="942" alt="Screenshot 2023-02-01 at 11 32 32" src="https://user-images.githubusercontent.com/45856600/216031534-ebc6b23d-ede6-41ff-bfc2-83299433f86f.png"> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org