Expand description
Declarative quality gates over a ProfileReport.
A pipeline that wants to stop on a bad extract has to turn a report into a
decision. Doing that by hand means re-deciding, at every call site, what an
absent metric means, whether a sampled scan can answer a question about the
whole source, and which number belongs in the log line. This module makes
that decision data: a QualityPolicy states the requirements and
QualityPolicy::evaluate returns a GateResult describing what was
checked and what happened.
Evaluation never exits the process, prints, or mutates the report.
§Verdicts and evidence
The verdict is three-valued, because a decision and the evidence behind it are separate facts. A requirement about the full source cannot be passed by a truncated or sampled scan: nothing was observed that rules the failure out. It can still be failed by one, when the scan witnessed a violation that more scanning cannot retract. So:
Verdict::Fail— at least one requirement was conclusively violated.Verdict::Inconclusive— nothing was violated, and at least one requirement could not be evaluated (a metric was not analyzed, a column was not profiled, the evidence does not reach as far as the requirement).Verdict::Pass— every requirement was evaluated and met.
Fail wins over Inconclusive: a witnessed violation is a decision.
§Example
use dataprof_runtime::{ProfileReport, QualityPolicy, Verdict};
fn gate(report: &ProfileReport) -> Result<bool, Box<dyn std::error::Error>> {
let result = QualityPolicy::new()
.min_quality_score(90.0)
.max_null_percentage("customer_id", 0.0)
.max_null_percentage_any(20.0)
.require_quality()
.evaluate(report)?;
if result.verdict != Verdict::Pass {
for violation in result.violations() {
eprintln!("{}: {}", violation.code, violation.message);
}
}
Ok(result.passed())
}Structs§
- Check
- One requirement and what the report said about it.
- Check
Bounds - The interval a sampled score was decided on.
- Gate
Result - The structured result of evaluating a
QualityPolicy. - Quality
Policy - What a report must satisfy.
Enums§
- Check
Code - Stable identifier for the requirement a check came from.
- Check
Status - What happened to one requirement.
- Evidence
- Whether the data behind a number covers the whole source.
- Evidence
Gap - Why the data behind a number falls short of the whole source.
- Expectation
- The constraint a check applied.
- Metric
Value - A number a check read, or a threshold it compared against.
- NotEvaluated
- Why a requirement was not evaluated.
- Policy
Error - A policy that cannot be evaluated as written.
- Policy
Scope - What the requirements in a policy are statements about.
- Required
Metric - A metric a policy requires to have been analyzed.
- Verdict
- The overall outcome of a policy.