Naming#
Note
The below checks require manifest.json to be present.
Checks related to model naming conventions.
Functions:
| Name | Description |
|---|---|
check_model_alias |
Models must have an explicit alias and/or an alias that matches the supplied regex. |
check_model_names |
Models must have a name that matches the supplied regex. |
check_model_alias
#
Models must have an explicit alias and/or an alias that matches the supplied regex.
Rationale
check_model_names governs the file name; the alias governs the table name consumers see in the warehouse. Marts often carry layer suffixes in the file name (e.g. fct_volume_fraction_ldm) and expose a clean alias (FCT_VOLUME_FRACTION); enforcing this in CI keeps warehouse naming consistent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alias_pattern
|
str | None
|
Regexp the model alias must match. If not supplied, the alias is not checked against a pattern. |
None
|
require_explicit_alias
|
bool
|
If |
False
|
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 | list[str] | None
|
Regex pattern(s) to match the model path. Model paths that match any pattern will not be checked. |
include |
str | list[str] | None
|
Regex pattern(s) to match the model path. Only model paths that match any 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_alias
include: ^models/marts
require_explicit_alias: true
alias_pattern: ^(FCT|DIM)_[A-Z_]+$
Source code in src/dbt_bouncer/checks/manifest/models/naming.py
check_model_names
#
Models must have a name that matches the supplied regex.
Rationale
Naming conventions such as stg_ for staging models and int_ for intermediate models are a cornerstone of readable dbt projects. Enforcing these patterns in CI prevents inconsistently named models from being merged, keeping the project navigable as it grows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name_pattern
|
str
|
Regexp the model name 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 | list[str] | None
|
Regex pattern(s) to match the model path. Model paths that match any pattern will not be checked. |
include |
str | list[str] | None
|
Regex pattern(s) to match the model path. Only model paths that match any 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_names
include: ^models/intermediate
model_name_pattern: ^int_
- name: check_model_names
include: ^models/staging
model_name_pattern: ^stg_