Grants and roles
Grant and revoke privileges, roles, membership, and fine-grained data access. See the permissions documentation for what each privilege and role allows.
Every method names one principal with principal_type ("USER", "GROUP", "SERVICE_PRINCIPAL") and principal (the user's email, or the group or service principal name). Object names are dotted: "lake", "lake.database", "lake.database.table".
These methods do not take unsafe_raw; keyword values are always validated.
A group must hold a project role before it can be granted privileges on tables. Grant the role first with grant_role; otherwise the server returns Entity of type: GROUP not found.
Methods
| Method | Description |
|---|---|
grant_privilege / revoke_privilege | Grant or revoke privileges on one object |
grant_privilege_on_all / revoke_privilege_on_all | Grant or revoke privileges on every child of a container |
grant_role / revoke_role | Grant or revoke a project or account role |
grant_member / revoke_member | Add or remove a member of a group or service principal |
grant_row_filter / revoke_row_filter | Restrict which rows of a table the principal sees |
grant_column_mask / revoke_column_mask | Mask a column of a table for the principal |
grant_column_access / revoke_column_access | Restrict which columns of a table the principal sees |
grant_data_admin / revoke_data_admin | Make the principal a data admin for the organization |
show_grants | List the grants on an object |
show_roles | List the roles a type of principal holds on a project |
grant_privilege
grant_privilege(
privileges: str | Sequence[str],
*,
on: str,
name: str,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
revoke_privilege takes the same arguments.
| Parameter | Required | Type / values |
|---|---|---|
privileges | yes | One privilege or a list: "VIEWER", "EDITOR", "USER", "MANAGER", "ALL_PRIVILEGES", "MANAGE", "DESCRIBE", "CREATE", "SELECT", "INSERT", "UPDATE", "DELETE", "CANCEL", "ALTER", "DROP", "INVOKE", "CALL", "READ", "WRITE" |
on | yes | "TABLE", "DATABASE", "CLUSTER", "LAKE", "JOB", "AI_MODEL", "MCP_TOOL", "URL" |
name | yes | str — name of the object |
principal_type | yes | "USER", "GROUP", "SERVICE_PRINCIPAL" |
principal | yes | str |
The grade privileges VIEWER, EDITOR, USER, and MANAGER must be granted on their own. Passing one of them in a list with other privileges raises ValueError.
Example
client.grant_privilege(
["SELECT", "DESCRIBE"],
on="TABLE",
name="prod_lake.sales.orders",
principal_type="GROUP",
principal="analysts",
)
# GRANT PRIVILEGE SELECT, DESCRIBE ON TABLE 'prod_lake.sales.orders' TO GROUP 'analysts'
grant_privilege_on_all
grant_privilege_on_all(
privileges: str | Sequence[str],
*,
children: str,
container_type: str,
container: str,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
revoke_privilege_on_all takes the same arguments. The grant covers every current and future child of the container.
| Parameter | Required | Type / values |
|---|---|---|
privileges | yes | Same values and rules as grant_privilege |
children | yes | "TABLES", "DATABASES" |
container_type | yes | "DATABASE", "LAKE" |
container | yes | str — name of the container |
principal_type | yes | "USER", "GROUP", "SERVICE_PRINCIPAL" |
principal | yes | str |
Only two children / container_type pairs are accepted: TABLES in DATABASE, and DATABASES in LAKE. Any other pair raises ValueError.
Example
client.grant_privilege_on_all(
"SELECT",
children="TABLES",
container_type="DATABASE",
container="prod_lake.sales",
principal_type="GROUP",
principal="analysts",
)
# GRANT PRIVILEGE SELECT ON ALL TABLES IN DATABASE 'prod_lake.sales' TO GROUP 'analysts'
grant_role
grant_role(
role: str,
*,
on: str,
name: str,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
| Parameter | Required | Type / values |
|---|---|---|
role | yes | "ADMIN", "MEMBER", "READER" |
on | yes | "PROJECT", "ACCOUNT" |
name | yes | str — project or account name |
principal_type | yes | "USER", "GROUP", "SERVICE_PRINCIPAL" |
principal | yes | str |
on="ACCOUNT" works only with principal_type="SERVICE_PRINCIPAL"; any other principal type raises ValueError. For account roles the server ignores name.
Example
client.grant_role(
"MEMBER", on="PROJECT", name="my_project",
principal_type="GROUP", principal="analysts",
)
# GRANT ROLE MEMBER ON PROJECT 'my_project' TO GROUP 'analysts'
revoke_role
Same signature as grant_role, but on accepts only "PROJECT": account roles cannot be revoked through SQL.
revoke_role removes the principal from the project entirely. The server ignores role, so revoke_role("ADMIN", ...) does not downgrade an admin to a member; it removes every role the principal holds on the project. To change a principal's role, revoke it and then grant the new role.
Example
client.revoke_role(
"MEMBER", on="PROJECT", name="my_project",
principal_type="GROUP", principal="analysts",
)
grant_member
grant_member(
*,
on: str,
name: str,
principal_type: str,
principal: str,
role: str = "MEMBER",
timeout: float | None = None,
poll_interval: float | None = None,
)
revoke_member takes the same arguments. It removes the membership whatever role is given; it never downgrades a manager to a member.
| Parameter | Required | Type / values |
|---|---|---|
on | yes | "GROUP", "SERVICE_PRINCIPAL" |
name | yes | str — the group or service principal |
principal_type | yes | For a group: "USER", "SERVICE_PRINCIPAL". For a service principal: "USER", "GROUP". |
principal | yes | str |
role | no | "MEMBER" (default), "MANAGER" |
Any other principal type for the chosen on raises ValueError.
Example
client.grant_member(
on="GROUP", name="analysts",
principal_type="USER", principal="jane@example.com",
)
# GRANT ROLE MEMBER ON GROUP 'analysts' TO USER 'jane@example.com'
grant_row_filter
grant_row_filter(
expression: str,
*,
table: str,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
The principal sees only the rows of table that match expression.
Example
client.grant_row_filter(
"region = 'US'",
table="prod_lake.sales.orders",
principal_type="GROUP",
principal="analysts",
)
# GRANT ROW FILTER 'region = ''US''' ON TABLE 'prod_lake.sales.orders' TO GROUP 'analysts'
revoke_row_filter
revoke_row_filter(
*,
table: str,
principal_type: str,
principal: str,
expression: str | None = None,
timeout: float | None = None,
poll_interval: float | None = None,
)
Without expression, revokes every row filter on the table for the principal.
Example
client.revoke_row_filter(
table="prod_lake.sales.orders", principal_type="GROUP", principal="analysts",
)
grant_column_mask
grant_column_mask(
column: str,
*,
table: str,
principal_type: str,
principal: str,
mask_type: str | None = None,
custom_expression: str | None = None,
timeout: float | None = None,
poll_interval: float | None = None,
)
Pass exactly one of mask_type or custom_expression.
| Parameter | Required | Type / values |
|---|---|---|
column | yes | str |
table | yes | str |
mask_type | one of | "MASK", "MASK_SHOW_LAST_4", "MASK_SHOW_FIRST_4", "MASK_HASH", "MASK_NULL", "MASK_DATE_SHOW_YEAR" |
custom_expression | one of | str — custom mask expression |
Examples
client.grant_column_mask(
"email", table="prod_lake.sales.orders",
principal_type="GROUP", principal="analysts", mask_type="MASK_HASH",
)
# GRANT COLUMN MASK 'email' USING 'MASK_HASH' ON TABLE 'prod_lake.sales.orders' TO GROUP 'analysts'
client.grant_column_mask(
"ssn", table="prod_lake.sales.orders",
principal_type="GROUP", principal="analysts",
custom_expression="concat('***', substr(ssn, -4))",
)
revoke_column_mask
revoke_column_mask(
column: str,
*,
table: str,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
Example
client.revoke_column_mask(
"email", table="prod_lake.sales.orders", principal_type="GROUP", principal="analysts",
)
grant_column_access
grant_column_access(
columns: str | Sequence[str],
*,
table: str,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
The principal sees only these columns of table. Column names must be non-empty and must not contain commas.
Example
client.grant_column_access(
["id", "region"], table="prod_lake.sales.orders",
principal_type="GROUP", principal="analysts",
)
# GRANT COLUMN ACCESS 'id,region' ON TABLE 'prod_lake.sales.orders' TO GROUP 'analysts'
revoke_column_access
revoke_column_access(
*,
table: str,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
Removes the column-access restriction on the table for the principal.
Example
client.revoke_column_access(
table="prod_lake.sales.orders", principal_type="GROUP", principal="analysts",
)
grant_data_admin
grant_data_admin(
*,
principal_type: str,
principal: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
revoke_data_admin takes the same arguments. Data admin is organization-wide and takes no object. See GRANT DATA_ADMIN.
Example
client.grant_data_admin(principal_type="USER", principal="jane@example.com")
# GRANT DATA_ADMIN TO USER 'jane@example.com'
show_grants
show_grants(
*,
on: str,
name: str,
timeout: float | None = None,
poll_interval: float | None = None,
)
on takes the same eight values as in grant_privilege: TABLE, DATABASE, CLUSTER, LAKE, JOB, AI_MODEL, MCP_TOOL, URL. Any other value raises ValueError. SHOW GRANTS itself also accepts ACCOUNT, PROJECT, GROUP, SERVICE_PRINCIPAL, SOURCE, CATALOG, and FLOW; run those through client.execute(), for example client.execute("SHOW GRANTS ON FLOW 'my_flow'").
Example
result = client.show_grants(on="TABLE", name="prod_lake.sales.orders")
show_roles
show_roles(
principal_type: str,
*,
name: str,
on: str = "PROJECT",
timeout: float | None = None,
poll_interval: float | None = None,
)
Lists the roles that users, groups, or service principals hold on the project name. on accepts only "PROJECT".
Example
result = client.show_roles("GROUP", name="my_project")
# SHOW GROUP ROLES ON PROJECT 'my_project'