Using environment variables in queries


#1

Issue Summary

A summary of the issue and the browser/OS environment in which it occurs.
I am using MongoDB datasource, and I my use case is as follows:

I am creating different views for one of my collections, the view names are having the convention - _<collection_name>_view. In addition I create a user in MongoDB that has permissions only for that specific collection according to the user name.
At Redash I create a datasource that has the permissions of that same user name in correlation with MongoDB user name.I also create a group \ user in Redash with the same convention.
I would like to have according to user login to Redash the option to inject environment variable to my existing queries corresponding to the username that logged in for Redash.
The environment variable I was looking at is - REDASH_MAIL_USERNAME.

My final outcome is that the same user name in Redash(user\group) \ MongoDB(user\view) will be the same and the query will be executed upon the injected environment variable.

Please assist with the above requirements.
If you have other insights how to implement it I am open for suggestions.

Thanks.

Technical details:

  • Redash Version: 4.0.1+b4038
  • Browser/OS: Chrome
  • How did you install Redash: Docker container - official image