Govern a BigQuery dataset from source to Looker
Trace a dataset into a Looker report and cover its quality checks, access controls, lineage and region placement.
By Invicly Tech, , in Google Cloud Engineering and Services. About 8 minutes to read.
In short
Data governance answers four questions: who may see this data, is it correct, where did it come from, and where is it stored. On Google Cloud you answer them with IAM and policy tags, data quality checks, lineage in Knowledge Catalog, and dataset location. Looker then shows the governed data to people.
Explained simply
Governance sounds large, but it is a short checklist. Who can see the data? Is it right? Where did it come from? Where does it live? Each question has a matching tool on Google Cloud.
For access, you give people roles on a dataset, not on the whole project. If one column is sensitive, such as a phone number, you tag the column and only allow certain people to read that tag.
For quality, you check the data as it arrives. Is the id missing? Is the date in the future? Is yesterday's data missing? A simple check that fails loudly is better than a wrong report nobody notices.
Lineage is a map of the data's journey. Knowledge Catalog, formerly Dataplex, can show which tables feed a report. When someone asks why a number looks odd, the map shows where to look.
Finally Looker puts a friendly layer on top. You describe your tables and metrics once in a model, and people build charts by choosing fields, without writing SQL.
Press Play on a diagram to walk through it one step at a time.
- 1Source
App database or files
- 2Raw dataset
BigQuery, in one region
- 3Clean dataset
Checked and access controlled
- 4LookML model
Defines views, joins and measures
- 5Explore and report
People query without writing SQL
- Access
- Dataset role for analysts group
- Policy tag on email column
- Quality
- Order id unique
- Freshness under 24 hours
- Lineage
- Source: Cloud SQL export
- Feeds: revenue explore
- Location
- EU region, matching policy
In depth
Three levels of access control
Dataset-level IAM is the base: a role like BigQuery Data Viewer on one dataset. For sensitive columns, create a taxonomy of policy tags and attach a tag to a column. Only principals with the Fine-Grained Reader role on that tag can read the column. For per-user row filtering, create a row-level access policy with a filter expression. Layering the three gives least privilege without copying tables.
- Dataset IAM for general access
- Policy tags for column-level security
- Row access policies for row filters
- Prefer groups over single users
- 1Project IAM
Who can run jobs at all
- 2Dataset IAM
Who can read which dataset
- 3Row access policy
Which rows a user sees
- 4Policy tag
Which columns a user sees
Quality checks and lineage
Write checks as SQL or use data quality rules in Knowledge Catalog. Good first checks are: key is not null and unique, values are in range, row count today is close to the usual, and the newest timestamp is recent. Run them after each load and stop the downstream job on failure. Lineage records which jobs read and wrote which tables, so you can trace a report back to its sources and see what a change will affect before you make it.
- Not null and unique keys
- Range and format checks
- Freshness: is the newest row recent?
- Volume: is the count near normal?
Region placement and Looker models
A BigQuery dataset has one location, such as the US multi-region, EU or a single region like europe-west1. It cannot be changed in place. Jobs that join tables must usually run where the data is, so keep related datasets in the same location. In Looker, a LookML view maps to a table and defines dimensions (fields to group by) and measures (totals and counts). A model joins views, and an explore is the page where people pick fields. Metrics defined once stay consistent in every report.
- Choose location from legal rules and latency
- Keep joined datasets in the same location
- Dimension: a field to group or filter by
- Measure: an aggregate such as sum or count
Learn it in 5 short steps
About 30m each. Track them with a timer in your plan.
- 1Restrict access by dataset and column~30m
- 2Check data quality~30m
- 3Follow lineage in Knowledge Catalog~30m
- 4Keep data in the right region~30m
- 5Explain Looker models and explores~30m
Key points
- Grant access at the dataset level first. Add column-level security with policy tags for sensitive columns, and row-level policies when users should see only some rows.
- Check quality early: not-null, unique keys, valid ranges and freshness. Fail or flag a load when a check breaks.
- Knowledge Catalog (formerly Dataplex) shows lineage, which tables and jobs a table came from and feeds.
- A dataset's location is chosen when you create it and cannot be changed later. Pick the region from legal and latency needs.
- In Looker, a LookML model describes tables as views with dimensions and measures. An explore lets people filter and group them.
Key terms
Tap a card to flip it. 0/6 known
Examples
Row-level policy for a regional team
Prerequisites: a BigQuery table orders with a region column, and a Google group for the EU team (use a placeholder like eu-team@example.com). Create a row access policy so that group only sees EU rows. Expected evidence: a member of the group sees only EU rows; others see none unless another policy grants them. Cleanup: drop the policy. This uses synthetic data only.
CREATE ROW ACCESS POLICY eu_only
ON shop_demo.orders
GRANT TO ("group:eu-team@example.com")
FILTER USING (region = "EU");
-- cleanup
DROP ROW ACCESS POLICY eu_only ON shop_demo.orders;Trace a number back from a Looker report
A revenue tile looks too low. Open the explore and note the view and table. Open that table in Knowledge Catalog and view its lineage graph. Find the upstream job that loads it. Run a freshness check on the raw table. In this scenario the check shows the newest row is three days old, so the load job failed. Expected evidence: lineage graph lists the upstream table and job. The fix is in the load job, not in the report.
SELECT MAX(received_at) AS newest,
TIMESTAMP_DIFF(CURRENT_TIMESTAMP(), MAX(received_at), HOUR) AS hours_old
FROM shop_demo.orders_raw;Quick reference
- Grant roles on the dataset, not the whole project
- Policy tags secure columns; row access policies filter rows
- Run quality checks after every load and stop downstream on failure
- Knowledge Catalog (formerly Dataplex) shows lineage
- Dataset location cannot be changed in place
- LookML: view = table, dimension = group by, measure = aggregate
- Define each metric once in the model
Common mistakes
- Giving a whole project the BigQuery Data Viewer role when only one dataset needs it.
- Creating a dataset in the wrong location, then discovering it cannot be moved in place and must be copied.
- Defining the same metric differently in several reports instead of once in the model.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
List the four governance questions and one Google Cloud feature for each.
- Exercise 2medium
Write a SQL check that fails if order_id is duplicated in orders_final.
- Exercise 3hard
Design the access model for orders data: analysts see all but email; support sees emails for their region only.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is Knowledge Catalog the same as Dataplex?
- It is the current name for Dataplex in the Google Cloud docs. Older articles may still use Dataplex.
- Do I need Looker to use BigQuery?
- No. Looker is one way to build reports. You can also use Looker Studio, SQL or notebooks.
- Why keep datasets in the same region?
- Queries that join tables generally need the data in the same location, and moving data across regions can add cost and delay.