Dynamically changing looker connection inside model file

I have been trying to dynamically change the looker connection using user attributes. Here the database connections are SIEM databases namely siem_1 and siem_2. I created a user attribute named db_connection and under the "user values" tab I have assigned myself the "siem_1" db_connection value and another member of the team "siem_2". Then I went to the model file to change the connection and this is where I got stuck. Here connection variable takes only a string value in the form of a connection name. So if I use:
1) connection: {{_user_attribute["db_connection"]}} -> it says that it should be string
2) connection: "{{_user_attribute['db_connection']}}" -> it throws a model error as it is not one of the model connections i.e., siem_1 and siem_2

Some other solutions that I thought to solve this problem include creating a manifest file and adding the constants there but it doesn't seem to work either.

But in this Google document: https://cloud.google.com/looker/docs/admin-panel-users-user-attributes  they have mentioned that we should be able to use user attributes to dynamically change the database connection inside a model. I have attached a screenshot for the same:use_cases.png

 Kindly help me out with this problem and provide some solutions. I have been stuck on this for quite some time now. I also request Google to have example code snippets along with explanations in their documentation as it would make understanding use cases a lot easier.

 

0 4 703
4 REPLIES 4
Top Labels in this Space
Top Solution Authors