arrow_back

Ingesting New Datasets into BigQuery

登录 加入
访问 700 多个实验和课程

Ingesting New Datasets into BigQuery

实验 1 小时 universal_currency_alt 1 个积分 show_chart 入门级
info 此实验可能会提供 AI 工具来支持您学习。
访问 700 多个实验和课程

GSP411

Google Cloud self-paced labs logo

Overview

BigQuery is Google's fully managed, NoOps, low cost analytics database. With BigQuery you can query terabytes and terabytes of data without having any infrastructure to manage, or needing a database administrator. BigQuery uses SQL and can take advantage of the pay-as-you-go model. BigQuery allows you to focus on analyzing data to find meaningful insights.

The dataset you'll use is an ecommerce dataset that has millions of Google Analytics records for the Google Merchandise Store loaded into BigQuery. You have a copy of that dataset for this lab and will explore the available fields and row for insights.

In this lab, you will ingest several types of datasets into tables inside of BigQuery.

Setup and requirements

Before you click the Start Lab button

Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.

This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.

To complete this lab, you need:

  • Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
  • Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.

How to start your lab and sign in to the Google Cloud console

  1. Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:

    • The Open Google Cloud console button
    • Time remaining
    • The temporary credentials that you must use for this lab
    • Other information, if needed, to step through this lab
  2. Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).

    The lab spins up resources, and then opens another tab that shows the Sign in page.

    Tip: Arrange the tabs in separate windows, side-by-side.

    Note: If you see the Choose an account dialog, click Use Another Account.
  3. If necessary, copy the Username below and paste it into the Sign in dialog.

    {{{user_0.username | "Username"}}}

    You can also find the Username in the Lab Details pane.

  4. Click Next.

  5. Copy the Password below and paste it into the Welcome dialog.

    {{{user_0.password | "Password"}}}

    You can also find the Password in the Lab Details pane.

  6. Click Next.

    Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials. Note: Using your own Google Cloud account for this lab may incur extra charges.
  7. Click through the subsequent pages:

    • Accept the terms and conditions.
    • Do not add recovery options or two-factor authentication (because this is a temporary account).
    • Do not sign up for free trials.

After a few moments, the Google Cloud console opens in this tab.

Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field. Navigation menu icon and Search field

Open the BigQuery console

  1. In the Google Cloud Console, select Navigation menu > BigQuery.

The Welcome to BigQuery in the Cloud Console message box opens. This message box provides a link to the quickstart guide and the release notes.

  1. Click Done.

The BigQuery console opens.

Task 1. Create a new dataset to store tables

  1. To create a dataset, click on the View actions icon next to your Project ID and select Create dataset.

Create dataset option highlighted

  1. Set the Dataset ID to ecommerce. Leave the other fields at their default values.

  2. Click CREATE DATASET.

You'll now see the ecommerce dataset under your project name.

Click Check my progress to verify the objective. Create a new dataset to store tables

Task 2. Ingest a new Dataset from a CSV

Scenario: Your marketing team is looking to you to help guide them with what products should be up for promotions based on inventory stock levels. They have also asked how each product is trending in customer sentiment based on the product reviews.

Your existing ecommerce transactional dataset does not have inventory stock levels or product review data in it, but your operations and marketing teams have provided you with new datasets for you to analyze.

Here is how you get started:

  1. Download the following dataset locally onto your computer: Product stock level dataset. (Open and download the file in normal window)

  2. To create a table, click on the View actions icon next to the ecommerce dataset and select Open.

  3. Click Create Table.

  4. Specify the below table options:

Source:

  • Create table from: Upload
  • Select file: select the file you downloaded locally earlier
  • File format: CSV

Destination:

  • Table name: products

Leave other settings at their default value.

Schema:

  • Check Auto Detect for Schema
Tip: Not seeing the checkbox? Ensure the file format is CSV and not Avro.
  • Partition and Cluster settings: Leave at default settings

Advanced Options:

  • Leave at default settings
  1. Click Create table.

You should now see the products table below the ecommerce dataset.

  1. Select the products table and view Details.

Click Check my progress to verify the objective. Ingest a new dataset from a CSV

  1. Select Preview and confirm all columns have been loaded (sampled below):
SKU name orderedQuantity stockLevel restockingLeadTime
GGOEGDHQ014899 20 oz Stainless Steel Insulated Tumbler 499 652 2
GGOEGOAB022499 Satin Black Ballpoint Pen 403 477 2
GGOEYHPB072210 Twill Cap 1429 1997 2
GGOEGEVB071799 Pocket Bluetooth Speaker 214 246 2

You have successfully loaded a CSV file into a new BigQuery table.

Exploring newly loaded data with SQL

Next, practice with a basic query to gain insights from the new products table.

  • In the BigQuery EDITOR, write a query to list the top 5 products with the highest stockLevel:
#standardSQL SELECT * FROM ecommerce.products ORDER BY stockLevel DESC LIMIT 5

Task 3. Ingest data from Cloud Storage

  1. Create a table by clicking on the View actions icon next to the ecommerce dataset, then click Create Table.

  2. Specify the below table options:

Source:

  • Create table from: Google Cloud Storage
  • Select file from Cloud Storage bucket: spls/gsp411/exports/products.csv
  • File format: CSV

Destination:

  • Table name: products

Leave all other settings as default.

Schema:

  • Check Auto Detect for Schema.

Advanced Options:

  • Leave at default settings
  1. Click Create table.

Does it work? No

  1. Click GO TO JOB when the error message appears, then click the Repeat load job button.

  2. In the Create table form, click on Advanced options and in the Write preference dropdown menu, select Overwrite table.

  3. Now click Create Table.

Confirm the table was executed successfully.

Click Check my progress to verify the objective. Ingest data from Cloud Storage

Task 4. Ingest a new dataset from a Google Spreadsheet

  1. Click + SQL Query.

  2. Execute this next query to show which products are in the greatest restocking need based on inventory turnover and how quickly they can be resupplied:

#standardSQL SELECT *, SAFE_DIVIDE(orderedQuantity,stockLevel) AS ratio FROM ecommerce.products WHERE # include products that have been ordered and # are 80% through their inventory orderedQuantity > 0 AND SAFE_DIVIDE(orderedQuantity,stockLevel) >= .8 ORDER BY restockingLeadTime DESC Note: If you specify a relative project name path like ecommerce.products instead of project_id.ecommerce.products, BigQuery will assume the current project.

Task 5. Saving data to Google Sheets

Scenario: You want to provide your supply chain management team with a way to notate whether or not they have contacted the supplier to reorder inventory, and to make any notes on the items. You decide on using a Google Spreadsheet for a quick survey.

Now you'll create it:

  1. In Query results, select SAVE RESULTS, choose Google Sheets from the dropdown.

  2. A popup will appear with a link to Open the spreadsheet, select Open.

  3. In your spreadsheet, in column G add a new field titled comments and for the first product row type new shipment on the way then press Enter.

comments column highlighted in the spreadsheet

In Google Sheets, select Share and click Copy link from get link.

  1. Return to your BigQuery tab.

  2. Click on the View actions icon next to the ecommerce dataset, then click Create Table.

  3. Specify the below table options:

Source:

  • Create table from: Drive
  • Select Drive URI: put-your-spreadsheet-url-here
  • File format: Google Sheet

Destination:

  • Table type: Leave as default (External table)
  • Table name: products_comments

Schema:

  • Check Auto Detect for Schema.

Advanced options:

  • Set Header rows to skip: to 1.
  • Leave all options at their default.
  1. Click Create table.
Note: There is no load job for creating an externally-linked table since the data is not ingested.

Click Check my progress to verify the objective. Ingest a new dataset from a Google Spreadsheet

Query data from an external spreadsheet

  1. Click + SQL Query.

Add the below query then click RUN:

#standardSQL SELECT * FROM ecommerce.products_comments WHERE comments IS NOT NULL

Wait for the query to execute. You will see that the new comments field is now returned.

SKU

name

orderedQuantity

stockLevel

restockingLeadTime

ratio

comments

GGOENEBB078899

Cam Indoor Security Camera - USA

2139

2615

42

0.8179732314

new shipment on the way

  1. Navigate back to your Google Spreadsheet tab.

  2. Type in more comments in the Comments field.

  3. Navigate back to BigQuery and execute the query again by clicking RUN.

Confirm the new data properly shows in the results.

You have successfully created an external table connection into BigQuery from Google Spreadsheets.

Task 6. External table performance and data quality considerations

Linking external tables to BigQuery (e.g. Google Spreadsheets or directly from Cloud Storage) has several limitations. Two of the most significant are:

  • Data consistency is not guaranteed if the data values in the source are changed while querying.
  • Data sources stored outside of BigQuery lose the performance benefits of having BigQuery manage your data storage (including but not limited to auto-optimization of your query execution path, certain wildcard functions are disabled, etc.).

Congratulations!

You've successfully created a new dataset and ingested new external data sources into BigQuery from CSV, Cloud Storage, and Google Drive.

Next steps / Learn more

Already have a Google Analytics account and want to query your own datasets in BigQuery? Follow this export guide.

Google Cloud training and certification

...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.

Manual Last Updated August 27, 2025

Lab Last Tested August 27, 2025

Copyright 2025 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

准备工作

  1. 实验会创建一个 Google Cloud 项目和一些资源,供您使用限定的一段时间
  2. 实验有时间限制,并且没有暂停功能。如果您中途结束实验,则必须重新开始。
  3. 在屏幕左上角,点击开始实验即可开始

使用无痕浏览模式

  1. 复制系统为实验提供的用户名密码
  2. 在无痕浏览模式下,点击打开控制台

登录控制台

  1. 使用您的实验凭证登录。使用其他凭证可能会导致错误或产生费用。
  2. 接受条款,并跳过恢复资源页面
  3. 除非您已完成此实验或想要重新开始,否则请勿点击结束实验,因为点击后系统会清除您的工作并移除该项目

此内容目前不可用

一旦可用,我们会通过电子邮件告知您

太好了!

一旦可用,我们会通过电子邮件告知您

一次一个实验

确认结束所有现有实验并开始此实验

使用无痕浏览模式运行实验

请使用无痕模式或无痕式浏览器窗口运行此实验。这可以避免您的个人账号与学生账号之间发生冲突,这种冲突可能导致您的个人账号产生额外费用。