has_metadata_keys

Rule: has_metadata_keys


has_metadata_keys details
This rule ensures that dbt objects have specific required keys in their meta property. This is useful for enforcing governance standards such as requiring an owner, domain, or other organizational metadata.

Configuration

  • type: Must be has_metadata_keys.
  • applies_to: (optional) List of dbt object types to include.
    • Default: ["models", "sources"]
    • Options: models, seeds, snapshots, sources, macros, exposures, semantic_models
  • required_keys: List of metadata keys that must be present in the meta property of each dbt object.
  • custom_message (Optional): Custom message to display when the rule fails. It will insert the {Object name} before the message.
    • The custom message is missing an owner would produce a message like {Object name} is missing an owner
Common Rule Config
  • name: Human-readable name of the rule.
  • severity: "error" (fail) or "warning" (warn only).
    • (optional, defaults to "error" if not specified)
  • description: Human-readable explanation of the rule.
  • category: Override the default rule category. Included in structured output (JSON, CSV, NDJSON) but not in the CLI table. Each rule has a built-in default (e.g. documentation, naming, testing, governance, structure, performance).
    • (optional, defaults to the rule type's built-in category)
  • includes: List of patterns to explicitly include for this rule. See Includes & Excludes for pattern syntax and examples.
  • excludes: List of patterns to explicitly exclude from this rule. See Includes & Excludes for pattern syntax and examples.
  • model_materializations: Filter models by materialization type. Only applies when applies_to includes models.
    • (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: "models_have_owner"
    type: "has_metadata_keys"
    description: "All models and sources must have an owner defined in meta."
    required_keys: ["owner"]
    # severity: "warning"  (optional)
    # applies_to: ['models', 'seeds']  (optional)
    # includes: ["path/to/include/*"]  (optional)
    # excludes: ["path/to/exclude/*"]  (optional)
[[manifest_tests]]
name = "models_have_owner"
type = "has_metadata_keys"
description = "All models and sources must have an owner defined in meta."
required_keys = ["owner"]
# severity = "warning"  # (optional)
# applies_to = ["models", "seeds"]  # (optional)
# includes = ["path/to/include/*"]  # (optional)
# excludes = ["path/to/exclude/*"]  # (optional)
[[tool.dbtective.manifest_tests]]
name = "models_have_owner"
type = "has_metadata_keys"
description = "All models and sources must have an owner defined in meta."
required_keys = ["owner"]
# 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_owner
    description: This model has an owner defined
    meta:
      owner: "data-team@example.com"
    # or
    config:
      meta:
        owner: "data-team@example.com"

  - name: model_without_owner
    description: This model is missing the owner key