Docs/Error messages/Access Denied: policy tag on a column
Error messagesPermissions

Access Denied: neither fine-grained reader nor masked get permission

A column in the query has a policy tag and you hold no role on it. The message names the tag and every refused column. Which queries it refuses, how to read the column names, and how to leave the columns out.

Access Denied: BigQuery BigQuery: User has neither fine-grained reader nor masked get permission to get data protected by policy tag "Finance : pii" on column mydataset.customers.ssn.

What BigQuery means

A column in the query carries a policy tag, and your account holds neither the Fine-Grained Reader role on that tag nor the Masked Reader role. BigQuery refuses the whole query. The HTTP status is 403 and the reason is accessDenied. A dry run gets the same error, so the editor shows it before you run anything.

The text names the tag as taxonomy : tag and the column as dataset.table.column.

What counts as reading the column

Any use of it does: the select list, WHERE, ORDER BY, a function argument, an aggregate such as MAX(ssn). A SELECT * reads every column, so one tagged column breaks it for everyone without access. A RECORD is refused whole when any one of its fields has a tag. A field next to it that has no tag can still be read on its own.

A view that selects the column behaves the same way for its readers. Columns of the view that do not come from a tagged column are fine.

Reading the message

  • The sentence repeats once for every refused column, in no fixed order. SELECT * over a table with three tagged columns lists three.
  • A nested field is written with dots: mydataset.customers.address.street is the field street of the RECORD address.
  • Through a view the column is written with the project in front: my-project.mydataset.customers.ssn. The table named is the view’s underlying table, which your query may not mention.
  • Reading rows with the API (tabledata.list, which is what a table preview uses) gives a second wording, with a colon after the project:
User does not have permission to access data protected by policy tag "Finance : pii" on column my-project:mydataset.customers.ssn.

Leave the columns out

Name the columns you need, or exclude the refused ones:

SELECT * EXCEPT (ssn, address)
FROM mydataset.customers

For a field inside a RECORD, except the RECORD: EXCEPT (address), not EXCEPT (address.street). BigQuery refuses the whole RECORD, so the field cannot be left out on its own.

If the column is in a WHERE, a join condition, a GROUP BY or a function, leaving it out changes what the query means. Rewrite the query to use another column, or ask the owner of the taxonomy for access.

Ask for access

The owner of the taxonomy grants roles/datacatalog.categoryFineGrainedReader on the tag, or roles/bigquerydatapolicy.maskedReader on its data policy. A masked reader can run the query and gets hashed, nulled or truncated values, so a filter or an average over that column does not use the real data. See Column-level security. A grant took a few minutes to apply when we tried it.

In Querylab.io

The dry run runs as you type, so the editor marks every place the query reads a refused column, and the star of a SELECT * that expands to one. When the query does not write the column out, the mark goes on the table. The message says which columns and which tags, in one plain sentence. The status bar, the Info tab, History and the child jobs show that sentence too, with a link to show BigQuery’s original message.

After a failed run the status bar offers Leave out these columns. In History the same fix is a button in the detail pane of the failed row, and it opens the corrected query in a new tab. It rewrites SELECT * to SELECT * EXCEPT (...), or removes the column from an explicit select list. A column removed from a RECORD takes the whole RECORD with it, and the message says so.

The fix is not offered when:

  • the column is in WHERE, a join, GROUP BY, HAVING, QUALIFY or ORDER BY, or inside an expression
  • the columns are read in a subquery, a CTE or a UNION, because the query around them may use the column
  • the query is SELECT DISTINCT, because rows that differ only in the left-out column would merge
  • the query has GROUP BY ALL, because the groups would change
  • GROUP BY or ORDER BY counts items by position (ORDER BY 2, ROLLUP(1, 2)), or another clause reads the item’s alias
  • the item is a whole row (SELECT t), or removing it would leave nothing to select
  • the query does not write the column out, for example because it reads a view

The message then says which one it is.

See also Access Denied: no permission to query table, which is a table-level refusal.