JSON API SQL with runtime values of variables

Hi,

I have created a JSON API data source and have successfully connected Dremio REST API -

I want to pass a SQL query using the SQL API endpoint -

In the SQL query that I am sending, I want to send along the values of the Grafana variables at runtime, as selected from the dropdown. For eg.

JSON body -
{
“sql” : “select * from table1 where $__timeFilter(timeColumn)”
}

This query is not getting parsed. What should I do ?

I have tried variations like below but still no luck -

{
“sql” : “select * from table1 where ${__time_Filter(timeColumn)}”
}

Thanks

Take a look at our documentation about variables in datasource plugins Add support for variables | Grafana Plugin Tools

Does it work if you ran the query without filter

JSON body -
{
“sql” : “select * from table1 ”
}
1 Like

Hello @yosiasz ,

Yes, without filter it works like a charm. I can’t seem to wrap my head around how to pass the variables. Within double quotes the query is not parsed to replace timeFilter ( or any other variable ) with the chosen values at runtime and the query is passed on as-is which throws an error at the server end ( Dremio in this case ) as unrecognized function / failure parsing the query etc.

Where is the documentation for the above macro?

I have also tried below but it did not parse.

{
“sql” : “select * from table1 where ${__timeFilter(timeColumn)}”
}