# Data quality

## What it is

Data quality describes whether the information available is fit for a particular
use. A dataset can have consistent field types and still lead to the wrong
decision. A map might accept every row in a delivery while some coordinates
refer to the wrong region. A billing export might have the expected fields while
omitting a day. Define quality using the decisions each dataset supports and the
consequences when its information is incomplete, late or misleading.

A useful definition includes several observable properties. Completeness asks
whether the records and fields needed for the task are present. Validity asks
whether a value falls inside the permitted domain or follows an agreed rule.
Uniqueness and consistency matter when rows identify real entities or should
agree with another source. Timeliness describes how recent the information needs
to be. Accuracy often requires a trusted comparison or a review in the world the
data describes.

Measurements put those properties into operation. A check might require one
record per meter and hour, or a region identifier from a maintained reference
table. A different check can establish that all joins preserve the expected
number of observations. Give the measurement a clear input and an expected
result, and name who relies on it.

## Why it matters

Imagine an operations team using a map to direct maintenance crews. A set of
coordinates can be valid geometry and still be assigned to the wrong service
district. The result could send a crew to a different area while a spreadsheet
appears complete. A check comparing each location with the appropriate regional
boundary would serve that decision better than a schema check alone.

Quality can also decline without a dramatic failure. A producer might send a
slightly smaller extract each day until a report leaves out a meaningful part of
the business. A uniqueness test can catch repeated IDs after a retry. A coverage
test can detect missing periods or geographical areas. A ratio can be valuable
where occasional bad records are expected, provided the denominator and the
expected range are documented. A percentage without a count can hide a sudden
drop in the number of records measured.

Different consumers may need different thresholds. A draft dashboard can explain
that part of its input is late. An automated customer decision may need a
stricter eligibility rule. Decide in advance which changes justify a warning,
which prevent publication, and how recovery resumes. A quality check earns its
place when it leads to a useful response.

## What it looks like in practice

Consider a geographic delivery used for a daily outage dashboard. Agree on the
grain, possibly one observation per asset and time interval. Give each
observation a stable identifier. Validate the geometry, check that its region
exists, compare its source timestamp with the reporting deadline and confirm
that each expected area contributed. Put these decisions in a small set of
checks whose results are visible to the people who prepare and consume the
report.

Introduce deliberately flawed fixtures. A duplicate row should trip the
uniqueness rule. A location outside its assigned region should fail the spatial
relationship check. A late feed should leave a visible freshness result even if
all its rows are well formed. Test what the downstream dashboard does in each
case. It might wait, show the last successful edition, or show the valid regions
and mark the missing ones clearly.

Engineer's
[geographical-data quality case study](/portfolio/resolved-1000-issues-in-geographical-data/)
describes identifying recurring geographical and time-series inconsistencies,
correcting them with spatial tools and automating parts of the cleanup. It also
describes delivering the corrected data to visualisations. Quality work has both
parts. Teams need a way to find and repair the source problem and a way to
establish what behaviour the people reading the final product will actually see.

## Where it goes wrong

Quality checks can become a long collection of rules that nobody owns. Begin
with observable failures whose impact people can explain. Each rule should name
its input, the expected condition, its owner and the action after failure. If a
rule is allowed to warn for a defined period, give the exception an expiry and
show it alongside the measured result. A permanently ignored failure teaches
readers that the signal has little meaning.

Automatic repair can obscure the problem it was intended to resolve. Filling a
missing value may be appropriate for a visual estimate. A later reader should be
able to distinguish an estimate from a source observation. Preserve useful
provenance and make repetition safe. A re-run after a correction should operate
on known inputs and create a clearly identifiable result.

A rule also needs a denominator that reflects the data actually inspected.
Suppose a file has eleven valid districts and one that failed to load. A check
that scans the rows alone can report that all observed district IDs are valid. A
separate comparison against the list expected from the source reveals the
missing district. Record whether the absent district was intentionally out of
scope or needs a fresh delivery. The check's output should support that
distinction without requiring an operator to infer it from the passing count.

Finally, measure the fit of the checks over time. Review real incidents to see
which rule caught them and how quickly somebody could act. Record inputs that
were skipped because a feed was absent or a rule could not run. Compare results
after known changes to a source or its consumers. A quality process becomes
easier to trust when it explains both which information passed and which
information was outside what the checks could establish.

## Further reading

- [AWS Glue Data Quality Definition Language](https://docs.aws.amazon.com/glue/latest/dg/dqdl.html).
  Documents one format for defining measurable rules.
- [AWS Glue Data Quality rule types](https://docs.aws.amazon.com/glue/latest/dg/dqdl-rule-types.html).
  Provides examples of completeness, uniqueness and related checks.
- [dbt data tests](https://docs.getdbt.com/docs/build/data-tests). Describes
  reusable and custom tests within a data transformation project.

<https://engineer.company/glossary/data-quality/>
