Druid sql functions analogue to Prometheus 'rate' and 'histogram_quantile'

I wrote an application and deployed a Prometheus, that scrapes metrics from the app and stores it in Druid (I'm forced to use this database in production for metrics). Now I want to make a dashboard in Grafana to monitor the application. If the datasource is Prometheus, one query would look like


This is a companion discussion topic for the original entry at https://stackoverflow.com/questions/72507283/druid-sql-functions-analogue-to-prometheus-rate-and-histogram-quantile