naming_conventions
For column naming conventions, see the columns_name_convention rule.
Rule: name_convention
name_convention details
This rule ensures that a dbt object's name applies to naming conventions given in the arguments.
Configuration
- type: Must be
name_convention. - applies_to: (optional) List of dbt object types to include.
- Default:
["models", "seeds", "snapshots", "analyses", "sources", "unit_tests", "macros", "exposures", "semantic_models"] - Options:
models,seeds,snapshots,analyses,sources,unit_tests,macros,exposures,semantic_models
- Default:
- pattern: The naming convention pattern to enforce. Can be one of the following presets or a custom regex pattern.
- Presets:
snake_case: lowercase letters, numbers, and underscores (e.g.,my_model_name)kebab-case: lowercase letters, numbers, and hyphens (e.g.,my-model-name)camelCase: starts with a lowercase letter, followed by uppercase letters for new words (e.g.,myModelName)PascalCase: starts with an uppercase letter, followed by uppercase letters for new words (e.g.,MyModelName)
- Custom Regex: Any valid regex pattern to match against the dbt object names.
- Presets:
Common Rule Config
- name: Human-readable name of the rule.
- severity:
"error"(fail) or"warning"(warn only).- (optional, defaults to
"error"if not specified)
- (optional, defaults to
- description: Human-readable explanation of the rule.
- includes: List of patterns to explicitly include for this rule.
Paths are relative to theoriginal_file_pathfrom the manifest.
Pattern syntax:*matches any characters except/(within a single directory)**matches any characters including/(across directories)^at the start anchors to the beginning of the path$at the end anchors to the end of the path- Without anchors, pattern matches if it appears anywhere in the path (contains)
Examples:^models/staging/- paths starting withmodels/staging/orders- paths containingordersanywhere.sql$- paths ending with.sql^models/*.sql$- SQL files directly inmodels/folder^models/**/*.sql$- SQL files in any subfolder ofmodels/
- excludes: List of patterns to explicitly exclude from this rule.
Uses the same pattern syntax asincludes.
Examples:^models/legacy/- exclude legacy models folder_deprecated- exclude paths containing_deprecated^tests/- exclude test files - model_materializations: Filter models by materialization type. Only applies when
applies_toincludesmodels.
(optional, if not specified all materializations are included)
Built-in types:table,view,incremental,ephemeral,materialized_view. Custom materializations are also supported.
Example:["table", "incremental"]
Example Config
manifest_tests:
- name: "all_objects_snake_case"
type: "name_convention"
description: "All dbt objects must be snake_case."
pattern: "snake_case"
# severity: "warning" (optional)
# applies_to: ['models', 'seeds'] (optional)
# includes: ["path/to/include/*"] (optional)
# excludes: ["path/to/exclude/*"] (optional)[[manifest_tests]]
name = "all_objects_snake_case"
type = "name_convention"
description = "All dbt objects must be snake_case."
pattern = "snake_case"
# severity = "warning" # (optional)
# applies_to = ["models", "seeds"] # (optional)
# includes = ["path/to/include/*"] # (optional)
# excludes = ["path/to/exclude/*"] # (optional)[[tool.dbtective.manifest_tests]]
name = "all_objects_snake_case"
type = "name_convention"
description = "All dbt objects must be snake_case."
pattern = "snake_case"
# severity = "warning" # (optional)
# applies_to = ["models", "seeds"] # (optional)
# includes = ["path/to/include/*"] # (optional)
# excludes = ["path/to/exclude/*"] # (optional)Relevant dbt code
models:
- name: model_with_description
description: This is a model with a description
- name: model_without_description