Lab 1 - Exploring A BigQuery Public Dataset
Lab 1 - Exploring A BigQuery Public Dataset
help_outline
language
Start Lab
01:00:00
Student Resources
Overview
Set up your environments
Task 1. Query a public dataset
Task 2. Create a custom table
Task 3. Create a dataset
Task 4. Load the data into a new table
Task 5. Query the table
End your lab
Exploring a BigQuery
Public Dataset
1 hour1 Credit
Overview
Storing and querying massive datasets can be time consuming and expensive without the right
hardware and infrastructure. BigQuery is an enterprise data warehouse that solves this problem
by enabling super-fast SQL queries using the processing power of Google's infrastructure.
Simply move your data into BigQuery and let us handle the hard work. You can control access to
both the project and your data based on your business needs, such as giving others the ability to
view or query your data.
You access BigQuery through the Cloud Console, the command-line tool, or by making calls to
the BigQuery REST API using a variety of client libraries such as Java, .NET, or Python. There
are also a variety of third-party tools that you can use to interact with BigQuery, such as
visualizing the data or loading the data. In this lab, you access BigQuery using the web UI.
You can use the BigQuery web UI in the Cloud Console as a visual interface to complete tasks
like running queries, loading data, and exporting data. This hands-on lab shows you how to
query tables in a public dataset and how to load sample data into BigQuery through the Cloud
Console.
Objectives
Query a table
Set up your environments
Qwiklabs setup
For each lab, you get a new GCP project and set of resources for a fixed time at no cost.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
3. When ready,
click .
4. Click bigquery-public-data in
the pinned project list to expand it.
Note: You can also search and explore the available datasets va the ADD DATA > Explore
public datasets menu.
SELECT
name, gender,
SUM(number) AS total
FROM
`bigquery-public-data.usa_names.usa_1910_2013`
GROUP BY
name, gender
ORDER BY
total DESC
LIMIT
10
Copied!
content_copy
2. In the upper right of the window, view
the query validator.
BigQuery displays a green check mark icon if the query is valid. If the query is invalid, a red
exclamation point icon is displayed. When the query is valid, the validator also shows the
amount of data the query processes when you run it. This helps to determine the cost of running
the query.
3. Click Run.
The query results opens below the Query editor. At the top of the Query results section,
BigQuery displays the time elapsed and the data processed by the query. Below the time is the
table that displays the query results. The header row contains the name of the column as
specified in GROUP BY in the query.
Task 2. Create a custom table
In this task, you create a custom table, load data into it, and then run a query against the table.
The file you're downloading contains approximately 7 MB of data about popular baby names,
and it is provided by the US Social Security Administration.
Datasets help you control access to tables and views in a project. This lab uses only one table,
but you still need a dataset to hold the table.
For Source,
choose Upload from
the Create table
from: dropdown menu.
For Select file, click Browse,
navigate to
the yob2014.txt file and
click Open.
For File format,
choose CSV from the dropdown
menu.
For Table name,
enter names_2014.
In the Schema section, click
the Edit as text toggle and
paste the following schema
definition in the text box.
name:string,gender:string,count:integer
Copied!
content_copy
3. Click Create table (at the bottom of
the window).
Note: If you see an import error, your data should still have been imported. To clear the error
click Close , then click Cancel to exist the import dialog, and finally click Yes, quit in response
to the warning that your changes will not be saved.
True
False
Task 5. Query the table
Now that you've loaded data into your table, you can run queries against it. The process is
identical to the previous example, except that this time, you're querying your table instead of a
public table.
Web UI
Make calls to BigQuery REST API
Third-party tools
Command-line tool
Submit
Congratulations!
You queried a public dataset, then created a custom table, loaded data into it, and then ran a
query against that table.
You will be given an opportunity to rate the lab experience. Select the applicable number of
stars, type a comment, and then click Submit.
Cancel
Submit
error_outline
All done? If you end this lab, you will lose all
your work. You may not be able to restart the
lab if there is a quota limit. Are you sure you
want to end this lab?
Cancel
Submit