Why governance ensures data trust in dbt - Performance Analysis
We want to understand how the time it takes to check data governance rules grows as data grows.
How does enforcing governance affect the work done on data in dbt?
Analyze the time complexity of the following dbt model with governance checks.
-- model.sql
select
user_id,
count(*) as total_events
from {{ ref('events') }}
where event_date >= '2024-01-01'
and event_date <= '2024-01-31'
and is_valid = true -- governance filter
group by user_id
This code filters events by date and a governance flag, then counts events per user.
- Primary operation: Scanning each event row to check date and validity.
- How many times: Once for every event in the input table.
As the number of events grows, the work to check each event grows too.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 checks |
| 100 | 100 checks |
| 1000 | 1000 checks |
Pattern observation: The work grows directly with the number of events.
Time Complexity: O(n)
This means the time to enforce governance rules grows linearly with data size.
[X] Wrong: "Governance checks only add a tiny fixed cost, so time stays the same no matter data size."
[OK] Correct: Each row must be checked, so more data means more work, not a fixed cost.
Understanding how governance affects processing time helps you explain data quality work clearly and confidently.
"What if we added multiple governance filters instead of one? How would the time complexity change?"
Practice
Solution
Step 1: Understand the role of governance
Governance creates rules and standards to ensure data is accurate and consistent.Step 2: Connect governance to trust
When data is accurate and consistent, teams can trust and confidently use it.Final Answer:
It sets clear rules to keep data accurate and consistent. -> Option DQuick Check:
Governance = Clear rules = Trust [OK]
- Thinking governance slows down data use
- Believing governance hides data
- Assuming governance removes documentation
Solution
Step 1: Identify dbt features
dbt models build data tables, seeds load static data, snapshots track changes, tests check data quality.Step 2: Match feature to governance
Data governance needs quality checks, which dbt tests provide by validating data correctness.Final Answer:
dbt tests -> Option BQuick Check:
Tests = Quality checks = Governance support [OK]
- Confusing models with tests
- Thinking snapshots check quality
- Assuming seeds validate data
user_id contains NULL values?
version: 2
models:
- name: users
columns:
- name: user_id
tests:
- not_null
Solution
Step 1: Understand the
This test checks that the specified column has no NULL values.not_nulltestStep 2: Analyze the presence of NULLs
Ifuser_idcontains NULLs, the test will detect them and fail.Final Answer:
The test will fail because NULL values exist in user_id. -> Option AQuick Check:
not_null test + NULL values = Fail [OK]
- Assuming NULLs pass not_null test
- Thinking test is ignored automatically
- Believing syntax error occurs
tests:
- unique:
column_name: email
But it does not run. What is the error?Solution
Step 1: Check correct test syntax in dbt schema.yml
Tests on columns go under thecolumnssection with just- uniquelisted.Step 2: Identify the mistake
The test is incorrectly placed and usescolumn_name, which is not valid here.Final Answer:
The test should be under thecolumnssection with just- unique. -> Option CQuick Check:
Unique test syntax = under columns with - unique [OK]
- Using parameters like column_name in schema tests
- Placing tests outside columns section
- Thinking SQL files are needed for built-in tests
Solution
Step 1: Understand governance needs
Governance requires both clear documentation and data quality checks to build trust.Step 2: Evaluate options
Write detailed model descriptions and add tests likenot_nullanduniqueon key columns. combines documentation and tests, supporting governance best. Others skip key parts.Final Answer:
Write detailed model descriptions and add tests likenot_nullanduniqueon key columns. -> Option AQuick Check:
Docs + tests = Strong governance [OK]
- Skipping docs or tests thinking one is enough
- Avoiding tests to speed builds
- Relying only on snapshots for trust
Ready to prove it?
Pass the test and this pattern moves unknown
