In the Authorized dataset pane that appears, find the entry for the authorized dataset in the Currently authorized datasets section.
Click the delete icon next to the authorized dataset you want to remove, and then click Close.
Open the Cloud Shell:
Write the existing metadata (including the access control list) for the shared dataset into a JSON file by using the bq show
command.
bqshow--format=prettyjsonPROJECT:SHARED_DATASET>FILE_PATH
Use a text editor to remove the authorized dataset from the access
section of the JSON file that was created at FILE_PATH, as follows:
{"dataset":{"dataset":{"project_id":"PROJECT","dataset_id":"AUTHORIZED_DATASET"},"target_types":"VIEWS"}}
Update the shared dataset by using the bq update
command. For example:
bqupdate--sourceFILE_PATHPROJECT:SHARED_DATASET
To verify that the authorized dataset has been removed, enter the bq show
command again. For example:
bqshow--format=prettyjsonPROJECT:SHARED_DATASET
Get the current metadata for the shared dataset by calling the datasets.get
method, as follows:
GEThttps://bigquery.googleapis.com/bigquery/v2/projects/PROJECT/datasets/SHARED_DATASET
The response body returns a Dataset
resource that contains JSON metadata for the dataset.
Remove the authorized dataset from the access
section of the JSON that was returned in the Dataset
resource, for example:
{"dataset":{"dataset":{"project_id":"PROJECT","dataset_id":"AUTHORIZED_DATASET"},"target_types":"VIEWS"}}
Use the datasets.update
method to update the dataset with the removed authorization:
PUThttps://bigquery.googleapis.com/bigquery/v2/projects/PROJECT/datasets/SHARED_DATASET
Include the updated Dataset
resource in the request body.
You can verify that the authorized dataset has been removed by calling the datasets.get
method again.
To create or update a view that is in an authorized dataset, you must have the permissions for the shared dataset that are listed in Required permissions and roles, in addition to the permissions that are required to create or update a view in a standard dataset.
The following table summarizes the necessary Identity and Access Management (IAM) permissions to create or update a view that is in an authorized dataset:
Permission | Resource |
---|---|
bigquery.datasets.get | The dataset you are sharing. |
bigquery.tables.getData | Any tables or views from the shared dataset that are referenced in the new view you are creating or updating. |
bigquery.tables.create | The authorized dataset in which you are creating a view. |
bigquery.tables.update | The authorized dataset in which you are updating a view. |
You don't need any additional permissions to delete a view from an authorized dataset.
To query a view in an authorized dataset, a user needs to have access to the view, but access to the shared dataset is not required.
For more information, see Authorized views.
The following example describes how to create and use an authorized dataset.
Assume you have two datasets, named private_dataset
and public_dataset
. The private_dataset
dataset contains a table named private_table
. The public_dataset
dataset contains a view named private_table_filtered
. The private_table_filtered
view is based on a query that returns some, but not all, of the fields in the private_table
table.
You can give a user access to the data returned by the private_table_filtered
view, but not all of the data in the private_table
table, as follows:
Grant the bigquery.dataViewer
role to the user for the public_dataset
dataset. This role includes the bigquery.tables.getData
permission, which lets the user query the views in the public_dataset
dataset. For information about how to grant a role to a user for a dataset, see Controlling access to datasets.
The user now has permission to query views in the public_dataset
, but they still cannot access the private_table
table in private_dataset
. If the user tries to query the private_table
table directly, or if they try to access the private_table
table indirectly by querying the private_table_filtered
view, they get an error message similar to the following:
Access Denied: Table PROJECT:private_dataset.private_table: User does not have permission to query table PROJECT:private_dataset.private_table.
In the BigQuery page of the Google Cloud console, open the private_dataset
dataset, click Sharing, and then select Authorize Datasets.
In the Authorized dataset pane that appears, enter PROJECT.public_dataset
in the Dataset ID field, and then click Add Authorization.
The public_dataset
dataset is added to the access control list of the private_dataset
dataset, authorizing the views in the public_dataset
dataset to query the data in the private_dataset
dataset.
The user can now query the private_table_filtered
view in the public_dataset
dataset, which indirectly accesses the private_dataset
dataset, without having any permissions to directly access data in the private_dataset
dataset.
For information about authorizing an individual view to access data in a dataset, see Authorized views.
For information about authorizing a table function or a user-defined function to access data in a dataset, see Authorized functions.
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.