Utilizzo di attributi utente per l'iniezione di nomi di tabelle e schemi dinamici
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
La funzionalità Attributi utente di Looker può essere utilizzata per inserire dinamicamente i nomi di schemi e/o tabelle in base all'utente.
Il primo passaggio consiste nel
creare un attributo utente, comecustom_schema o custom_table, a cui assegnare un valore per ogni utente. Puoi assegnare i seguenti valori:
Dopo aver creato l'attributo utente e assegnato il valore appropriato per i tuoi utenti, puoi aggiungere un riferimento a questo attributo nel sql_table_name dei file di visualizzazione tramite le variabili Liquid.
Di seguito sono riportati due esempi, uno che utilizza uno schema personalizzato e uno una tabella personalizzata.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-31 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```"]]