vw_workspace_assignments
Creates, updates, deletes, gets or lists a vw_workspace_assignments resource.
Overview
| Name | vw_workspace_assignments |
| Type | View |
| Id | databricks_account.iam.vw_workspace_assignments |
Fields
The following fields are returned by this view:
| Name | Datatype | Description |
|---|---|---|
account_id | string | Databricks account ID used to scope the query. |
workspace_id | integer | Numeric ID of the workspace used to scope the query. |
principal_id | integer | Numeric ID of the principal assigned to the workspace. |
display_name | string | Display name of the assigned principal. |
user_name | string | Username of the assigned principal if the principal is a user. |
group_name | string | Group name of the assigned principal if the principal is a group. |
service_principal_name | string | Application name of the assigned principal if the principal is a service principal. |
permission | string | Permission level granted to the principal on the workspace (one row per permission, e.g. USER, ADMIN). |
Required Parameters
The following parameters are required by this view:
| Name | Datatype | Description |
|---|---|---|
account_id | string | Databricks account ID used to scope the query. |
workspace_id | integer | Numeric ID of the workspace used to scope the query. |
SELECT Examples
SELECT
account_id,
workspace_id,
principal_id,
display_name,
user_name,
group_name,
service_principal_name,
permission
FROM databricks_account.iam.vw_workspace_assignments
WHERE account_id = '{{ account_id }}'
AND workspace_id = '{{ workspace_id }}';
SQL Definition
- Sqlite3
- Postgres
SELECT
wa.account_id,
wa.workspace_id,
JSON_EXTRACT(wa.principal, '$.principal_id') AS principal_id,
JSON_EXTRACT(wa.principal, '$.display_name') AS display_name,
JSON_EXTRACT(wa.principal, '$.user_name') AS user_name,
JSON_EXTRACT(wa.principal, '$.group_name') AS group_name,
JSON_EXTRACT(wa.principal, '$.service_principal_name') AS service_principal_name,
p.value AS permission
FROM databricks_account.iam.workspace_assignment wa,
JSON_EACH(wa.permissions) p
WHERE account_id = '{{ account_id }}'
AND workspace_id = '{{ workspace_id }}'
SELECT
wa.account_id,
wa.workspace_id,
(wa.principal->>'principal_id')::bigint AS principal_id,
wa.principal->>'display_name' AS display_name,
wa.principal->>'user_name' AS user_name,
wa.principal->>'group_name' AS group_name,
wa.principal->>'service_principal_name' AS service_principal_name,
p.value AS permission
FROM databricks_account.iam.workspace_assignment wa,
jsonb_array_elements(wa.permissions::jsonb) AS p
WHERE account_id = '{{ account_id }}'
AND workspace_id = '{{ workspace_id }}'