Lesson 1 of 5 Data Quality, Cleaning and Labeling

Validating Data Quality Before Training

This lesson explains how automated data quality checks catch missing, invalid and stale data before it reaches training or inference, turning data expectations into rules that run every time.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the dimensions of data quality.
  • Write Glue Data Quality rules in DQDL.
  • Use DataBrew profiles and rules.
  • Gate a retraining pipeline on data quality.

Dimensions of data quality

Data quality is usually described along several dimensions. Completeness asks whether required values are present. Validity asks whether values fit their type, format and allowed range. Uniqueness asks whether records that should be unique are. Consistency asks whether related values agree across fields and sources. Timeliness or freshness asks whether the data is recent enough. For ML, a further check is distribution stability: whether statistics such as means and category frequencies have shifted from previous loads.

Sort into groups

Name the quality problem

Exam skills 1.3.1

Sort each data problem into the quality dimension it breaks.

Log in to try this activity Interactive activities are free with an account.

AWS Glue Data Quality

AWS Glue Data Quality evaluates rules written in the Data Quality Definition Language (DQDL). Rules can run against Data Catalog tables on demand or on a schedule, or inside Glue ETL jobs as a transform. Glue can recommend rules by analysing a table's statistics, and anomaly detection learns the normal range of statistics, such as row count or distinct values, and flags unusual loads without hand-set thresholds.

Rules = [
    RowCount > 10000,
    IsComplete "customer_id",
    IsUnique "transaction_id",
    ColumnValues "age" between 18 and 110,
    ColumnValues "country" in ["US", "CA", "MX"],
    Completeness "income" > 0.95,
    DataFreshness "event_time" <= 24 hours
]

In an ETL job, the evaluation result can stop the job, or the job can split rows into passed and failed outputs so failing rows are quarantined while good rows continue. Results are published to CloudWatch and EventBridge for alerts.

The following diagram shows a data quality gate added at the start of a weekly retraining pipeline.

The quality gate added at the start of the weekly retraining pipeline. Glue Data Quality checks row count, completeness of key columns and price > 0, and anomaly detection watches mean price and row count. If the ruleset fails, the pipeline stops and EventBridge alerts the data owners through SNS, so a file of zero prices never reaches training.
Anomaly detection flags unusual loads that still pass fixed rules.
Match the pairs

Write the DQDL rule

Exam skills 1.3.1

Match each requirement with the Data Quality Definition Language (DQDL) rule that checks it.

Log in to try this activity Interactive activities are free with an account.

DataBrew profiles and rules

AWS Glue DataBrew offers a visual alternative to rules written in code. A profile job reports, for each column, missing values, distinct counts, value distributions, outliers and correlations with other columns, and data quality rulesets validate conditions, such as allowed ranges or maximum missing percentages, during profiling.

The two tools suit different people and stages. DataBrew suits analysts and data scientists exploring a dataset interactively, deciding whether it is fit for modelling. Glue Data Quality suits engineers embedding checks in production pipelines, where a failed rule can stop bad data from reaching a training job automatically. The following table compares them.

Glue Data Quality
InterfaceDQDL rules (console, API, ETL transform)
Runs inCatalog tables, Glue ETL jobs
Special featuresRule recommendations, anomaly detection, row-level results
Best forAutomated gates in pipelines
Glue DataBrew
InterfaceVisual profiles and rulesets
Runs inDataBrew profile jobs
Special featuresColumn statistics, correlations, PII detection
Best forExploring and validating datasets without code
True or false

DataBrew data quality

Exam skills 1.3.1

Check what DataBrew profile jobs and rulesets provide.

Log in to try this activity Interactive activities are free with an account.
Worked example

A quality gate before training

A weekly retraining pipeline once trained on a file in which a source system had sent every price as zero. The model was deployed and recommended free products.

  • Add a Glue Data Quality evaluation at the start of the pipeline with rules for row count, completeness of key columns and ColumnValues "price" > 0.
  • Enable anomaly detection on mean price and row count so unusual loads are flagged even if they pass fixed rules.
  • If the ruleset fails, the pipeline stops and EventBridge sends an SNS alert to the data owners.

The gate costs seconds per run and would have stopped the faulty file before training. Checking model accuracy after training would not, because the evaluation set came from the same faulty load.

Check yourself

How can unusual statistics be detected without fixed thresholds?

Show answer

With Glue Data Quality anomaly detection, which learns the normal range from past runs.

Exam Tips

Remember for the exam

  • Rule-based checks in pipelines: Glue Data Quality with DQDL.
  • Unusual statistics without fixed thresholds: Glue Data Quality anomaly detection.
  • Visual profiling of a dataset: DataBrew profile job.
  • Quarantine failing rows and continue with good rows.
  • Validate data before training, not only the model after training.