Nested Variables not working in datasource plugin

I am developing a custom Data source, so i tried to give in nested variables, but instead of variables it is still showing ‘$variable’ only , Is it a thing that plugin should handle ? I am assuming that grafana does the substitution

this is the query i am receiving
SELECT time FROM QUERY_xxxx limit $top

thanks

Yes, your datasource needs to use the templateSrv to replace variables in metricFindQuery