3. Clean layers: bronze, silver and gold
3.5 Who can see what: roles and safe views
Highlights & notes
Select lesson text to highlight it, or tap Add note.
Bookmarks
Bookmark a lesson to see it here.
Not everyone should see everything. Analysts need the gold tables. They should not see raw files with phone numbers. BigQuery controls this with roles.
- BigQuery Data Viewer: may read the data
- BigQuery Data Editor: may also change tables
- BigQuery Job User: may run queries (the project pays)
- To query a table, a person needs to read it and to run jobs: both roles
Give roles to groups, not to single people, and usually on a whole dataset. Give analysts the viewer role on gold only.
Follow least privilege: give each person the smallest access that lets them do their job. It is easy to add access later and very hard to take back a leak.
Let analysts read gold
One statement for the whole dataset.
SQL
GRANT `roles/bigquery.dataViewer`ON SCHEMA goldTO "group:analysts@shop.example";
Result
analysts@shop.example: read access to every table in gold
Quick check
Why grant a role to a group instead of to each person?
A view that hides private columns
silver.customers also has a phone column.
SQL
CREATE VIEW gold.customers_safe ASSELECT customer_id, cityFROM silver.customers;
Rows at this step
customer_id | city ------------+------ 1 | Noida 2 | Delhi
Quick check
An analyst may read gold.customers_safe but not silver.customers. What can they see?
Try it yourself
1. Open one of your datasets, click Sharing and then Permissions. See who has which role.
2. Create a view on sales.customers that leaves out one column.
Question 1 · Easy
Which role lets a person read data but not change it?
Question 2 · Medium
Which datasets should a business analyst usually read?
Question 3 · Hard
A user has Data Viewer on gold but cannot run any query. What is missing?
Key takeaways
Access is given through roles, best to groups and per dataset. Analysts read gold. A view can hide private columns. Give the smallest access that does the job.
Save your progress
Start free and your progress, code and notes stay saved. Free for 1 month, no card needed.
Start free Log in