Data Sharing Using Google Analytics Hub
In this tutorial, we will take an in-depth look at Google Analytics Hub, a tool to securely share and access data, simplifying collaboration and analysis
Join the DZone community and get the full member experience.
Join For FreeGoogle Cloud Analytics Hub is a tool built on BigQuery that enables seamless data sharing across the organization by making it easier to share and access datasets. Analytics Hub makes it easy to discover public, private, and internally shared data sources.
Accessing Public Datasets in Analytics Hub
Navigate to the Google Cloud console using the URL "https://console.cloud.google.com," search for BigQuery, and select BigQuery.
In the BigQuery console, click on Analytics Hub, and click on Search Listings.
Search for trees to search for listings named "trees" and click on Street Trees Listing.
Click on Subscribe to subscribe to the listing.
Select the desired project for your linked dataset by clicking on Browse. Once you've made your selection, provide the linked dataset name and click Save to continue.
Click on Go to Linked Dataset.
Expand the street_trees dataset in BigQuery, select the street_trees table, click on Query, and click on In new tab.
Add “*” to the Query and click Run.
It's that simple to query linked datasets in BigQuery.
Creating Dataset in BigQuery
In BigQuery, datasets provide a logical structure for managing tables and views within a project. Before loading data into BigQuery, users must create at least one dataset to store their tables or views.
Navigate to BigQuery Studio and click on Create Dataset to create dataset in BigQuery.
Specify the Dataset ID as dzone-dataset, then click on Create Dataset.
Creating a Table in BigQuery
BigQuery organizes data in Tables where data is stored in rows and columns.
In BigQuery Studio, run the Query below by clicking on Run.
CREATE OR REPLACE TABLE `dzone_dataset.analytics_hub_table` AS
SELECT *
FROM `dzone-tutorial.street_trees.street_trees` LIMIT 1000
Notice that the new table 'analytics_hub_table' is created.
Creating Analytics Hub Data Exchange
Data exchanges streamline data sharing by providing a structured environment for publishing and accessing data. Data exchange is a catalog of available datasets. Analytics Hub allows publishers and administrators to manage subscriber access at both the exchange and the listing levels. The Analytics Hub subscriber can browse data exchanges, discover accessible data, and subscribe to the shared resources. This method eliminates the requirement to explicitly grant access to the underlying shared resources.
When creating a data exchange, a primary contact email can be assigned, providing a means for users to contact the owner with questions or concerns about the data exchange.
Click on Create Exchange to create an exchange in Analytics Hub.
Specify the Display Name as the name you want to specify for the exchange. Users can click on the Toggle to make the exchange publicly discoverable. Click on Create Exchange.
Users can specify the administrators for exchange who can manage the listings, specify the publishers who can publish and manage the listings, specify the subscribers who can subscribe to the listings, or specify viewers who can view listings and exchange permissions. We can click on Skip.
Notice the dzone-tutorial-exchange has been created. Click on the dzone-tutorial-exchange.
Listing is a dataset that we want to share with Analytics Hub and a listing could be a public listing or private listing.
Click on Create Listing.
Select the Resource Type as BigQuery Dataset, select the dataset we have created earlier by typing the dataset name, in our example we will select dzone-tutorial.dzone_dataset. Click on Next.
Provide the Display Name as Analytics Hub Sample Trees Data. In the markdown provide the code "# Sample Dataset For Trees Data" and click on Next.
In Analytics Hub, the Publisher should have an Analytics Hub Listing Admin role or Analytics Hub Publisher role to create the listing.
We can provide the listing contact information, such as primary contact, provider name, and publisher name, by clicking on Next.
In this example, we are leaving it empty.
Click on Publish.
Click on Search Listings to search for our published listing.
Search for dzone and click on the Analytics Hub Sample Trees Data tile.
To discover and subscribe to the listings the user should have the Analytics Hub subscriber role.
If you are logged into Analytics Hub as a user that has Analytics Hub subscriber then we can click on Subscribe.
Specify the linked dataset name as sample_analytics_hub_sample_trees_data and click on Save.
Click on Go to Linked Dataset.
Click on the analytics_hub_table and click on Query.
Add * to the Query and click on Run. Notice that we are able to see the linked dataset.
This is how data is published and subscribed to Analytics Hub.
Summary
Google Analytics Hub provides a secure and seamless way to share and access datasets, both public and private. Built on BigQuery, Google Analytics Hub simplifies data sharing by allowing users to easily create and subscribe to listings, making data readily available for analysis within their projects.
Opinions expressed by DZone contributors are their own.
Comments