datacatalog.categories.setIamPolicy
datacatalog.taxonomies.create
datacatalog.taxonomies.delete
datacatalog.taxonomies.get
datacatalog.taxonomies.getIamPolicy
datacatalog.taxonomies.list
datacatalog.taxonomies.setIamPolicy
datacatalog.taxonomies.update
resourcemanager.projects.get
resourcemanager.projects.list
Applies at the project level.
This role grants the ability to do the following:
You need one of the following BigQuery roles to create and manage data policies:
Role/ID | Permissions | Description |
---|---|---|
BigQuery Data Policy Admin/bigquerydatapolicy.admin BigQuery Admin/ bigquery.admin BigQuery Data Owner/ bigquery.dataOwner | bigquery.dataPolicies.create bigquery.dataPolicies.delete bigquery.dataPolicies.get bigquery.dataPolicies.getIamPolicy bigquery.dataPolicies.list bigquery.dataPolicies.setIamPolicy bigquery.dataPolicies.update | The This role grants the ability to do the following:
|
datacatalog.taxonomies.get
permission, which you can get from several of the Data Catalog predefined roles. You need the datacatalog.taxonomies.get
and bigquery.tables.setCategory
permissions to attach policy tags to columns. datacatalog.taxonomies.get
is included in the Data Catalog Policy Tags Admin and Viewer roles. bigquery.tables.setCategory
is included in the BigQuery Admin (roles/bigquery.admin
) and BigQuery Data Owner (roles/bigquery.dataOwner
) roles.
You need the BigQuery Masked Reader role to query the data from a column that has data masking applied.
Role/ID | Permissions | Description |
---|---|---|
Masked Reader/bigquerydatapolicy.maskedReader | bigquery.dataPolicies.maskedGet | Applies at the data policy level. This role grants the ability to view the masked data of a column that is associated with a data policy. Additionally, a user must have appropriate permissions to query the table. For more information, see Required permissions. |
Data masking builds on top of column-level access control. For a given column, it is possible to have some users with the BigQuery Masked Reader role that allows them to read masked data, some users with the Data Catalog Fine-Grained Reader role that allows them to read unmasked data, some users with both, and some users with neither. These roles interact as follows:
In the case where a table has columns that are secured or secured and masked, in order to run a SELECT * FROM
statement on that table, a user must be a member of appropriate groups such that they are granted Masked Reader or Fine-Grained Reader roles on all of these columns.
A user who is not granted these roles must instead specify only columns that they have access to in the SELECT
statement, or use SELECT * EXCEPT (restricted_columns) FROM
to exclude the secured or masked columns.
Roles are evaluated starting at the policy tag associated with a column, and then checked at each ascending level of the taxonomy, until the user either is determined to have appropriate permissions or the top of the policy tag hierarchy is reached.
For example, take the policy tag and data policy configuration shown in Figure 4:
Figure 4. Policy tag and data policy configuration.
You have a table column that is annotated with the Financial
policy tag, and a user who is a member of both the ftes@example.com and analysts@example.com groups. When this user runs a query that includes the annotated column, their access is determined by the hierarchy defined in the policy tag taxonomy. Because the user is granted the Data Catalog Fine-Grained Reader role by the Financial
policy tag, the query returns unmasked column data.
If another user who is only a member of the ftes@example.com role runs a query that includes the annotated column, the query returns column data that has been hashed using the SHA-256 algorithm, because the user is granted the BigQuery Masked Reader role by the Confidential
policy tag, which is the parent of the Financial
policy tag.
A user who is not a member of either of those roles gets an access denied error if they try to query the annotated column.
In contrast with the preceding scenario, take the policy tag and data policy configuration shown in Figure 5:
Figure 5. Policy tag and data policy configuration.
You have the same situation as shown in Figure 4, but the user is granted the Fine-Grained Reader role at a higher level of the policy tag hierarchy, and the Masked Reader role at a lower level of the policy tag hierarchy. Because of this, the query returns masked column data for this user. This happens even though the user is granted the Fine-Grained Reader role further up the tag hierarchy, because the service uses the first assigned role it encounters as it ascends the policy tag hierarchy to check for user access.
If you want to create a single data policy and have it apply to several levels of a policy tag hierarchy, you can set the data policy on the policy tag that represents the topmost hierarchy level to which it should apply. For example, take a taxonomy with the following structure:
If you want a data policy to apply to all of these policy tags, set the data policy on policy tag 1. If you want a data policy to apply to policy tag 1b and its children, set the data policy on policy tag 1b.
When you use BigQuery features that aren't compatible with data masking, the service treats the masked column as a secured column, and only grants access to users who have the Data Catalog Fine-Grained Reader role.
For example, take the policy tag and data policy configuration shown in Figure 6:
Figure 6. Policy tag and data policy configuration.
You have a table column that is annotated with the Financial
policy tag, and a user who is a member of the analysts@example.com group. When this user tries to access the annotated column through one of the incompatible features, they get an access denied error. This is because they are granted the BigQuery Masked Reader by Financial
policy tag, but in this case, they must have the Data Catalog Fine-Grained Reader role. Because the service has already determined an applicable role for the user, it does not continue to check farther up the policy tag hierarchy for additional permissions.
To see how tags, principals, and roles work together, consider this example.
At example.com, basic access is granted through the data-users@example.com group. All employees who need regular access to BigQuery data are members of this group, which is assigned all the necessary permissions to read from tables as well as the BigQuery Masked Reader role.
Employees are assigned to additional groups that provide access to secured or masked columns where that is required for their work. All members of these additional groups are also members of data-users@example.com. You can see how these groups are associated with appropriate roles in Figure 7:
Figure 7. Policy tags and data policies for example.com.
The policy tags are then associated with table columns, as shown in Figure 8:
Figure 8. Example.com policy tags associated with table columns.
Given the tags that are associated with the columns, running SELECT * FROM Accounts;
leads to the following results for the different groups:
data-users@example.com: This group has been granted the BigQuery Masked Reader role on both the PII
and Confidential
policy tags. The following results are returned:
SSN | Priority | Lifetime value | Creation date | |
---|---|---|---|---|
NULL | "" | 0 | March 8, 1983 | NULL |
NULL | "" | 0 | December 29, 2009 | NULL |
NULL | "" | 0 | July 14, 2021 | NULL |
NULL | "" | 0 | May 5, 1997 | NULL |
accounting@example.com: This group has been granted the Data Catalog Fine-Grained Reader role on the SSN
policy tag. The following results are returned:
SSN | Priority | Lifetime value | Creation date | NULL |
---|---|---|---|---|
123-45-6789 | "" | 0 | March 8, 1983 | NULL |
234-56-7891 | "" | 0 | December 29, 2009 | NULL |
345-67-8912 | "" | 0 | July 14, 2021 | NULL |
456-78-9123 | "" | 0 | May 5, 1997 | NULL |
sales-exec@example.com: This group has been granted the Data Catalog Fine-Grained Reader role on the Confidential
policy tag. The following results are returned:
SSN | Priority | Lifetime value | Creation date | |
---|---|---|---|---|
NULL | High | 90,000 | March 8, 1983 | NULL |
NULL | High | 84,875 | December 29, 2009 | NULL |
NULL | Medium | 38,000 | July 14, 2021 | NULL |
NULL | Low | 245 | May 5, 1997 | NULL |
fin-dev@example.com: This group has been granted the BigQuery Masked Reader role on the Financial
policy tag. The following results are returned:
SSN | Priority | Lifetime value | Creation date | |
---|---|---|---|---|
NULL | "" | Zmy9vydG5q= | March 8, 1983 | NULL |
NULL | "" | GhwTwq6Ynm= | December 29, 2009 | NULL |
NULL | "" | B6y7dsgaT9= | July 14, 2021 | NULL |
NULL | "" | Uh02hnR1sg= | May 5, 1997 | NULL |
All other users: Any user who does not belong to one of the listed groups gets an access denied error, because they haven't been granted the Data Catalog Fine-Grained Reader or BigQuery Masked Reader roles. To query the Accounts
table, they must instead specify only columns that they have access to in the SELECT * EXCEPT (restricted_columns) FROM Accounts
to exclude the secured or masked columns.
Data masking might indirectly affect the number of bytes processed, and therefore affect the cost of the query. If a user queries a column that is masked for them with the Nullify or Default Masking Value rules, then that column isn't scanned at all, resulting in fewer bytes processed.
The following sections describe the categories of restrictions and limitations that data masking is subject to.
A policy tag hierarchy can be no more than five levels deep from the root node to the lowest-level subtag, as shown in the following screenshot:
After a taxonomy has a data policy associated with at least one of its policy tags, access control is automatically enforced. If you want to turn off access control, you must first delete all of the data policies associated with the taxonomy.
If you have existing materialized views, repeated record masking queries on the associated base table fail. To resolve this issue, delete the materialized view. If the materialized view is needed for other reasons, you can create it in another dataset.
Queries that include data masking on the partitioned or clustered columns are not supported.
Legacy SQL is not supported.
Custom masking routines are subject to the following limitations:
STRUCT
, because data masking can only apply to leaf fields of the STRUCT
data type.Permission denied.
Dangling references to empty masking rules might be cleaned by automated processes after seven days.Not compatible with the tabledata.list
method. To call tabledata.list
, you need full access to all of the columns returned by this method. The Data Catalog Fine-Grained Reader role grants appropriate access.
Compatible. Data masking policies are enforced on BigLake tables.
Compatible. Data masking policies are enforced in the BigQuery Storage Read API.
Compatible. Data masking policies are enforced in the BI Engine. Queries that have data masking in effect are not accelerated by BI Engine. Use of such queries in Looker Studio might cause related reports or dashboards to become slower and more expensive.
Compatible. Data masking policies are enforced on the BigQuery Omni tables.
Not compatible. Collation is not supported on masked columns.
Not compatible. To copy a table from source to the destination, you need to to have full access to all of the columns on the source table. The Data Catalog Fine-Grained Reader role grants appropriate access.
Compatible. If you have the BigQuery Masked Reader role, then the exported data is masked. If you have the Data Catalog Fine-Grained Reader role, then the exported data is not masked.
Compatible. Data masking is applied on top of row-level security. For example, if there is a row access policy applied on location = "US"
and location
is masked, then users are able to see rows where location = "US"
but the location field is masked.
Partially compatible. You can call the SEARCH
function on indexed or unindexed columns that have data masking applied.
When you call the SEARCH
function on columns that have data masking applied, you must use search criteria compatible with your level of access. For example, if you have Masked Reader access with a Hash (SHA-256) data masking rule, you would use the hash value in your SEARCH
clause, similar to the following:
SELECT*FROMmyDataset.CustomersWHERESEARCH(Email,"sg172y34shw94fujaweu");
If you have Fine-Grained Reader access, you would use the actual column value in your SEARCH
clause, similar to the following:
SELECT*FROMmyDataset.CustomersWHERESEARCH(Email,"jane.doe@example.com");
Searching is less likely to be useful if you have Masked Reader access to a column where the data masking rule used is Nullify or Default Masking Value. This is because the masked results you would use as search criteria, such as NULL
or ""
, aren't sufficiently unique to be useful.
When searching on an indexed column that has data masking applied, the search index is only used if you have Fine-Grained Reader access to the column.
Not compatible. To create a snapshot of a table, you need full access to all of the columns on the source table. The Data Catalog Fine-Grained Reader role grants appropriate access.
Compatible. Table renaming is not affected by data masking.
Compatible with both time decorators and the FOR SYSTEM_TIME AS OF
option in SELECT
statements. The policy tags for the current dataset schema are applied to the retrieved data.
Partly compatible. BigQuery caches query results for approximately 24 hours, although the cache is invalidated if changes are made to the table data or schema before that. In the following circumstance, it is possible that a user who does not have the Data Catalog Fine-Grained Reader role granted on a column can still see the column data when they run a query:
Not compatible. You need full access to all of the referenced columns on all of the tables matching the wildcard query. The Data Catalog Fine-Grained Reader role grants appropriate access.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-04-17 UTC.