Skip to main content

odcs.export()

The contract of node as an ODCS document (ODCS_VERSION).

Usage

Source

odcs.export(
    node,
    *,
    id=None,
    version="1.0.0",
    status="active",
    description=None,
    descriptions=None
)

One schema object, named after the node, with a property per column: its logical and physical (DuckDB) type, required where the node proves the column NOT NULL, and primaryKey or unique for its keys. Value sets become invalidValues rules, row caps rowCount rules, keys over several columns duplicateValues rules, and other row conditions sql rules (SELECT COUNT(*) FROM {object} WHERE NOT COALESCE(<condition>, FALSE), which must be 0). Every flag and rule carries the custom property sverify with its status: proved, checked (on the data, on_unproved="check") or declared. The document’s own sverify property names the node, the plan’s sha256 (as the sink’s contract record has it) and whether the whole contract is proved.

Parameters

node: Node

A node with a contract (a transform’s result, stored or not).

id: str | None = None

The contract’s id. Default: a UUID derived from the node’s name, the same on every export.

version: str = "1.0.0"

The contract’s version. Default “1.0.0”.

status: str = "active"

The contract’s status. Default “active”.

description: str | None = None

The dataset’s purpose (description.purpose and the schema object’s description). Default: the first paragraph of the transform’s docstring, if any.

descriptions: Mapping[str, str] | None = None
A description per column, by name.

Returns

dict[str, Any]
The document as a dict, ready for json.dump or yaml.safe_dump.

Raises

ValueError
node has no contract (a source, or a transform without one).