Using user attributes for dynamic schema and table name injection
Stay organized with collections
Save and categorize content based on your preferences.
Looker's
User Attributes
feature can be used to dynamically insert schema and/or table names on a per-user
basis.
The first step is to
create a user attribute,
such as custom_schema or custom_table, to which you
will assign a value for each user. You can assign these values:
Once you have created the user attribute and assigned the appropriate value for
your users, you can add a reference to that attribute in the
sql_table_name of your view files, via
Liquid variables.
Following are two examples, one using a custom schema and one a custom table.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-22 UTC."],[],[],null,["# Using user attributes for dynamic schema and table name injection\n\nLooker's\n[User Attributes](/looker/docs/admin-panel-users-user-attributes)\nfeature can be used to dynamically insert schema and/or table names on a per-user\nbasis.\n\n\nThe first step is to\n[create a user attribute](/looker/docs/admin-panel-users-user-attributes#creating_user_attributes),\nsuch as `custom_schema` or `custom_table`, to which you\nwill assign a value for each user. You can assign these values:\n\n- Through the UI\n- In [bulk via the API](/looker/docs/reference/looker-api/latest/methods/UserAttribute/user_attribute)\n- In the [SSO URL for embedded contexts](https://github.com/looker/looker_embed_sso_examples/blob/master/node_example.js#L31).\n\n\nOnce you have created the user attribute and assigned the appropriate value for\nyour users, you can add a reference to that attribute in the\n`sql_table_name` of your view files, via\n[Liquid variables](/looker/docs/liquid-variable-reference).\nFollowing are two examples, one using a custom schema and one a custom table.\n\nExample A\n---------\n\n\nUsing a `custom_schema`: \n\n```\nview: events {\n sql_table_name: {{ _user_attributes['custom_schema'] }}.events ;;\n\n dimension: event_id {\n type: number\n primary_key: yes\n sql: ${TABLE}.id ;;\n }\n}\n```\n\nExample B\n---------\n\n\nUsing a `custom_table`: \n\n```\nview: events {\n sql_table_name: web_traffic.{{ _user_attributes['custom_event_table_name'] }} ;;\n\n dimension: event_id {\n type: number\n primary_key: yes\n sql: ${TABLE}.id ;;\n }\n}\n```"]]