Skip to main content

oh grant

Grant privileges, roles, group / service-principal membership, and fine-grained data access.

Every subcommand targets exactly one principal, chosen with one of:

FlagTarget
--user EMAILA user, by email
--group NAMEA group
--service-principal NAMEA service principal

To revoke, use the sibling command oh revoke.


oh grant privilege NAME​

Grants one or more privileges on the object NAME, or on every child of a container.

Flags​

FlagRequiredDescription
--privilege PRIVILEGEYesPrivilege (repeatable), e.g. SELECT, INSERT, MANAGE. Grade roles — viewer, editor, user, manager — must be granted on their own.
--on OBJECT_TYPEOne of --on / --on-allType of the object NAME (e.g. TABLE, DATABASE, LAKE)
--on-all CHILD_TYPEOne of --on / --on-allEvery current and future child of the container NAME (tables or databases)
--in CONTAINER_TYPEWith --on-allContainer type: database for --on-all tables, lake for --on-all databases
--user / --group / --service-principalYesPrincipal

Group principals​

The server looks up a --group within the project only. Grant the group a project role (oh grant role) first, otherwise the command fails with Entity of type: GROUP not found.

# SELECT on one table
oh grant privilege my-lake.events.clicks \
--privilege SELECT --on TABLE \
--user alice@example.com

# SELECT and INSERT on every table in a database
oh grant privilege my-lake.events \
--privilege SELECT --privilege INSERT \
--on-all tables --in database \
--group analytics

# EDITOR grade role (must be granted alone)
oh grant privilege my-lake.events \
--privilege editor --on DATABASE \
--user alice@example.com

oh grant role ROLE NAME​

Grants a role (admin, member or reader) on the project or account NAME.

FlagRequiredDescription
--onYesPROJECT or ACCOUNT. --on ACCOUNT only works with --service-principal and the server ignores NAME.
--user / --group / --service-principalYesPrincipal
oh grant role admin my-project --on PROJECT --user alice@example.com
oh grant role member my-project --on PROJECT --group analytics
oh grant role admin ignored --on ACCOUNT --service-principal ci-bot

oh grant member NAME​

Adds a principal as member (default) or manager of the group or service principal NAME.

FlagRequiredDescription
--onYesGROUP or SERVICE_PRINCIPAL
--roleNomember (default) or manager
--user / --group / --service-principalYesPrincipal to add

Allowed principal types​

  • --on GROUP takes --user or --service-principal.
  • --on SERVICE_PRINCIPAL takes --user or --group.
oh grant member analytics --on GROUP --user alice@example.com
oh grant member analytics --on GROUP --service-principal ci-bot --role manager
oh grant member ci-bot --on SERVICE_PRINCIPAL --group analytics

oh grant row-filter EXPRESSION​

Restricts the principal to only see rows of --table that match EXPRESSION.

FlagRequiredDescription
--tableYesFully-qualified table (lake.database.table)
--user / --group / --service-principalYesPrincipal
oh grant row-filter "region = 'EU'" \
--table my-lake.events.clicks \
--user alice@example.com

oh grant column-mask COLUMN​

Masks COLUMN of --table for the principal. Exactly one of --mask-type or --custom is required.

FlagRequiredDescription
--tableYesFully-qualified table
--mask-typeOne of --mask-type / --customBuilt-in mask (e.g. mask-hash, mask-show-last-4)
--custom EXPRESSIONOne of --mask-type / --customCustom mask expression
--user / --group / --service-principalYesPrincipal
oh grant column-mask ssn \
--table my-lake.customers.profiles \
--mask-type mask-show-last-4 \
--user alice@example.com

oh grant column-mask email \
--table my-lake.customers.profiles \
--custom "regexp_replace(email, '.+@', '***@')" \
--group analytics

oh grant column-access COLUMN...​

Restricts the principal to only see the listed columns of --table. Columns may be space-separated or comma-separated.

FlagRequiredDescription
--tableYesFully-qualified table
--user / --group / --service-principalYesPrincipal
oh grant column-access id event_time region \
--table my-lake.events.clicks \
--group analytics

oh grant column-access "id,event_time,region" \
--table my-lake.events.clicks \
--user alice@example.com

oh grant data-admin​

Grants DATA_ADMIN, which is organisation-wide and takes no object.

FlagRequiredDescription
--user / --group / --service-principalYesPrincipal
oh grant data-admin --user alice@example.com

oh grant show NAME​

Lists the grants on the object NAME.

FlagRequiredDescription
--onYesType of the object NAME
oh grant show my-lake.events.clicks --on TABLE

oh grant show-roles NAME​

Lists the roles a type of principal holds on the project NAME.

FlagRequiredDescription
--principal-typeYesUSER, GROUP or SERVICE_PRINCIPAL
--onNoObject type (defaults to PROJECT)
oh grant show-roles my-project --principal-type USER
oh grant show-roles my-project --principal-type GROUP