Beyond schema checks (presence, type, nullability), a data contract can declare quality rules. When you run datacontract test, executable rules run against the data source and are reported alongside the schema checks.
Quality rules use the ODCS quality attribute, which can be attached either to a schema (table/object level) or to an individual property (column/field level):
schema:
- name: orders
quality: # schema-level rule
- type: library
metric: rowCount
mustBeGreaterThan: 0
properties:
- name: order_total
quality: # property-level rule
- type: library
metric: nullValues
mustBe: 0
ODCS defines four types of quality rule. Each has its own page:
Use --checks to restrict a run to quality rules:
datacontract test --checks quality datacontract.yaml
Executable rules (sql, library) run during test. All rule types are also translated when you export to a quality engine:
dbt_utils tests and singular SQL tests for rules that cannot be expressed natively.When a quality (or schema) check fails, add --include-failed-samples to test to collect a small sample of the offending rows (identifier + offending columns; sensitive columns are omitted). This is off by default.
datacontract test --include-failed-samples datacontract.yaml