Custom 'from' functions?


I am working on the standard problem of needing to pick the correct rollup for the selected time interval.

We have lots of data stored every 1ms, and build grafana dashboards to show it. We currently have a very custom grafana datasource that picks a different rollup (retention policy) based on the query interval.

Is there any way to do this directly with flux? Something like:
from( my_func_that_somehow_knows_the_range() )
|> range(start: -1h)

Any ideas? The real goal is:

but that solves the general case. I wonder if flux would let me put custom logic into a single function