Skip to content

_result_from_counts

Internal helper
This page documents an internal implementation helper, not a primary public API.
Source code in src/fabricops_kit/quality.py
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def _result_from_counts(rule: dict[str, Any], severity: str, failed_count: int, total_count: int, threshold: Any, message: str) -> dict[str, Any]:
    status = "failed" if failed_count > 0 else "passed"
    return {
        "rule_id": rule.get("rule_id", "unknown"),
        "rule_type": rule.get("rule_type", "unknown"),
        "column_name": rule.get("column"),
        "columns": rule.get("columns"),
        "severity": severity,
        "status": status,
        "action": SEVERITY_TO_ACTION[severity] if status == "failed" else "allow",
        "failed_count": int(failed_count),
        "total_count": int(total_count),
        "failed_pct": float((failed_count / total_count) * 100.0) if total_count > 0 else 0.0,
        "threshold": _to_jsonable(threshold),
        "message": message,
        "reason": rule.get("reason"),
    }