odcs.read()
Read an ODCS contract as conditions.
Usage
odcs.read(
source,
*,
strict=False,
)Each schema object gives a list of conditions (OdcsContract.conditions): required columns NOT NULL, the primaryKey columns sv.key, unique columns and duplicateValues rules sv.unique, value sets (enum, invalidValues with validValues) IN lists, the bounds in logicalTypeOptions comparisons, rowCount caps sv.max_rows, foreign keys sv.references, and sql rules of the form SELECT COUNT(*) FROM {object} WHERE <rows that break it> that must be 0 the condition that no row is counted. ODCS leaves NULLs to required, so on a column that may be NULL a rule on values lets NULL through.
Every other rule (free text, a custom engine’s, a pattern, a threshold other than 0, a share of rows) is listed in unread, with the reason, and read warns.
Parameters
source: str | Path | Mapping[str, Any]-
A file (YAML, or JSON by its
.jsonsuffix), the document’s text, or the document as a dict. strict: bool = False- Raise if any rule is unread. Default False: warn.
Returns
OdcsContract- An OdcsContract.
Raises
ValueError-
The document is no ODCS 3.x contract, or with
strict, some rule is unread.