Filter data in SQL with a user attribute
Last updated
Last updated
In this section, we'll explore the process of efficiently filtering tables using user attributes, utilizing the PostgreSQL connector as our example. This feature enables the dynamic application of row-level security, proving especially valuable in scenarios with a multi-tenant data architecture. In such setups, where data for all users is housed within a common table, our user-friendly approach empowers you to seamlessly implement and manage security measures tailored to your unique requirements.
It's highly recommended as an App-builder to be connected with an account that has the user attributes used that are set. This ensures a smooth and efficient configuration process.
Dive into the following guide to manage RLS directly within the SQL query:
When creating a dataset from a connector, switch to code-mode.
Write your SQL query to fetch data by filtering the data based on the user attribute (customer_key in the example below) by using the syntax {{user.attributes.your_attribute}}
More on variable syntaxes in this page.
If you are not connected with a user that has those attributes that are set, you can make the choice to use conditional templating syntax (given in the linked page above).