Manage data exchanges
This document describes how to manage data exchanges in BigQuery sharing (formerly Analytics Hub). As a BigQuery sharing administrator, you can do the following:
- Create, update, view, share, and delete data exchanges .
- Create, update, delete, and share listings.
- Manage BigQuery sharing administrators, listing administrators, publishers, subscribers, and viewers.
By default, a data exchange is private. Only users or groups with access to
an exchange can view or subscribe to its data. You can request to make your data exchange public
.
Making your data exchange public allows Google Cloud users ( allAuthenticatedUsers
)
to discover
and subscribe to
listings.
Before you begin
To get started with BigQuery sharing (formerly Analytics Hub), you need to enable the Analytics Hub API inside your Google Cloud project.
To enable the Analytics Hub API, you need the following Identity and Access Management (IAM) permissions:
-
serviceUsage.services.get -
serviceUsage.services.list -
serviceUsage.services.enable
The following predefined IAM role includes the permissions that you need to enable the Analytics Hub API:
- Service Usage Admin
(
roles/serviceusage.serviceUsageAdmin)
To enable the Analytics Hub API, select one of the following options:
Console
Go to the Analytics Hub APIpage and enable the Analytics Hub API for your Google Cloud project.
gcloud
Run the gcloud services enable command:
gcloud services enable analyticshub.googleapis.com
Required roles
To get the permissions that
you need to manage data exchanges,
ask your administrator to grant you the Analytics Hub Admin role
( roles/analyticshub.admin
)
IAM role on your project.
For more information about granting roles, see Manage access to projects, folders, and organizations
.
You might also be able to get the required permissions through custom roles or other predefined roles .
Create a data exchange
To create a data exchange, follow these steps:
Console
-
Go to the Sharing (Analytics Hub)page.
-
Click Create exchange.
-
In the Create exchangedialog, select a Projectand a Regionfor your data exchange. You can't update the project and region after you create the data exchange.
-
In the Display namefield, enter a name for your data exchange.
-
Optional: Enter values in the following fields:
- Primary contact: enter the URL or the email address of the primary contact for the data exchange.
- Description: enter a description for the data exchange.
-
To log the principal identifiers of all users running jobs and queries on linked datasets, click the Subscriber Email Loggingtoggle. When you enable this option, all future listings under the data exchange have subscriber email logging turned on. The logged data is available in the
job_principal_subjectfield of theINFORMATION_SCHEMA.SHARED_DATASET_USAGEview . -
To enable public discoverability, click the Public Discoverabilitytoggle. When an exchange is publicly discoverable, all listings in the exchange appear and are searchable in the catalog. If you enable public discoverability, configure the exchange permissions. All listings inherit the data exchange's public discoverability setting by default. This setting inheritance means public exchanges can't have private listings, but private exchanges can have public listings. You can set the public discoverability type at the individual listing level. The project where you create the data exchange must have an associated organization and billing account.
-
Click Create Exchange.
-
Optional: In the Exchange Permissionssection, complete the following steps:
-
Enter email addresses in the following fields to grant the Identity and Access Management (IAM) roles:
- Administrators: assign the Analytics Hub Admin role
(
roles/analyticshub.admin) to these users. - Publishers: assign the Analytics Hub Publisher role
(
roles/analyticshub.publisher) to these users. For information about the tasks that BigQuery sharing publishers can perform, see Manage listings . - Subscribers: assign the Analytics Hub Subscriber role
(
roles/analyticshub.subscriber) to these users. For information about the tasks that BigQuery sharing subscribers can perform, see View and subscribe to listings and data exchanges . -
Viewers: assign the Analytics Hub Viewer role (
roles/analyticshub.viewer) to these users. BigQuery sharing viewers can view listings .If public discoverability is enabled, grant the Analytics Hub Viewer role to
allUsersorallAuthenticatedUsers.
- Administrators: assign the Analytics Hub Admin role
(
-
To save permissions, click Set permissions.
-
-
If you didn't set permissions for your data exchange, click Skip.
API
Use the projects.locations.dataExchanges.create
method
.
POST https://analyticshub.googleapis.com/v1/projects/ PROJECT_ID /location/ LOCATION /dataExchanges?dataExchangeId= DATAEXCHANGE_ID
Replace the following:
-
PROJECT_ID: the ID of the project where you want to create the data exchange. -
LOCATION: the location for your data exchange. For more information about locations that support BigQuery sharing, see Supported regions . -
DATAEXCHANGE_ID: the ID for your data exchange.
In the body of the request, provide the data exchange details .
If the request is successful, the response body contains the details of the data exchange.
If you enable subscriber email logging with the logLinkedDatasetQueryUserEmail
field, the data exchange response contains log_linked_dataset_query_user_email: true
. The logged
data is available in the job_principal_subject
field of the INFORMATION_SCHEMA.SHARED_DATASET_USAGE
view
.
For more information about the tasks that you can perform on data exchanges using
APIs, see projects.locations.dataExchanges
methods
.
Update a data exchange
To update a data exchange, follow these steps:
Console
-
Go to the Sharing (Analytics Hub)page.
-
From the list of data exchanges, select the data exchange to update.
-
Go to the Detailstab.
-
Click Edit exchange.
-
In the Edit exchangedialog, update the following fields:
- Display name
- Primary contact
- Description
- Public discoverability
- If you enable public discoverability, grant the
Analytics Hub Viewer role (
roles/analyticshub.viewer) toallUsersorallAuthenticatedUsers. - If you disable public discoverability, remove the
Analytics Hub Viewer role (
roles/analyticshub.viewer) fromallUsersorallAuthenticatedUsers. Public exchanges can't have private listings, but private exchanges can have public listings.
- If you enable public discoverability, grant the
Analytics Hub Viewer role (
-
Subscriber Email Logging
-
Click Save.
API
Use the projects.locations.dataExchanges.patch
method
.
PATCH https://analyticshub.googleapis.com/v1/projects/ PROJECT_ID /location/ LOCATION /dataExchanges/ DATAEXCHANGE_ID ?updateMask= UPDATEMASK
Replace UPDATEMASK
with the list of fields
that you want to update. To update multiple values, use a comma-separated
list. For example, to update the display name and primary contact for a
data exchange, enter displayName,primaryContact
.
In the body of the request, specify updated values for the following fields:
-
displayName -
description -
primaryContact -
documentation -
icon -
discoveryType -
logLinkedDatasetQueryUserEmail
For details on these fields, see Resource: DataExchange .
For more information about the tasks that you can perform on data exchanges using
APIs, see projects.locations.dataExchanges
methods
.
View data exchanges
To view the data exchanges in your project or organization that you have access to, follow these steps:
Console
-
Go to the Sharing (Analytics Hub)page.
-
The page displays the data exchanges in your Google Cloud project. If you have the
resourcemanager.organizations.getpermission, you can also see the data exchanges in your Google Cloud organization.
API
To view data exchanges in your project, use the projects.locations.dataExchanges.list
method
:
GET https://analyticshub.googleapis.com/v1/projects/ PROJECT_ID /location/ LOCATION /dataExchanges
Replace the following:
- PROJECT_ID : the project ID.
- LOCATION : the location for which you want to list the existing data exchanges.
To view data exchanges in your organization, use the organizations.locations.dataExchanges.list
method
:
GET https://analyticshub.googleapis.com/v1/organizations/ ORGANIZATION_ID /location/ LOCATION /dataExchanges
Replace the following:
-
ORGANIZATION_ID: the organization ID. For more information, see Getting your organization ID . -
LOCATION: the location where you want to list the existing data exchanges.
Share a data exchange
If the BigQuery sharing publisher belongs to a different organization than the organization that contains the data exchange, the publisher can't view your data exchange in BigQuery sharing. Share a link to the data exchange with the publisher.
-
Go to the Sharing (Analytics Hub)page.
-
From the list of data exchanges, click More options.
-
Click Copy share link.
Give users access to a data exchange
To give users access to a data exchange, you must set the IAM policy for that data exchange. For information about predefined IAM user roles, see BigQuery sharing IAM roles .
Console
-
In the Google Cloud console, go to the Sharing (Analytics Hub)page.
-
Click the data exchange name for which you want to set permissions.
-
Go to the Detailstab.
-
Click Set permissions.
-
To add principals, click Add principal.
-
In the New principalsfield, add the email IDs to which you want to grant access. You can also use
allUsersto make a resource public and accessible to everyone on the internet, orallAuthenticatedUsersto make it accessible only to signed-in Google users. -
In the Select a rolemenu, select Analytics Hub, and then select one of the following Identity and Access Management (IAM) roles:
- Analytics Hub Admin
- Analytics Hub Listing Admin
- Analytics Hub Publisher
- Analytics Hub Subscriber
- Analytics Hub Subscription Owner
- Analytics Hub Viewer
-
Click Save.
API
-
Read the existing policy with the listing
getIamPolicymethod by using theprojects.locations.dataExchanges.getIamPolicymethod :POST https://analyticshub.googleapis.com/v1/projects/ PROJECT_ID /locations/ LOCATION /dataExchanges/ DATAEXCHANGE_ID :getIamPolicy
Replace the following:
-
PROJECT_ID: the project ID—for example,my-project-1. -
LOCATION: the location for your data exchange. Use lowercase letters. -
DATAEXCHANGE_ID: the data exchange ID.
BigQuery sharing (formerly Analytics Hub) returns the current policy.
-
-
To add or remove members and their associated Identity and Access Management (IAM) roles, edit the policy with a text editor. Use the following format to add members:
-
user:test-user@gmail.com -
group:admins@example.com -
serviceAccount:test123@example.domain.com -
domain:example.domain.com
For example, to grant the
roles/analyticshub.subscriberrole togroup:subscribers@example.com, add the following binding to the policy:{ "members": [ "group:subscribers@example.com" ], "role":"roles/analyticshub.subscriber" } -
-
Write the updated policy by using the
projects.locations.dataExchanges.setIamPolicymethod . In the body of the request, provide the updated IAM policy from the previous step.POST https://analyticshub.googleapis.com/v1/projects/ PROJECT_ID /locations/ LOCATION /dataExchanges/ DATAEXCHANGE_ID :setIamPolicy
In the body of the request, provide the listing details. If the request is successful, then the response body contains details of the listing.
Create BigQuery sharing administrators
To manage data exchanges, create data exchange administrators by
granting users the Analytics Hub Admin role
( roles/analyticshub.admin
)
at the project or data exchange level.
To allow administrators to manage all data exchanges in a project, grant them the Analytics Hub Admin role for that project .
To allow administrators to manage a specific data exchange, grant them the Analytics Hub Admin role for that data exchange .
Make a data exchange public
By default, a data exchange is private. Only users or groups with access to an exchange can view or subscribe to its listings. You can make a data exchange public,
which lets Google Cloud users ( allAuthenticatedUsers
)
discover and subscribe to its listings.
To make a data exchange public, follow these steps:
-
To allow
allAuthenticatedUsersto view listings , grant them the Analytics Hub Viewer role (roles/analyticshub.viewer) at the data exchange level. -
To allow
allAuthenticatedUsersto subscribe to listings , grant them the Analytics Hub Subscriber role (roles/analyticshub.subscriber) at the data exchange level. -
Enable public discoverability when you create or update a data exchange. Specify the appropriate permissions when you make a data exchange public.
Delete a data exchange
Deleting a data exchange also deletes all its listings. However, shared and linked datasets aren't deleted. When you delete a project, its data exchanges aren't deleted. Delete these data exchanges before deleting the project . You can't undo a data exchange deletion.
Before deleting a data exchange, complete the following steps based on the data exchange's configuration:
- For data exchanges with Google Cloud Marketplace-integrated commercial listings, delete the Google Cloud Marketplace-integrated commercial listings . Then recreate the listings as non-commercial listings.
- For data exchanges with listings for multiple regions, remove all active subscriptions using the
projects.locations.subscriptions.revokemethod .
To delete a data exchange, follow these steps:
Console
-
Go to the Sharing (Analytics Hub)page.
-
From the list of data exchanges, select the data exchange to delete.
-
Go to the Detailstab.
-
Click Delete exchange.
-
In the Delete exchange?dialog, confirm deletion by typing delete.
-
Click Delete.
API
Use the projects.locations.dataExchanges.delete
method
.
DELETE https://analyticshub.googleapis.com/v1/projects/ PROJECT_ID /locations/ LOCATION /dataExchanges/ DATAEXCHANGE_ID
Replace the following:
-
PROJECT_ID: the ID of the project in which you want to create the data exchange. -
LOCATION: the location for your data exchange. For more information about locations that support BigQuery sharing, see Supported regions . -
DATAEXCHANGE_ID: the ID for your data exchange.
For more information about the tasks that you can perform on data exchanges using
APIs, see projects.locations.dataExchanges
methods
.
What's next
- Learn about managing listings .
- Learn how to grant Analytics Hub user roles .
- Learn how to view and subscribe to listings and data exchanges .
- Learn about Sharing audit logging .

