Keep bad records from quietly reaching consumers
A daily fact table can pass a row-count test even when half its business keys repeat.
Keep bad records from quietly reaching consumers
A daily fact table can pass a row-count test even when half its business keys repeat. Test completeness, uniqueness and reference integrity separately. Stratify samples if rare categories carry greater risk. A skewed partition affects runtime; it can also make an unbalanced sample unrepresentative.
Decisions to rehearse
- Completeness rule
- A non-null or non-empty check measures whether a required field is present.
- Uniqueness rule
- Comparing key count with distinct key count detects repeated business keys.
- Stratified sampling
- Sampling within groups preserves visibility into rare populations that random selection can miss.
- Split or salt the hot key
- Distributing an oversized key's work can reduce stragglers when a correct downstream aggregation recombines it.
Practise each AWS skill
These references use the skill numbers in the AWS guide.
- 3.4.1 · Reject or quarantine rows lacking a required value while retaining source identifiers for reprocessing.
- 3.4.2 · Implement separate range, uniqueness and completeness rules; state which rules block publication.
- 3.4.3 · Compare source and destination keys by partition and investigate a sample mismatch before approving reconciliation.
- 3.4.4 · Represent rare vendors deliberately in a stratified sample and explain what the sample cannot prove.
- 3.4.5 · Measure a hot key's share, split its processing when appropriate and recombine partial results at the correct grain.
Official skills for this topic
Work through the decision
A quality sample contains no records from a low-volume but regulated supplier. The overall completeness score is 99.9%. What test would let the steward judge the supplier's feed?
Check your reasoning
Validate mandatory fields and unique keys for that supplier independently. Stratify the review by supplier and compare rejection rates. The aggregate score can hide a concentrated defect.
Catch a balanced but corrupt batch
2:29:53 · Completeness and uniqueness. The recording distinguishes required values from unique keys. Predict which rule will fail for each damaged invoice.
Both sources claim four input rows. Predict which checks fail before running the code. Replace the repeated invoice with i4 and the missing country with GB, then rerun the checks. Run with Python 3 and its standard library.
from collections import Counter
expected = 4
batch = [("i1", "US"), ("i2", ""), ("i2", "FR"), ("i3", "GB")]
counts = Counter(invoice for invoice, country in batch)
print("rows match:", len(batch) == expected)
print("duplicate keys:", sorted(key for key, n in counts.items() if n > 1))
print("missing countries:", sum(not country for _, country in batch))
Check the result
rows match: True duplicate keys: ['i2'] missing countries: 1
A total by itself cannot distinguish a duplicate from the missing invoice it replaces. Run completeness and uniqueness checks independently.
Related lesson in Data Engineer Associate · Data integrity.
Keep bad records from quietly reaching consumers quiz
Answer 3 questions. Check each answer for an explanation.
Worked example · Keep bad records from quietly reaching consumers