$__interval inside date_bin causing syntax error

I’m trying to integrate to InfluxDB using flightSQL, and I’ve a query that’s working fine and starts…

SELECT DATE_BIN(INTERVAL '10 minutes', time, $__timeFrom::TIMESTAMP) ...

However if I try and use the $__internal macro:

SELECT DATE_BIN($__interval, time, $__timeFrom::TIMESTAMP) ...

I get an error:

Failed to evaluate queries and expressions: [sse.dataQueryError] failed to execute query [A]: flightsql: rpc error: code = InvalidArgument desc = Error while planning query: This feature is not implemented: Unsupported interval argument. Expected string literal, got: Cast { expr: Value(SingleQuotedString(“900 second”)), data_type: Timestamp(None, None), format: None }

Alternatively, if I change the final argument in DATE_BIN:

SELECT DATE_BIN($__interval, time, arrow_cast($__timeFrom, 'Utf8')) ...

Which again works with the hard coded interval, I then get a probably odder error…

… No function matches the given name and argument types ‘date_bin(Interval(MonthDayNano))’. You might need to add explicit type casts …

That seems to suggest that the other two options in the function have been lost somehow?!

I’m unclear quite who’s problem this should be, but if I’m understanding things correctly, these macros should be literal string replacements, so totally under Grafana’s remit, not the back end it goes off to?

If the query help text is correct:

  • $__interval → interval ’30 second’

How is there any room for a change in behaviour?