Defining and Enforcing Data Quality Rules
This lesson explains how data quality is defined, measured and enforced in pipelines, so that bad data does not flow silently into reports and models.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish the dimensions of data quality.
- Place checks at ingestion, transformation and publication.
- Choose between Glue Data Quality, DataBrew and custom checks.
- Act on results by quarantining, alerting or stopping.
Dimensions of data quality
Data quality is measured along several dimensions, and each kind of check targets one of them. Completeness means no required values are missing, such as an order without a customer. Accuracy means values reflect reality, such as a correct address. Validity means values match expected formats and ranges, such as dates that parse and amounts above zero. Uniqueness means no duplicates, such as one row per order. Consistency means data agrees across systems, such as order totals matching between the source and the warehouse. Timeliness means data is fresh enough for its use. The following table summarises the dimensions.
| Dimension | Meaning |
|---|---|
| Completeness | No required values are missing |
| Accuracy | Values reflect reality |
| Validity | Values match expected formats and ranges |
| Uniqueness | No duplicates |
| Consistency | Data agrees across systems |
| Timeliness | Data is fresh enough |
Quality dimensions
Where and how to check
Checks are most effective at three points in a pipeline, each catching different problems. At ingestion, checks confirm that the schema and format are what was expected, so a malformed file is rejected before it spreads. After transformation, checks apply business rules, such as totals that must balance or values that must be within limits, catching errors in the transformation logic. Before publishing, checks confirm the data is ready for consumers, for example complete for the whole day and fresh, before dashboards or models use it. The following table summarises the checkpoints.
| Checkpoint | Checks |
|---|---|
| At ingestion | Schema and format |
| After transformation | Business rules |
| Before publishing | Readiness for consumers |
Implement checks with Glue Data Quality transforms, SQL assertions in Athena or Redshift, Lambda validation for events, or libraries such as Deequ.
The following diagram shows the three checkpoints along a pipeline.

Which checkpoint?
AWS tools
Three AWS tools implement data quality checks. AWS Glue Data Quality is the most complete: rules written in DQDL check completeness, uniqueness, ranges, referential integrity, comparisons between datasets and freshness. It can recommend rules by analysing the data, detects anomalies such as an unusual drop in row count, and runs both on catalogue tables and inside ETL jobs. Glue DataBrew evaluates rulesets as part of its profile jobs during data preparation. DMS data validation compares rows between source and target after a migration or during replication, to confirm that nothing was lost or changed. The following table summarises the tools.
| Tool | What it does |
|---|---|
| AWS Glue Data Quality | Rules in DQDL for completeness, uniqueness, ranges, referential integrity, data set comparison and freshness; rule recommendations; anomaly detection; runs on catalogue tables and inside jobs |
| Glue DataBrew | Evaluates rulesets in profile jobs |
| DMS data validation | Compares rows between source and target after a migration |
Acting on results
Data quality checks are only worth running if their results lead to action. The right action depends on how harmful bad data would be. Failing records can be quarantined: written to a separate location with the rules they broke, so they can be investigated and corrected, while the good records continue through the pipeline.
When the overall quality score falls below a threshold, the pipeline can fail or pause, so that bad data is not published at all. Results are published to Amazon CloudWatch and Amazon EventBridge, where alarms and rules alert the owners. And quality scores are shown to consumers in SageMaker Catalog, so that anyone deciding whether to use a dataset can see how trustworthy it currently is.
Acting on quality results
Mapping quality dimensions to checks
Each dimension of data quality is verified by a specific check at a particular point in the pipeline. The following table gives an example check for each dimension and where it runs.
| Dimension | Example check | Where |
|---|---|---|
| Completeness | email is present in at least 95% of rows | Glue Data Quality on ingestion |
| Uniqueness | No duplicate order_id values | Glue Data Quality |
| Validity | country is a valid ISO code | Rule with an allowed list |
| Consistency | Order totals equal the sum of their line items | Custom SQL rule |
| Timeliness | Today's partition exists by 06:00 | Freshness metric and alarm |
| Accuracy | Revenue matches the finance system within 0.5% | Reconciliation job |
Checks run where problems are cheapest to catch: on arrival in the cleaned zone. Failing data goes to quarantine rather than flowing into reports, and the results are published so data owners can fix the source.
Name the main data quality dimensions.
Show answer
Completeness, accuracy, validity, uniqueness, consistency and timeliness.
Exam Tips
Remember for the exam
- Know the dimensions: completeness, accuracy, validity, uniqueness, consistency and timeliness.
- Declarative data quality rules in Glue are written in DQDL.
- To confirm that a migration copied data correctly, use DMS data validation.
- Quarantine bad records and alert their owners.
- To detect unusual changes in data statistics, use Glue Data Quality anomaly detection.