instruments like dbt make developing SQL knowledge pipelines simple and systematic. However even with the added construction and clearly outlined knowledge fashions, pipelines can nonetheless grow to be complicated, which makes debugging points and validating modifications to knowledge fashions troublesome.
The rising complexity of information transformation logic offers rise to the next points:
- Conventional code overview processes solely take a look at code modifications and exclude the information affect of these modifications.
- Knowledge affect ensuing from code modifications is tough to hint. In sprawling DAGs with nested dependencies, discovering how and the place knowledge affect happens is extraordinarily time-consuming, or close to unimaginable.
Gitlab’s dbt DAG (proven within the featured picture above) is the proper instance of an information mission that’s already a house-of-cards. Think about attempting to comply with a easy SQL logic change to a column by this complete lineage DAG. Reviewing an information mannequin replace could be a frightening process.
How would you method the sort of overview?
What’s knowledge validation?
Knowledge validation refers back to the course of used to find out that the information is appropriate when it comes to real-world necessities. This implies making certain that the SQL logic in an information mannequin behaves as supposed by verifying that the information is appropriate. Validation is normally carried out after modifying an information mannequin, akin to accommodating new necessities, or as a part of a refactor.
A singular overview problem
Knowledge has states and is straight affected by the transformation used to generate it. That is why reviewing knowledge mannequin modifications is a singular problem, as a result of each the code and the information must be reviewed.
Resulting from this, knowledge mannequin updates must be reviewed not just for completeness, but in addition context. In different phrases, that the information is appropriate and present knowledge and metrics weren’t unintentionally altered.
Two extremes of information validation
In most knowledge groups, the individual making the change depends on institutional information, instinct, or previous expertise to evaluate the affect and validate the change.
“I’ve made a change to X, I feel I do know what the affect must be. I’ll verify it by operating Y”
The validation methodology normally falls into certainly one of two extremes, neither of which is right:
- Spot-checking with queries and a few high-level checks like row rely and schema. It’s quick however dangers lacking precise affect. Important and silent errors can go unnoticed.
- Exhaustive checking of each single downstream mannequin. It’s gradual and useful resource intensive, and will be expensive because the pipeline grows.
This ends in an information overview course of that’s unstructured, arduous to repeat, and infrequently introduces silent errors. A brand new methodology is required that helps the engineer to carry out exact and focused knowledge validation.
A greater method by understanding knowledge mannequin dependencies
To validate a change to an information mission, it’s essential to grasp the connection between fashions and the way knowledge flows by the mission. These dependencies between fashions inform us how knowledge is handed and reworked from one mannequin to a different.
Analyze the connection between fashions
As we’ve seen, knowledge mission DAGs will be large, however an information mannequin change solely impacts a subset of fashions. By isolating this subset after which analyzing the connection between the fashions, you’ll be able to peel again the layers of complexity and focus simply on the fashions that truly want validating, given a particular SQL logic change.
The kinds of dependencies in an information mission are:
Mannequin-to mannequin
A structural dependency during which columns are chosen from an upstream mannequin.
--- downstream_model
choose
a,
b
from {{ ref("upstream_model") }}
Column-to-column
A projection dependency that selects, renames, or transforms an upstream column.
--- downstream_model
choose
a,
b as b2
from {{ ref("upstream_model") }}
Mannequin-to-column
A filter dependency during which a downstream mannequin makes use of an upstream mannequin in a the place, be a part of, or different conditional clause.
-- downstream_model
choose
a
from {{ ref("upstream_model") }}
the place b > 0
Understanding the dependencies between fashions helps us to outline the affect radius of an information mannequin logic change.
Determine the affect radius
When making modifications to an information mannequin’s SQL, it’s essential to grasp which different fashions is perhaps affected (the fashions you could verify). On the excessive stage, that is performed by model-to-model relationships. This subset of DAG nodes is called the affect radius.
Within the DAG beneath, the affect radius consists of nodes B (the modified mannequin) and D (the downstream mannequin). In dbt, these fashions will be recognized utilizing the modified+ selector.

Figuring out modified nodes and downstream is a superb begin, and by isolating modifications like this you’ll cut back the potential knowledge validation space. Nevertheless, this might nonetheless end in numerous downstream fashions.
Classifying the sorts of SQL modifications can additional provide help to to prioritize which fashions really require validation by understanding the severity of the change, eliminating branches with modifications which might be recognized to be secure.
Classify the SQL change
Not all SQL modifications carry the identical stage of danger to downstream knowledge, and so must be categorized accordingly. By classifying SQL modifications this manner, you’ll be able to add a scientific method to your knowledge overview course of.
A SQL change to an information mannequin will be categorised as one of many following:
Non-breaking change
Modifications that don’t affect the information in downstream fashions akin to including new columns, changes to SQL formatting, or including feedback and many others.
-- Non-breaking change: New column added
choose
id,
class,
created_at,
-- new column
now() as ingestion_time
from {{ ref('a') }}
Partial-breaking change
Modifications that solely affect downstream fashions that reference sure columns akin to eradicating or renaming a column; or modifying a column definition.
-- Partial breaking change: `class` column renamed
choose
id,
created_at,
class as event_category
from {{ ref('a') }}
Breaking change
Modifications that affect all downstream fashions akin to filtering, sorting, or in any other case altering the construction or which means of the reworked knowledge.
-- Breaking change: Filtered to exclude knowledge
choose
id,
class,
created_at
from {{ ref('a') }}
the place class != 'inner'
Apply classification to scale back scope
After making use of these classifications the affect radius, and the variety of fashions that have to be validated, will be considerably lowered.

Within the above DAG, nodes B, C and F have been modified, leading to probably 7 nodes that have to be validated (C to E). Nevertheless, not every department accommodates SQL modifications that truly require validation. Let’s check out every department:
Node C: Non-breaking change
C is assessed as a non-breaking change. Due to this fact each C and H don’t have to be checked, they are often eradicated.
Node B: Partial-breaking change
B is assessed as a partial-breaking change attributable to change to the column B.C1. Due to this fact, D and E have to be checked solely in the event that they reference column B.C1.
Node F: Breaking change
The modification to mannequin F is assessed as a breaking-change. Due to this fact, all downstream nodes (G and E) have to be checked for affect. As an example, mannequin g would possibly combination knowledge from the modified upstream column
The preliminary 7 nodes have already been lowered to five that have to be checked for knowledge affect (B, D, E, F, G). Now, by inspecting the SQL modifications on the column stage, we are able to cut back that quantity even additional.
Narrowing the scope additional with column-level lineage
Breaking and non-breaking modifications are simple to categorise however, relating to inspecting partial-breaking modifications, the fashions have to be analyzed on the column stage.
Let’s take a better take a look at the partial-breaking change in mannequin B, during which the logic of column c1 has been modified. This modification may probably end in 4 impacted downstream nodes: D, E, Okay, and J. After monitoring column utilization downstream, this subset will be additional lowered.

Following column B.c1 downstream we are able to see that:
- B.c1 → D.c1 is a column-to-column (projection) dependency.
- D.c1 → E is a model-to-column dependency.
- D → Okay is a model-to-model dependency. Nevertheless, as D.c1 shouldn’t be utilized in Okay, this mannequin will be eradicated.
Due to this fact, the fashions that have to be validated on this department are B, D, and E. Along with the breaking change F and downstream G, the entire fashions to be validated on this diagram are F, G, B, D, and E, or simply 5 out of a complete of 9 probably impacted fashions.
Conclusion
Knowledge validation after a mannequin change is troublesome, particularly in giant and complicated DAGs. It’s simple to overlook silent errors and performing validation turns into a frightening process, with knowledge fashions typically feeling like black containers relating to downstream affect.
A structured and repeatable course of
By utilizing this change-aware knowledge validation method, you’ll be able to deliver construction and precision to the overview course of, making it systematic and repeatable. This reduces the variety of fashions that have to be checked, simplifies the overview course of, and lowers prices by solely validating fashions that truly require it.
Earlier than you go…
Dave is a senior technical advocate at Recce, the place we’re constructing a toolkit to allow superior knowledge validation workflows. He’s at all times completely satisfied to talk about SQL, knowledge engineering, or serving to groups navigate their knowledge validation challenges. Join with Dave on LinkedIn.
Analysis for this text was made attainable by my colleague Chen En Lu (Popcorny).