Data quality
DEA-C01 · Lesson 18 of 23 · 2:28:58
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the DEA-C01 exam (AWS Certified Data Engineer – Associate). In this lesson: quality checks while the data flows (empty fields, nulls, repeated rows, ranges, row counts), AWS Glue Data Quality and DQDL rules in the Data Catalog and in ETL jobs, DataBrew rulesets, random and stratified sampling, and data skew handled with the Spark UI, Adaptive Query Execution, better keys, and salting. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Data you cannot trust
AnyCompany Games trains a churn model on last month's sessions, but one row in ten has an empty region, and some matches appear twice. Meanwhile, a nightly Spark job takes four hours, because one hugely popular game holds most of the rows. This lesson covers quality checks in pipelines, rules in DataBrew, sampling techniques, and data skew.
Quality checks in pipelines
Check quality while the data flows, before bad rows reach the lake: empty fields, nulls in key columns, repeated rows, values out of range, and row counts that drop suddenly. AWS Glue Data Quality evaluates rules written in DQDL, the Data Quality Definition Language, on tables in the Data Catalog or inside Glue ETL jobs, and it can recommend rules from your data. IsComplete checks a column for nulls, IsUnique for repeated values, Completeness for a share of non-null values, ColumnValues for ranges or empty strings, and RowCount checks the number of rows. In a job, the Evaluate Data Quality transform can add columns that list the rules that each row failed, so you can route bad rows to a quarantine location. Actions publish metrics to CloudWatch and EventBridge for alerts, and on ruleset failure, the job can continue, fail after loading, or fail without loading the target.
Rules and consistency in DataBrew
In DataBrew, a ruleset groups data quality rules that compare data metrics with expected values, and if any rule fails, the whole ruleset fails validation. A rule can check one column or several columns at once, like values between zero and one hundred, or missing values that stay under five percent. To investigate consistency, a rule can compare two columns row by row, like an end time later than the start time for at least ninety-five percent of rows, or count repeated values. You add rulesets to a profile job, which produces a validation report next to the data profile, with a Data Quality tab in the console. When the profile job completes, DataBrew sends an event for each ruleset, with a status of succeeded, failed, or error, so an EventBridge rule can notify the team or start the next step.
Sampling
Profiling or testing every row is slow and costly, so you often work on a sample, and the technique decides whether the sample represents the data. Random sampling gives every row the same chance, like the sample method of a Spark DataFrame, or Athena's table sample with the Bernoulli method, which keeps each row with the probability that you set. Athena's system method keeps or skips whole segments of data, which is faster, but the rows are not sampled independently. Stratified sampling takes a fraction of each group, or stratum, like the sampleBy method of Spark, so small groups, like rare regions or rare fraud cases, stay in the sample. And a DataBrew project samples the first rows by default, or a random selection of rows, so check which one you use before you trust a profile.
Data skew
Data skew happens when rows are not spread evenly across partitions, so a few tasks take much longer than the others, and the whole job waits for them. The Spark UI shows it: an uneven event timeline, and task durations whose maximum is far above the median. Adaptive Query Execution, on by default since Glue version four, splits skewed partitions in joins into smaller tasks, and a join key with more distinct values, or a composite key, spreads the rows better. Salting adds a random suffix to a hot key, like a date followed by a number from one to two hundred, so its rows spread over many partitions, at the cost of extra work to bring them back together. In Redshift, a distribution key where a few values dominate puts most rows on a few slices: choose a column with high cardinality, or let AUTO distribution choose.
Quality at AnyCompany Games
Here is the setup at AnyCompany Games: each Glue job evaluates a DQDL ruleset, and fails before loading when player IDs are incomplete or match IDs repeat. Bad rows are flagged and routed to a quarantine prefix, and the data quality metrics feed a CloudWatch alarm. The data science team receives a stratified sample by region, and DataBrew rulesets check that every session ends after it starts. And the nightly join on game ID uses Adaptive Query Execution and a salted key for the hit games, so it runs in minutes rather than hours.
Recap
Let's recap. Check quality while the data flows: empty fields, nulls, repeated rows, ranges, and row counts. Glue Data Quality runs DQDL rules in the Data Catalog or in ETL jobs, flags bad rows, and can fail a job before it loads. DataBrew rulesets validate data in profile jobs, compare columns for consistency, and send events with their result. Random sampling gives every row the same chance, and stratified sampling keeps the share of each group. And for skew, read the Spark UI, then use Adaptive Query Execution, better keys, and salting.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
A Glue ETL job loads match results into the lake each night. The team wants the load to stop when more than 1% of rows have no player ID, and an alert to go out. What should the data engineer add?
- Data quality rules in the job, failing before loading
- A DataBrew project on a sample of five hundred rows
- An Athena query on the table after each nightly load
- A Glue crawler set to add new columns only
Show the answer
Data quality rules in the job, failing before loading
Glue Data Quality evaluates the rules in the job, and it can fail the job before it loads the target, while its metrics feed an alert. “A DataBrew project on a sample of five hundred rows” would look at a sample in a project, without stopping any load. “An Athena query on the table after each nightly load” would find the nulls after they reached the lake. And “A Glue crawler set to add new columns only” would handle new columns, not null values.
The data science team needs a 10% sample of 300 million sessions for a churn model. Players in small regions make up 1% of the rows, and each region must keep its exact share in the sample. Which technique should the data engineer use?
- The first ten percent of rows, in load order
- A random sample of ten percent of all the rows
- Athena system sampling, on segments of the data
- Stratified sampling with region as the stratum
Show the answer
Stratified sampling with region as the stratum
Stratified sampling takes ten percent of each region, so even small regions keep their exact share. “The first ten percent of rows, in load order” would depend on the load order, which can favor some regions or dates. “A random sample of ten percent of all the rows” would give every row the same chance, but small regions could end up with too few rows. And “Athena system sampling, on segments of the data” would keep or skip whole segments, so the rows are not sampled independently.
A Glue Spark job joins events with players by game ID. In the Spark UI, one task runs for 40 minutes while the others finish in seconds, because one hit game holds most of the events, and Adaptive Query Execution is already on. What should the data engineer do?
- Add workers, with the same join key
- Salt the game ID with a random suffix
- Turn on job run insights for the job
- Group the small input files on read
Show the answer
Salt the game ID with a random suffix
Salting spreads the rows of the hit game over many partitions, so no single task does most of the work. “Add workers, with the same join key” would add workers, but one task would still hold the hot key. “Turn on job run insights for the job” would explain failures, but this job does not fail, it is slow. And “Group the small input files on read” would fix many small files, not one hot key.