Checkpoints
Create a lake, zone, and asset
/ 20
Query BigQuery table to review data quality
/ 20
Create and upload a data quality specification file
/ 20
Define and run a data quality job
/ 20
Review data quality results in BigQuery
/ 20
Assessing Data Quality with Dataplex
- GSP1158
- Overview
- Setup and requirements
- Task 1. Create a lake, zone, and asset in Dataplex
- Task 2. Query a BigQuery table to review data quality
- Task 3. Create and upload a data quality specification file
- Task 4. Define and run a data quality job in Dataplex
- Task 5. Review data quality results in BigQuery
- Congratulations!
GSP1158
Overview
Dataplex is an intelligent data fabric that enables organizations to centrally discover, manage, monitor, and govern their data across data lakes, data warehouses, and data marts to power analytics at scale.
A valuable feature of Dataplex is the ability to define and run data quality checks on Dataplex assets such as BigQuery tables and Cloud Storage files. Using Dataplex data quality tasks, you can integrate data quality checks into everyday workflows by validating data that is part of a data production pipline, regularly monitoring the quality of your data against a set of criteria, and building data quality reports for regulatory requirements.
In this lab, you learn how to assess data quality using Dataplex by creating a custom data quality specification file and using it to define and run a data quality job on BigQuery data.
What you'll do
- Create a Dataplex lake, zone, and asset
- Query a BigQuery table to review data quality
- Create and upload a data quality specification file
- Define and run a data quality job
- Review the results of a data quality job
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 will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that 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).
- Time to complete the lab---remember, once you start, you cannot pause a lab.
How to start your lab and sign in to the Google Cloud console
-
Click the Start Lab button. If you need to pay for the lab, a pop-up opens for you to select your payment method. On the left is the Lab Details panel 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
-
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. -
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 panel.
-
Click Next.
-
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 panel.
-
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. -
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.
Activate Cloud Shell
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
- Click Activate Cloud Shell at the top of the Google Cloud console.
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
- (Optional) You can list the active account name with this command:
- Click Authorize.
Output:
- (Optional) You can list the project ID with this command:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
Enable Dataproc API
-
In the Google Cloud Console, enter Cloud Dataproc API in the top search bar.
-
Click on the result for Cloud Dataproc API under Marketplace.
-
Click Enable.
Task 1. Create a lake, zone, and asset in Dataplex
To define and run data quality tasks, you first need to create some Dataplex resources.
In this task, you create a new Dataplex lake to store ecommerce customer information, add a raw zone to the lake, and then attach a pre-created BigQuery dataset as a new asset in the zone.
Create a lake
- In the Google Cloud Console, in the Navigation menu (), navigate to Analytics > Dataplex.
If prompted Welcome to the new Dataplex experience
, click Close.
-
Under Manage lakes, click Manage.
-
Click Create lake.
-
Enter the required information to create a new lake:
Property | Value |
---|---|
Display Name | Ecommerce Lake |
ID | Leave the default value. |
Region |
Leave the other default values.
- Click Create.
It can take up to 3 minutes for the lake to be created.
Add a zone to the lake
-
On the Manage tab, click on the name of your lake.
-
Click +ADD ZONE.
-
Enter the required information to create a new zone:
Property | Value |
---|---|
Display Name | Customer Contact Raw Zone |
ID | Leave the default value. |
Type | Raw zone |
Data locations | Regional |
Leave the other default values.
For example, the option for Enable metadata discovery under Discovery settings is enabled by default and allows authorized users to discover the data in the zone.
- Click Create.
It can take up to 2 minutes for the zone to be created.
Attach an asset to a zone
-
On the Zones tab, click on the name of your zone.
-
On the Assets tab, click +ADD ASSET.
-
Click Add an asset.
-
Enter the required information to attach a new asset:
Property | Value |
---|---|
Type | BigQuery dataset |
Display Name | Contact Info |
ID | Leave the default value. |
Dataset |
|
Leave the other default values.
-
Click Done.
-
Click Continue.
-
For Discovery settings, select Inherit to inherit the Discovery settings from the zone level, and then click Continue.
-
Click Submit.
Click Check my progress to verify the objective.
Task 2. Query a BigQuery table to review data quality
In the previous task, you created a new Dataplex asset from a BigQuery dataset named customers that has been pre-created for this lab. This dataset contains a table named contact_info which contains raw contact information for customers of a fictional ecommerce company.
In this task, you query this table to start identifying some potential data quality issues that you can include as checks in a data quality job. You also identify another precreated dataset that you can use to store data quality job results in a later task.
-
In the Google Cloud Console, in the Navigation menu (), navigate to BigQuery.
-
In the Explorer pane, expand the arrow next to your project ID to list the contents:
In addition to the customer_contact_raw_zone dataset created by Dataplex to manage that zone, there are two BigQuery datasets that were precreated for this lab:
- customers
- customers_dq_dataset
The dataset named customers contains one table named contact_info, which contains contact information for customers such as a customer ID, name, email, and more. This is the table that you explore and check for data quality issues throughout this lab.
The dataset named customers_dq_dataset does not contain any tables. When you define a data quality job in a later task, you use this dataset as the destination for a new table containing the data quality job results.
- In the SQL Editor, click on + SQL query. Paste the following query, and then click Run:
This query selects 50 records from the original table and orders the records by the customer id in the results.
- Scroll through the results in the Results pane.
Notice that some records are missing customer IDs or have incorrect emails, which can make it difficult to manage customer orders.
Click Check my progress to verify the objective.
Task 3. Create and upload a data quality specification file
Dataplex data quality check requirements are defined using CloudDQ YAML specification files. Once created, the YAML specification file is uploaded to a Cloud Storage bucket that is made accessible to the data quality job.
The YAML file has four keys sections:
- a list of rules to run (either pre-defined or customized rules)
- row filters to select a subset of data for validation
- rule bindings to apply the defined rules to the table(s)
- optional rule dimensions to specify the types of the rules that the YAML file can contain
In this task, you define a new YAML specification file for data quality checks that identify null customer IDs and emails in the specified BigQuery table. After you define the file, you upload it to a pre-created Cloud Storage bucket for use in a later task to run the data quality job.
Create the data quality specification file
- In Cloud Shell, run the following command to create a new empty file for the data quality specification:
- Paste the following code:
- Review the code to identify the two primary data quality rules that are defined in this file.
The dq-customer-raw-data.yaml
file begins with key parameters to identify the Dataplex resources including the project ID, region, and names of the Dataplex lake and zone.
Next, it specifies the allowed rule dimensions and two primary rules:
- The rule for NOT_NULL values refers to the completeness dimension such as null values.
- The rule for VALID_EMAIL values refers to the conformance dimension such as invalid values.
Last, the rules are bound to entities (tables) and columns using rule bindings for data quality validation:
- The first rule binding named VALID_CUSTOMER binds the NOT_NULL rule to the id column of the contact_info table, which will validate if the ID column has any NULL values.
- The second rule binding named VALID_EMAIL_ID binds the VALID_EMAIL rule to the email column of the contact_info table, which will check for valid emails.
- Enter
Ctrl+X
, thenY
, to save and close the file.
Upload the file to Cloud Storage
- In Cloud Shell, run the following command to upload the file to a Cloud Storage bucket that has been created for this lab:
Click Check my progress to verify the objective.
Task 4. Define and run a data quality job in Dataplex
The data quality process uses a data quality specification YAML file to run a data quality job and generates data quality metrics that are written to a BigQuery dataset.
In this task, you define and run a data quality job using the data quality specification YAML file uploaded to Cloud Storage in the previous task. When you define the job, you also specify a pre-created BigQuery dataset named customer_dq_dataset to store the data quality results.
-
In the Google Cloud Console, in the Navigation menu (), navigate to Analytics > Dataplex.
-
Under Manage lakes, click Process.
-
Click +CREATE TASK.
-
Under Check Data Quality, click Create task.
-
Enter the required information to create a new data quality job:
Property | Value |
---|---|
Dataplex lake | ecommerce-lake |
Display name | Customer Data Quality Job |
ID | Leave the default value. |
Select GCS file |
|
Select BigQuery dataset |
|
BigQuery table | dq_results |
User service account | Compute Engine default service account |
Leave the other default values.
Note that the Compute Engine default service account has been preconfigured for this lab to have the appropriate IAM roles and permissions. For more information, review the Dataplex documentation titled Create a service account.
-
Click Continue.
-
For Start, select Immediately.
-
Click Create.
Click Check my progress to verify the objective.
Task 5. Review data quality results in BigQuery
In this task, you review the tables in the customers_dq_dataset to identify records that are missing customer ID values or have an invalid values for emails.
-
In the Google Cloud Console, in the Navigation menu (), navigate to BigQuery.
-
In the Explorer pane, expand the arrow next to your project ID to list the contents:
-
Expand the arrow next to the customer_dq_dataset dataset.
-
Click on the dq_summary table.
-
Click on the Preview tab to see the results.
The dq summary table provides useful information about the overall data quality including the number of records that were identified to not adhere to the two rules in the data quality specification file.
-
Scroll to the last column named failed_records_query.
-
Click on the down arrow in the first row to expand the text and view the entire query for the VALID_EMAIL rule results.
Note that the query is quite long and ends with ORDER BY _dq_validation_rule_id
.
- Click on + SQL query. Copy and paste the query into SQL Editor, and click Run.
The results of the query provide the email values in the contact_info table that are not valid.
- Repeat steps 7-8 for the second cell that contains the query for the VALID_CUSTOMER rule results.
The results of the query identify that there are 10 records in the contact_info table that are missing ID values.
Click Check my progress to verify the objective.
Congratulations!
You assessed data quality using Dataplex by creating a custom data quality specification file and using it to run a data quality job on a BigQuery table.
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 October 22, 2024
Lab Last Tested October 22, 2024
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.