
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Create the source dataset
/ 30
Create the analyst dataset
/ 30
Secure the datasets
/ 40
When using BigQuery, permissions are configured at the dataset level. Frequently, data engineering teams maintain datasets with many large tables of raw data, but they want to share subsets of these tables with particular analyst audiences.
For example, analysts might have access to a version of a table that excludes columns with user-specific information. Or, perhaps a specific user should be able to see only specific rows from a given BigQuery table or view.
In this lab, you will learn how to create and use Authorized Views in BigQuery. You will also learn how to do row-level filtering using information about the logged-in user.
This lab will provide two Google Cloud users. This is so the BigQuery authorized view permissions can be verified by logging in as a different user.
In this lab, you will learn how to perform the following tasks:
SESSION_USER()
function to limit access to specific rows within a table/view.For each lab, you get a new Google Cloud project and set of resources for a fixed time at no cost.
Sign in to Qwiklabs using an incognito window.
Note the lab's access time (for example, 1:15:00
), and make sure you can finish within that time.
There is no pause feature. You can restart if needed, but you have to start at the beginning.
When ready, click Start lab.
Note your lab credentials (Username and Password). You will use them to sign in to the Google Cloud Console.
Click Open Google Console.
Click Use another account and copy/paste credentials for this lab into the prompts.
If you use other credentials, you'll receive errors or incur charges.
Accept the terms and skip the recovery resource page.
In this task, you create the source dataset in BigQuery that will be used in this lab.
source_data
for Dataset ID, and then click on Create dataset (accepting the other default values).Click Activate Cloud Shell to open Cloud Shell. If prompted, click Continue, and then click Authorize.
Load the source data into a new table in BigQuery by entering the following in Cloud Shell:
Click Check my progress to verify the objective.
In this task, you create the analyst dataset, create a redacted view for the analysts, and create a second view for logged-in users.
analyst_views
for Dataset ID, and click on Create Dataset (accepting the other default values).no_user_info
and click Save. Note, though the UI says destination table, you are only creating a view, not a table.*
into the SELECT statement so that your SQL query looks like this:Next, create a 2nd view using the following information.
Click Run.
Save the entered query as a view by clicking Save > Save view.
Select your project, and the analyst_views dataset.
Enter a destination table name of row_filter_session_user
and click Save.
Click Check my progress to verify the objective.
In this task you share the analyst dataset with Username 2, and secure it by providing the Viewer role.
In the dataset listing to the left of the screen, click on the analyst_views dataset.
Then select Sharing from the right pane and click on Permissions.
Click Add Principal. In the New principals field, enter the email address of the 2nd lab account:
Select BigQuery Data Viewer as the role and click Save.
Click Close.
In this task, you secure the source dataset. You don't want analysts and others outside the data engineering team to have access to the raw data available in the source dataset, so you are going to restrict access.
You do want those using the views you've created to be able to see the data the views produce. This will require authorizing not the users, but the views.
In the dataset listing to the left of the screen, click on the source_data dataset.
Then select Sharing from the right pane and click on Permissions.
Expand the BigQuery Data Viewer principal from the permission list and click on the trash icon next to it and click Remove to confirm. Click Close.
In Sharing, click on Authorize Views .
In the Authorized views, choose the following settings.
Authorized view |
|
Click Add Authorization.
Add another entry with these settings replacing the existing view.
Authorized view |
|
Click Add Authorization.
Click Close.
Click Check my progress to verify the objective.
In this task, you test the security settings that you applied in previous tasks.
You should see a result set with all the user registration events within the table.
row_filter_session_user
view, only seeing the rows associated with your account, by executing the following query:You should see a result set with 68 rows specific to the second Qwiklabs user.
You will see an Access denied error message indicating that you don't have permissions.
In this lab, you have learned how to do the following:
SESSION_USER()
function to limit access to specific rows within a table/view.When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.
You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.
The number of stars indicates the following:
You can close the dialog box if you don't want to provide feedback.
For feedback, suggestions, or corrections, please use the Support tab.
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.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one