Stratified sampling is a probability sampling technique that separates a population into mutually exclusive, collectively exhaustive groups called strata, then randomly selects records within every stratum. Each record must belong to exactly one stratum. Useful strata reflect differences relevant to the investigation, such as source system, geographic region, device type, or ingestion date. For data quality assessment, this approach helps expose problems that a simple random sample might miss in small but operationally important groups.
Consider a pipeline that processes one million transactions daily: 900,000 from one source system, 90,000 from another, and 10,000 from a third. A proportional sample of 1,000 records would allocate 900, 90, and 10 records respectively. This preserves the population's source-system distribution, but ten records may provide insufficient evidence about the smallest source. An engineer could instead select 300 records from each source to support more useful source-level comparisons.
That second design uses disproportionate allocation. It improves coverage of smaller groups, but its raw combined error rate does not represent the overall population error rate. To estimate the population rate, weight each stratum's observed error rate by that stratum's share of the population. Equivalently, for simple random sampling without replacement within each stratum, each sampled record has a population expansion weight of N_h divided by n_h, where N_h is the stratum population size and n_h is its sample size.
In a cloud pipeline, first define the population and time window, count records by stratum, and choose sample allocations. Use distributed processing or SQL to perform random selection within each group, then apply checks for missing values, invalid formats, inconsistent business rules, and other quality issues. Store the sampled records together with their stratum, population count, sampling probability, and run identifier. Keeping these details makes results interpretable and supports repeatable investigations.
A SQL implementation can assign ROW_NUMBER() over each stratum ordered by a random expression, then retain rows up to the required allocation. This can require expensive scans, shuffles, and sorts. Fraction-based sampling may be cheaper, but often produces approximate rather than exact group sizes. A seeded random generator can support reproducibility under controlled execution conditions; a stable hash of a unique record identifier can support repeatable selection when its distribution is suitable.
Stratified sampling is not cluster sampling: stratification samples within every group, whereas cluster sampling selects groups and examines records within the selected groups. It is also not simply taking the first records from each partition, which can introduce ordering bias. Storage partitions can help identify strata, but partitioning alone does not perform sampling. Excessively detailed strata create many tiny groups and increase operational complexity.
For certification scenarios, choose stratified sampling when important subpopulations need deliberate representation. It can improve precision when the strata explain variation in the measured quality characteristic, but it does not guarantee that rare defects will be detected. Sample-based validation estimates quality; it does not prove that every record satisfies a constraint. Use full-data checks where requirements demand exhaustive validation, such as enforcing uniqueness or rejecting every malformed record.