Authorized datasets

This document describes how to useauthorized datasets inBigQuery.An authorized dataset lets you authorize all of the views in a specifieddataset to access the data in a second dataset.With an authorizeddataset, you don't need to configure individualauthorized views.

Overview

Aview in BigQuery is a virtualtable defined by a SQL query. For example, a view's querymight return only a subset of the columns of a table, excluding columnsthat contain personal identifiable information (PII). To query a view, a userneeds to haveaccess to the resources that are accessed by the view's query.

Authorized views

If you want to let users query a view, without giving them direct access to theresources referenced by the view, you can use anauthorized view. When you create anauthorized view, you can share either a logical view or a materializedview. When you authorize a materialized view, it's referred to as anauthorized materialized view.

An authorized view lets you, for example, share more limited data in a view withspecified groups or users (principals), without giving the principalsaccess to all of the underlying data. Principals can view the data you share andrun queries on it, but they can't access the source dataset directly. Instead,the authorized view has access to the source data.

Authorized datasets

If you want to give acollection of views access to a dataset, without havingto authorize each individual view, you can group the views together into adataset, and then give the dataset that contains the views access to the datasetthat contains the data. You can then give principals access to the dataset withthe group of views, or to individual views in the dataset, as needed.

A dataset that has access to another dataset is called anauthorized dataset.The dataset that authorizes another dataset to access its data is calledtheshared dataset.

Note: Because all current and future views in an authorized dataset have access to the tables in the shared dataset, BigQuery requires additional permissions to create or update the views in an authorized dataset, beyond the permissions that are required to create or update views in a standard dataset. For more information, seeCreate or update a view in an authorized dataset.

Required permissions and roles

To authorize a dataset, or to revoke a dataset's authorization, you must havethe followingIdentity and Access Management (IAM) permissions,which let you update the access control list of the dataset you are sharing.

After a dataset is authorized, you can create or update views in the authorizeddataset. For more information and required permissions, seeCreate or update a view in an authorized dataset.

PermissionResource
bigquery.datasets.getThe dataset you are sharing.
bigquery.datasets.updateThe dataset you are sharing.

The following predefinedIAM rolesprovide the required permissions.

RoleDescription
bigquery.dataOwnerBigQuery Data Owner
bigquery.adminBigQuery Admin

Quotas and limits

Authorized datasets are subject to dataset limits. For more information,seeDataset limits.

A dataset's access control list can have up to 2,500 total authorized resources, includingauthorized views,authorized datasets, andauthorized functions. If you exceed this limit due to a large number of authorized views, consider grouping the views into authorized datasets. As a best practice, group related views into authorized datasets when you design new BigQuery architectures, especially multi-tenant architectures.

Authorize a dataset

You can authorize a dataset's current and future views to access another datasetby adding the dataset you want to authorize to the access list of the datasetyou want to share, as follows:

Console

  1. In the Google Cloud console, go to theBigQuery page.

    Go to BigQuery

  2. In the left pane, clickExplorer:

    Highlighted button for the Explorer pane.

    If you don't see the left pane, clickExpand left pane to open the pane.

  3. In theExplorer pane, expand your project, clickDatasets, andthen click a dataset.

  4. In the details pane that appears, clickSharing and select theAuthorize Datasets option.

    Authorize a dataset in the Google Cloud console

  5. In theAuthorized dataset pane that appears, enter theDataset IDof the dataset that you want to authorize, in the following format:

    PROJECT.AUTHORIZED_DATASET

    For example:

    myProject.myDataset

  6. ClickAdd Authorization and then clickClose.

bq

  1. Open the Cloud Shell:

    Go to Cloud Shell

  2. Write the existing metadata (including the access control list) for thedataset you want to share into aJSON file by using thebq show command.

    bqshow--format=prettyjsonPROJECT:SHARED_DATASET>FILE_PATH
  3. Use a text editor to add the dataset that you want to authorizeinto the existingaccess section of the JSON file that was created atFILE_PATH.

    For example:

    "access":[...{"dataset":{"dataset":{"project_id":"PROJECT","dataset_id":"AUTHORIZED_DATASET"},"target_types":"VIEWS"}}]

  4. Update the shared dataset by using thebq updatecommand. For example:

    bqupdate--sourceFILE_PATHPROJECT:SHARED_DATASET
  5. To verify that the authorized dataset has been added, enter thebq showcommand again. For example:

    bqshow--format=prettyjsonPROJECT:SHARED_DATASET

API

  1. Get the current metadata for the dataset you want to share by calling thedatasets.getmethod, as follows:

    GEThttps://bigquery.googleapis.com/bigquery/v2/projects/PROJECT/datasets/SHARED_DATASET

    The response body returns aDatasetresource that contains JSON metadata for the dataset.

  2. Add the dataset that you want authorize into theaccesssection of the JSON metadata that was returned in theDataset resource asfollows:

    "access":[...{"dataset":{"dataset":{"project_id":"PROJECT","dataset_id":"AUTHORIZED_DATASET"},"target_types":"VIEWS"}}]
  3. Use thedatasets.updatemethod to update the dataset with the added authorization:

    PUThttps://bigquery.googleapis.com/bigquery/v2/projects/PROJECT/datasets/SHARED_DATASET

    Include the updatedDataset resource in the request body.

  4. You can verify that the authorized dataset has been added by calling thedatasets.getmethod again.

Revoke a dataset's authorization

When you delete a dataset authorized to access another source dataset, it cantake up to 24 hours for the change to fully reflect in the source dataset'saccess control lists (ACLs). During thistime:

  • You won't be able to access the source data through the deleted dataset.
  • The deleted dataset might still appear in the source dataset's ACL and counttowards any authorized dataset limits. This could prevent you from creatingnew authorized datasets until the ACL is updated.

To revoke the access granted to the views in an authorized dataset, remove theauthorized dataset from the shared dataset's access list, asfollows:

Console

  1. In the Google Cloud console, go to theBigQuery page.

    Go to BigQuery

  2. In the left pane, clickExplorer:

    Highlighted button for the Explorer pane.

  3. In theExplorer pane, expand your project, clickDatasets, andthen click a dataset.

  4. In the details pane that appears, clickSharing and select theAuthorize Datasets option.

    Authorize a dataset in the Google Cloud console

  5. In theAuthorized dataset pane that appears, find the entry for theauthorized dataset in theCurrently authorized datasets section.

  6. Click the delete icon next to the authorized dataset you want to remove,and then clickClose.

bq

  1. Open the Cloud Shell:

    Go to Cloud Shell

  2. Write the existing metadata (including the access control list) for theshared dataset into a JSON file by using thebq show command.

    bqshow--format=prettyjsonPROJECT:SHARED_DATASET>FILE_PATH
  3. Use a text editor to remove the authorized dataset from theaccesssection of the JSON file that was created atFILE_PATH, asfollows:

    {"dataset":{"dataset":{"project_id":"PROJECT","dataset_id":"AUTHORIZED_DATASET"},"target_types":"VIEWS"}}
  4. Update the shared dataset by using thebq updatecommand. For example:

    bqupdate--sourceFILE_PATHPROJECT:SHARED_DATASET
  5. To verify that the authorized dataset has been removed, enter thebq showcommand again.For example:

    bqshow--format=prettyjsonPROJECT:SHARED_DATASET

API

  1. Get the current metadata for the shared dataset by calling thedatasets.getmethod, as follows:

    GEThttps://bigquery.googleapis.com/bigquery/v2/projects/PROJECT/datasets/SHARED_DATASET

    The response body returns aDatasetresource that contains JSON metadata for the dataset.

  2. Remove the authorized dataset from theaccesssection of the JSON that was returned in theDataset resource, forexample:

    {"dataset":{"dataset":{"project_id":"PROJECT","dataset_id":"AUTHORIZED_DATASET"},"target_types":"VIEWS"}}
  3. Use thedatasets.updatemethod to update the dataset with the removed authorization:

    PUThttps://bigquery.googleapis.com/bigquery/v2/projects/PROJECT/datasets/SHARED_DATASET

    Include the updatedDataset resource in the request body.

  4. You can verify that the authorized dataset has been removed by calling thedatasets.getmethod again.

Create or update a view in an authorized dataset

To create or update a view that is in an authorized dataset,you must have the permissions for the shared dataset that are listed inRequired permissions and roles,in addition to the permissions that are required tocreate orupdate a view in astandard dataset.

The following table summarizes the necessaryIdentity and Access Management (IAM) permissionsto create or update a view that is in an authorized dataset:

PermissionResource
bigquery.datasets.getThe dataset you are sharing.
bigquery.tables.getDataAny tables or views from the shared dataset that are referencedin the new view you are creating or updating.
bigquery.tables.createThe authorized dataset in which you are creating a view.
bigquery.tables.updateThe authorized dataset in which you are updating a view.

You don't need any additional permissions todelete a view from anauthorized dataset.

Query a view in an authorized dataset

To query a view in an authorized dataset, a user needs to have access to theview, but access to the shared dataset is not required.

For more information, seeAuthorized views.

Authorized dataset example

The following example describes how to create and use an authorized dataset.

Assume you have two datasets, namedprivate_dataset andpublic_dataset.Theprivate_dataset dataset contains a table namedprivate_table. Thepublic_dataset dataset contains a view namedprivate_table_filtered. Theprivate_table_filtered view is based on a query that returns some, but notall, of the fields in theprivate_table table.

You can give a user access tothe data returned by theprivate_table_filtered view, but not all of the datain theprivate_table table, as follows:

  1. Grant thebigquery.dataViewer role to the user for thepublic_datasetdataset. This role includes thebigquery.tables.getData permission, whichlets the user query the views in thepublic_dataset dataset.For information about how to grant a role to a user for a dataset, seeControlling access to datasets.

    The user now has permission to query views in thepublic_dataset,but they still cannot access theprivate_table table inprivate_dataset. If the user tries to query theprivate_table tabledirectly, or if they try to access theprivate_table table indirectly byquerying theprivate_table_filtered view,they get an error message similar to the following:

    Access Denied: TablePROJECT:private_dataset.private_table:User does not have permission to query tablePROJECT:private_dataset.private_table.

  2. In theBigQuery page of the Google Cloud console, open theprivate_datasetdataset, clickSharing, and then selectAuthorize Datasets.

  3. In theAuthorized dataset pane that appears, enterPROJECT.public_dataset in theDataset ID field,and then clickAdd Authorization.

    Thepublic_dataset dataset is added to the access control list of theprivate_dataset dataset, authorizing the views in thepublic_datasetdataset to query the data in theprivate_dataset dataset.

    The user can now query theprivate_table_filtered view in thepublic_dataset dataset, which indirectly accesses theprivate_datasetdataset, without having any permissions to directly access data in theprivate_dataset dataset.

Limitations

  • You can create authorized datasets in different regions,but BigQuery doesn't support cross-region queries. Therefore,we recommend that you create datasets in the same region.

What's next

  • For information about authorizing an individual view to access data in adataset, seeAuthorized views.

  • For information about authorizing a table function or a user-defined functionto access data in a dataset, seeAuthorized functions.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.