How Camel Sets the UID
For every query executed through Camel, the system automatically sets a custom session setting:Setting Up RLS
Step 1: Create a Role with Custom Settings
First, create a role that allows the custom setting to be used:Step 2: Grant Table Permissions
Grant the necessary permissions to the role:Step 3: Create a Row Policy
Create a row policy that uses the custom setting to filter data:Step 4: Create Users and Assign Roles
Complete Example: Multi-Tenant Data
Let’s implement RLS for a multi-tenant analytics platform where each tenant should only see their own data.1. Create the Events Table
2. Set Up the Role and Permissions
3. Create the Row Policy
4. Create the User
Testing Your Policies
You can test your row policies using the ClickHouse client:Troubleshooting
Common Issues and Solutions
Issue | Solution |
---|---|
”Unknown setting SQL_camel_uid” | Ensure the role has CHANGEABLE_IN_READONLY permission for the setting |
No data returned | Verify the getSetting value matches your data exactly (case-sensitive) |
All data visible | Check that the row policy is applied to the correct role |
Poor performance | Ensure filter columns are in the ORDER BY clause |