Column

Inheritance diagram of dbt_contracts.contracts.terms.column.ColumnContractTerm, dbt_contracts.contracts.terms.column.Exists, dbt_contracts.contracts.terms.column.HasDataType, dbt_contracts.contracts.terms.column.HasExpectedName, dbt_contracts.contracts.terms.column.HasMatchingDataType, dbt_contracts.contracts.terms.column.HasMatchingDescription, dbt_contracts.contracts.terms.column.HasMatchingIndex, dbt_contracts.contracts.terms.column.HasTests

Classes

ColumnContractTerm()

Exists()

Check whether the columns exist in the database.

HasDataType()

Check whether columns have a data type configured in their properties.

HasExpectedName(*, ignore_whitespace, ...)

Check whether columns have an expected name based on their data type.

HasMatchingDataType(*[, ignore_whitespace, ...])

Check whether the data type configured in a column's properties matches the data type in the database.

HasMatchingDescription(*[, ...])

Check whether the descriptions configured in columns' properties match the descriptions in the database.

HasMatchingIndex(*[, ignore_whitespace, ...])

Check whether the index position within the properties of a column's table matches the index position in the database.

HasTests(*[, min_count, max_count])

Check whether columns have an appropriate number of tests configured.

class dbt_contracts.contracts.terms.column.ColumnContractTerm

Bases: ChildContractTerm, Generic

class dbt_contracts.contracts.terms.column.Exists

Bases: ColumnContractTerm, Generic

Check whether the columns exist in the database.

needs_catalog: ClassVar[bool] = True

Mark if this term requires a loaded catalog to operate. The catalog must then be provided by the ContractContext for the term to execute successfully.

run(item: ItemT, context: ContractContext, parent: ParentT = None) → bool

Validate the context before running the term.

class dbt_contracts.contracts.terms.column.HasTests(*, min_count: Annotated[int, Ge(ge=1)] = 1, max_count: Annotated[int | None, Gt(gt=0)] = None)

Bases: ColumnContractTerm, RangeMatcher, Generic

Check whether columns have an appropriate number of tests configured.

needs_manifest: ClassVar[bool] = True

Mark if this term requires a loaded manifest to operate. The manifest must then be provided by the ContractContext for the term to execute successfully.

run(item: ItemT, context: ContractContext, parent: ParentT = None) → bool

Validate the context before running the term.

class dbt_contracts.contracts.terms.column.HasExpectedName(*, ignore_whitespace: bool = False, case_insensitive: bool = False, compare_start_only: bool = False, patterns: ~collections.abc.Mapping[str | None, ~collections.abc.Sequence[str]] = <factory>)

Bases: ColumnContractTerm, StringMatcher, Generic

Check whether columns have an expected name based on their data type. Matches the column names against a set of patterns mapped to specific data types.

patterns: Mapping[str | None, Sequence[str]]
classmethod make_pattern_values_tuple(patterns: Mapping[str | None, str | Sequence[str]]) → dict[str | None, tuple[str]]

Convert all meta values to tuples

run(item: ItemT, context: ContractContext, parent: ParentT = None) → bool

Validate the context before running the term.

class dbt_contracts.contracts.terms.column.HasDataType

Bases: ColumnContractTerm, Generic

Check whether columns have a data type configured in their properties.

run(item: ItemT, context: ContractContext, parent: ParentT = None) → bool

Validate the context before running the term.

class dbt_contracts.contracts.terms.column.HasMatchingDescription(*, ignore_whitespace: bool = False, case_insensitive: bool = False, compare_start_only: bool = False)

Bases: ColumnContractTerm, StringMatcher, Generic

Check whether the descriptions configured in columns’ properties match the descriptions in the database.

needs_catalog: ClassVar[bool] = True

Mark if this term requires a loaded catalog to operate. The catalog must then be provided by the ContractContext for the term to execute successfully.

run(item: ItemT, context: ContractContext, parent: ParentT = None) → bool

Validate the context before running the term.

class dbt_contracts.contracts.terms.column.HasMatchingDataType(*, ignore_whitespace: bool = False, case_insensitive: bool = False, compare_start_only: bool = False)

Bases: ColumnContractTerm, StringMatcher, Generic

Check whether the data type configured in a column’s properties matches the data type in the database.

needs_catalog: ClassVar[bool] = True

Mark if this term requires a loaded catalog to operate. The catalog must then be provided by the ContractContext for the term to execute successfully.

run(item: ItemT, context: ContractContext, parent: ParentT = None) → bool

Validate the context before running the term.

class dbt_contracts.contracts.terms.column.HasMatchingIndex(*, ignore_whitespace: bool = False, case_insensitive: bool = False, compare_start_only: bool = False)

Bases: ColumnContractTerm, StringMatcher, Generic

Check whether the index position within the properties of a column’s table matches the index position in the database.

needs_catalog: ClassVar[bool] = True

Mark if this term requires a loaded catalog to operate. The catalog must then be provided by the ContractContext for the term to execute successfully.

run(item: ItemT, context: ContractContext, parent: ParentT = None) → bool

Validate the context before running the term.