Versioning#
Note
The below checks require manifest.json to be present.
Checks related to model versioning.
Functions:
| Name | Description |
|---|---|
check_model_latest_version_specified |
Check that the |
check_model_version_allowed |
Check that the version of the model matches the supplied regex pattern. |
check_model_version_pinned_in_ref |
Check that the version of the model is always specified in downstream nodes. |
check_model_latest_version_specified
#
Check that the latest_version attribute of the model is set.
Rationale
The latest_version attribute tells dbt which version of a model downstream consumers should default to when using ref('model_name') without specifying a version. Without it, dbt cannot resolve unversioned references, and consumers may inadvertently pin to an older version. Enforcing this attribute ensures the model versioning contract is fully specified.
Receives at execution time:
| Name | Type | Description |
|---|---|---|
model |
ModelNode
|
The ModelNode object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
Source code in src/dbt_bouncer/checks/manifest/models/versioning.py
check_model_version_allowed
#
Check that the version of the model matches the supplied regex pattern.
Rationale
Teams that use model versioning often enforce a convention for version identifiers — for example, numeric-only versions or semantic version strings. This check validates that version values conform to the team's chosen scheme, preventing arbitrary or malformed version strings from being introduced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version_pattern
|
str
|
Regexp the version must match. |
required |
Receives at execution time:
| Name | Type | Description |
|---|---|---|
model |
ModelNode
|
The ModelNode object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):
manifest_checks:
- name: check_model_version_allowed
include: ^models/marts
version_pattern: >- # Versions must be numeric
[0-9]\d*
- name: check_model_version_allowed
include: ^models/marts
version_pattern: ^(stable|latest)$ # Version can be "stable" or "latest", nothing else is permitted
Source code in src/dbt_bouncer/checks/manifest/models/versioning.py
check_model_version_pinned_in_ref
#
Check that the version of the model is always specified in downstream nodes.
Rationale
When a versioned model is referenced without specifying a version, dbt resolves it to the latest_version, meaning a version bump can silently redirect all downstream consumers. Requiring explicit version pins in ref() calls ensures that version upgrades are a deliberate, reviewed change rather than an implicit one.
Receives at execution time:
| Name | Type | Description |
|---|---|---|
manifest_obj |
ManifestObject
|
The ManifestObject object parsed from |
model |
ModelNode
|
The ModelNode object to check. |
Other Parameters (passed via config file):
| Name | Type | Description |
|---|---|---|
description |
str | None
|
Description of what the check does and why it is implemented. |
exclude |
str | None
|
Regex pattern to match the model path. Model paths that match the pattern will not be checked. |
include |
str | None
|
Regex pattern to match the model path. Only model paths that match the pattern will be checked. |
materialization |
Literal[ephemeral, incremental, table, view] | None
|
Limit check to models with the specified materialization. |
severity |
Literal[error, warn] | None
|
Severity level of the check. Default: |
Example(s):