Verifying and Cleaning Data with SQL, Notebooks and Visual Tools
This lesson explains the AWS tools for looking at data before it is trusted, counting nulls and finding outliers and duplicates, from SQL and code to visual interfaces, and which suits a given team and task.
Learning outcomes
After completing this lesson, you will be able to:
- Verify data with SQL queries and notebooks.
- Clean data visually with DataBrew and SageMaker Data Wrangler.
- Choose a tool for a team and task.
Verifying data with SQL and code
The quickest checks are SQL queries in Athena or Redshift: counting nulls per column, finding duplicate keys with GROUP BY ... HAVING COUNT(*) > 1, and comparing row counts with the source. Lambda functions apply lightweight validation as files arrive, such as checking that a file's header matches the expected columns before it is processed.
Jupyter notebooks suit exploratory investigation in Python or Spark, where an engineer profiles a dataset, plots distributions and tries cleaning logic interactively before putting it into a job. Notebooks are available in Amazon SageMaker Unified Studio, SageMaker AI Studio, EMR Studio and Athena for Apache Spark, so the same exploration can run against the data lake without a local copy.
-- Athena: nulls and duplicate keys in yesterday's partition
SELECT COUNT(*) - COUNT(customer_id) AS null_customer_ids,
COUNT(*) - COUNT(DISTINCT order_id) AS duplicate_order_ids
FROM orders
WHERE order_date = DATE '2026-10-15';The following diagram shows a data preparation flow in SageMaker Data Wrangler and the tools other users would choose.

Visual cleaning: DataBrew, Data Wrangler and Quick Sight
Visual tools let analysts clean data without code. AWS Glue DataBrew profiles datasets and applies recipes of more than 250 transformations, and its jobs run the recipe over the full dataset on a schedule. Amazon SageMaker Data Wrangler, now part of SageMaker Canvas, imports data from S3, Athena, Redshift and other sources, generates a data quality and insights report (missing values, outliers, duplicates, target leakage), and applies hundreds of built-in transformations; it is aimed at preparing data for machine learning and can export its flow as a processing job or notebook. Amazon Quick Sight dashboards make anomalies visible to business users, such as a sudden drop in daily volumes. The following table summarises the choice.
| Tool | Best for |
|---|---|
| Athena or Redshift SQL | Quick checks: nulls, duplicates, counts, ranges |
| Lambda | Lightweight validation as files or events arrive |
| Jupyter notebooks (Unified Studio, SageMaker AI Studio, EMR Studio, Athena Spark) | Exploratory investigation in Python or Spark |
| AWS Glue DataBrew | No-code profiling and recipe-based cleaning for analytics |
| Amazon SageMaker Data Wrangler | Visual data quality reports and preparation for machine learning |
| Amazon Quick Sight | Visual spotting of anomalies by business users |
Verifying and cleaning tools
Preparing training data for data scientists
Data scientists receive a churn dataset that joins customer records from Redshift with support tickets from S3, and they suspect quality problems. In SageMaker Data Wrangler they import both sources, run the data quality and insights report, which reveals 4% missing tenure values and a duplicated customer ID, then impute the missing values, drop the duplicates and export the flow as a repeatable processing job. Analysts preparing the same data for dashboards would use DataBrew instead, and a data engineer investigating a pipeline bug would use a notebook or Athena.
What is the quickest way to check a dataset for nulls, duplicates and row counts?
Show answer
SQL in Athena or Redshift.
Exam Tips
Remember for the exam
- Quick verification of nulls, duplicates and counts: SQL in Athena or Redshift.
- Interactive exploration in Python or Spark: Jupyter notebooks in Unified Studio, SageMaker AI Studio, EMR Studio or Athena.
- Visual data quality report and preparation for ML: SageMaker Data Wrangler.
- No-code cleaning recipes for analytics data: Glue DataBrew.