What You'll Learn
- 1Model a lake as zones and assets that match sensitivity and processing stage
- 2Configure discovery scans so schemas and PII land in the catalog automatically
- 3Attach data quality scans with dimensional rules and thresholds to governed tables
- 4Use lineage and the universal catalog to answer impact-analysis questions during incidents
Dataplex is GCP's governance fabric for data that lives in many places. Rather than moving data into a single system, Dataplex attaches management to where the data already sits: Cloud Storage buckets, BigQuery datasets, Bigtable instances, and Pub/Sub topics become catalogued assets under a lake, discoverable, profiled, quality-checked, and traceable. For data engineers it is the layer that turns a pile of tables into a system with ownership, rules, and lineage.
The Lake, Zone, Asset Hierarchy
A lake is a management boundary inside a project and region. Zones sit inside lakes and encode the processing stage and sensitivity of what they hold: raw zones keep unprocessed, schema-on-read data with restricted access; curated zones hold validated, business-ready assets. Assets are the actual resources, attached to a zone with discovery configuration, so the lake knows what exists and when it last changed.
| Level | What it represents | What you configure |
|---|---|---|
| Lake | regional governance boundary | display name, encryption, logging |
| Zone | processing stage and sensitivity | raw or curated type, discovery defaults |
| Asset | attached resource | bucket, dataset, schedule, sync settings |
Putting a bucket in the wrong zone is the common modelling error: raw landing data parked in a curated zone inherits the access posture of production-curated data, and the boundary the architecture promised simply does not exist.
from google.cloud import dataplex_v1
client = dataplex_v1.DataplexServiceClient()
parent = "projects/my-project/locations/us-central1"
lake = client.create_lake(
request={
"parent": parent,
"lake_id": "analytics-lake",
"lake": {
"display_name": "Analytics Lake",
"description": "Governed analytics data for the product domain",
},
}
)
raw_zone = client.create_zone(
request={
"parent": lake.name,
"zone_id": "raw-zone",
"zone": {
"display_name": "Raw Zone",
"type_": dataplex_v1.Zone.Type.RAW,
"resource_spec": {"location_type": "SINGLE_REGION"},
"discovery_spec": {"enabled": True, "schedule": "0 */6 * * *"},
},
}
)
asset = client.create_asset(
request={
"parent": raw_zone.name,
"asset_id": "landing-bucket",
"asset": {
"display_name": "Landing Bucket",
"resource_spec": {
"name": "//storage.googleapis.com/my-landing-bucket",
"type_": dataplex_v1.Asset.ResourceSpec.Type.STORAGE_BUCKET,
},
"discovery_spec": {"enabled": True},
},
}
)
Discovery schedules are cron expressions evaluated by Dataplex; a six-hour cadence suits raw landing zones where files arrive continuously, while BigQuery-linked curated assets usually sync on metadata changes rather than a clock.
Discovery and Profiling
Discovery walks attached assets and records what it finds: schemas for tables and files, data types, partition structures, and potentially sensitive columns. Sensitivity identification piggybacks on the same info-type machinery as Cloud DLP, so a column that looks like an email address is flagged without extra wiring. Profiling goes deeper, computing row counts, null fractions, and value distributions that make the catalog useful for someone deciding whether a dataset is fit for a model.
# Run discovery on demand instead of waiting for the schedule.
gcloud dataplex assets search \
--project=my-project \
--location=us-central1 \
--query="name:projects/my-project/locations/us-central1/lakes/analytics-lake/zones/raw-zone"
Discovery output flows into the universal catalog, which is Dataplex's merged view of entries and aspects across BigQuery, Cloud Storage, and external systems. Search becomes the front door: a data scientist finds the curated customers table, reads its profile, checks the owner aspect, and requests access without opening a ticket against an engineer's calendar. The cadence you pick for discovery trades freshness against cost: continuous metadata sync suits curated BigQuery assets whose schemas shift with deploys, while a six-hour crawl on a raw bucket is usually enough for landing files that arrive on a daily batch. Discovery also surfaces schema drift as a catalog event rather than a downstream query failure, which turns the usual silent breakage into something a monitoring alert can name before a consumer does.
Data Quality Scans
Quality scans attach rule sets to an asset and evaluate them on a schedule. Dimensional rules cover completeness, uniqueness, validity, and freshness; custom SQL rules express business invariants that dimensions cannot capture, such as revenue never being negative or a status column staying within an enum. Each rule carries a threshold, and the scan records pass or fail per run, which is what alerting hooks into.
scan = client.create_data_scan(
request={
"parent": parent,
"data_scan_id": "curated-customers-quality",
"data_scan": {
"display_name": "Curated Customers Quality",
"data": {
"resource": "projects/my-project/datasets/curated/tables/customers"
},
"data_quality_spec": {
"rules": [
{
"dimension": "COMPLETENESS",
"column": "customer_id",
"threshold": 1.0,
"non_null_expectation": {},
},
{
"dimension": "UNIQUENESS",
"column": "customer_id",
"threshold": 1.0,
"uniqueness_expectation": {},
},
{
"dimension": "VALIDITY",
"column": "email",
"threshold": 0.99,
"regex_expectation": {"pattern": "^[^@]+@[^@]+\\.[^@]+$"},
},
],
"sampling_percent": 10,
"row_filter": "is_active = TRUE",
},
},
}
)
Sampling trades exactness for cost: a ten percent sample catches distributional breakage fast, while uniqueness on a primary key should run full-table because a duplicate key is a discrete event a sample can miss. Wire scan results into Pub/Sub and you can fail a Dataform or Composer step when yesterday's curated load violated a rule, which closes the loop between governance and orchestration.
Lineage
Lineage records how data moved: which source tables fed a Dataflow job, what that job wrote, and which marts read the result. Dataplex exposes a Lineage API with processes and links, and pipelines from Dataflow and Dataproc can emit lineage events as they run. The payoff is incident response: when a revenue number looks wrong, the lineage graph answers which upstream change landed before the number moved, instead of a whiteboard session reconstructing the pipeline from memory.
Lineage quality depends entirely on instrumentation. A pipeline that writes tables without emitting lineage events leaves gaps that make the graph worse than useless, because users learn to distrust the edges that do exist. Treat lineage emission like logging: mandatory in shared pipelines, reviewed in code, and verified after deploys. The operational payoff appears in two scenarios. First, incident triage, where the graph answers which upstream table changed before a metric moved. Second, decommissioning, where an engineer asked to delete a table can see every downstream consumer still reading it, which replaces folklore with a queryable answer and prevents the outage that deleting "an unused table" usually causes.
Universal Catalog, Entries, and Aspects
The universal catalog generalises the old Data Catalog model into entries, entry groups, and aspects. An entry is a governed object, such as a BigQuery table or a Cloud Storage prefix; aspects are typed fragments of metadata attached to entries, such as an ownership record, a SLA statement, or a custom schema annotation. Teams define aspect types once and attach them consistently, which is how metadata standards stop being a wiki page nobody updates.
# Create an entry group and register a BigQuery table as an entry.
gcloud dataplex entry-groups create owners \
--project=my-project --location=us-central1 --lake=analytics-lake
gcloud dataplex entries create customers-entry \
--project=my-project --location=us-central1 \
--entry-group=owners \
--entry-id=customers \
--type=projects/my-project/locations/us-central1/entryTypes/bigquery-table \
--fully-qualified-name=//bigquery.googleapis.com/projects/my-project/datasets/curated/tables/customers \
--display-name="Curated Customers"
Governance Patterns and Cost
A working governance pattern assigns each lake zone an owner team, requires discovery on every asset, gates access through IAM combined with BigQuery policy tags for column-level restrictions, and treats quality scan failures as pipeline failures. Cost-wise Dataplex charges for metadata management and for scan work: discovery frequency, profiling depth, and quality scan sampling are the dials. Over-scanning is the budget surprise, so start scans at low sampling on wide tables and only raise the rate where a rule has earned the cost. The organisational side matters just as much as the technical one: a lake without an owning team accumulates unregistered assets within a quarter, and the catalog slowly reverts to the same swamp it was meant to replace, which is why zone-level ownership belongs in the same review process as the IAM bindings themselves.
Common Mistakes
Attaching landing buckets to curated zones
Fix: Raw data belongs in raw zones with tighter IAM; curated access should be earned by passing quality scans first.
Relying on scheduled scans without alerting on failures
Fix: Publish scan results to Pub/Sub and fail the orchestrating pipeline when a threshold is breached, so governance is enforced rather than decorative.
Leaving lineage uninstrumented in shared pipelines
Fix: Emit lineage events from Dataflow and Dataproc jobs in code review, or the catalog will silently go stale and lose trust.
Best Practices
- Mirror the processing stage in zone placement and enforce it with IAM
- Sample aggressively on first scans, then raise coverage only for rules that need it
- Own aspect types centrally so metadata stays queryable across teams
Key Takeaways
- Lakes hold zones, zones hold assets; zone choice encodes sensitivity and stage, not convenience
- Discovery and profiling populate the catalog on a cron you control and flag PII through DLP-style info types
- Quality scans with dimensional and SQL rules turn data contracts into scheduled, thresholded checks
- Lineage is only as good as the instrumentation you ship inside the pipelines themselves
Interview Questions
Interview Questions
Q1: What is the difference between a zone and an asset?
A zone is a logical container with access rules and discovery defaults for a processing stage; an asset is a concrete resource such as a GCS bucket or BigQuery dataset attached to that zone and scanned by its schedule.
Q2: How does Dataplex discover PII in a new dataset?
Discovery scans the attached asset, applies DLP-style info-type recognisers to columns, and records sensitivity findings as catalog metadata, which policy tags and IAM then enforce.
Q3: When should a quality rule run on a sample versus full data?
Distributional rules like validity can sample to control cost; keys and referential rules must run full-table because a single violation is the failure mode and sampling can miss it.
Q4: How do you use lineage during an incident?
Start at the broken table, walk upstream edges to the most recent changed process, and correlate that process's deploy time with the time the metric moved; the graph replaces pipeline archaeology.