Query a public dataset with the Trusted Cloud console
Learn how to locate and query public datasets in BigQuery by using the Trusted Cloud console.
Before you begin
-
In the Trusted Cloud console, on the project selector page, select or create a Trusted Cloud project.
-
Make sure that you have the following role or roles on the project: BigQuery Job User, Service Usage Admin
Check for the roles
-
In the Trusted Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Trusted Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the identifier for a user in a workforce identity pool. For details, see Represent workforce pool users in IAM policies, or contact your administrator.
- In the Select a role list, select a role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Make sure that billing is enabled for your Trusted Cloud project.
Ensure that the BigQuery API is enabled.
If you created a new project, the BigQuery API is automatically enabled.
If you don't enable billing for the Trusted Cloud project that you use in this tutorial, then you will upload and work with data in the BigQuery sandbox. The BigQuery sandbox lets you learn BigQuery with a limited set of BigQuery features at no charge.
Open a public dataset
BigQuery public datasets are available by default in the Trusted Cloud console.
In the following example, you access datasets in the public project
bigquery-public-data
.
In the Trusted Cloud console, go to the BigQuery page.
In the Explorer pane, click
+Add data .In the Add data dialog, in the Filter By pane, click
Public datasets.
You can use the Search Marketplace field or filters to narrow down your search.
Select a dataset, and then click View dataset.
In the Explorer pane, your dataset is selected and you can view its details.
Optional: Click
View actions next to your dataset to view more options.Each dataset contains tables, which you can view by clicking
Toggle node next to any dataset.
Query a public dataset
In the following steps, you query the USA Names public dataset to determine the most common names in the United States between 1910 and 2013:
In the Trusted Cloud console, go to the BigQuery page.
Click
SQL query .In the
query editor , copy the following query:SELECT name, SUM(number) AS total FROM `bigquery-public-data.usa_names.usa_1910_2013` GROUP BY name ORDER BY total DESC LIMIT 10;
If the query is valid, then a check mark appears along with the amount of data that the query processes. If the query is invalid, then an exclamation point appears along with an error message.
Click
Run .The most common names are listed in the Query results section. The table's header row contains each column name that you selected in the query.
Optional: To display the duration and the amount of data that the query processed, click the Job information tab in the
Query results section.
Clean up
To avoid incurring charges to your Trusted Cloud account for the resources used on this page, follow these steps.
Delete the project
If you used the BigQuery sandbox to query the public dataset, then billing is not enabled for your project.
The easiest way to eliminate billing is to delete the project that you created for the tutorial.
To delete the project:
- In the Trusted Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
What's next
- Learn about the BigQuery sandbox.
- Learn how to create a dataset and query tables in the Trusted Cloud console.
- Get updates about BigQuery.
- Learn about BigQuery pricing.
- Learn about BigQuery quotas and limits.