Macros

Full Example
contracts:
  macros:
  - filter:
    - path:
        include: .*i\s+am\s+a\s+regex\s+pattern.*
        exclude:
        - ^\w+\d+\s{1,3}$
        - exclude[_-]this
        match_all: true
    validations:
    - has_properties

Filters

Filters (or Conditions) for reducing the scope of the contract. You may limit the number of macros processed by the rules of this contract by defining one or more of the following filters.

name

Filter macros based on their names.

Schema
name:
  include:
    default: []
    description: Patterns to match against for values to include
    items:
      type: string
    type: array
  exclude:
    default: []
    description: Patterns to match against for values to exclude
    items:
      type: string
    type: array
  match_all:
    default: false
    description: When True, all given patterns must match to be considered a match
      for either pattern type
    type: boolean
Example
name:
  include:
  - ^\w+\d+\s{1,3}$
  - include[_-]this
  exclude:
  - ^\w+\d+\s{1,3}$
  - exclude[_-]this
  match_all: true

You may also define the parameters for include directly on the definition like below.

name:
- ^\w+\d+\s{1,3}$
- include[_-]this

path

Filter macros based on their paths. Paths must match patterns which are relative to the root directory of the dbt project.

Schema
path:
  include:
    default: []
    description: Patterns to match against for values to include
    items:
      type: string
    type: array
  exclude:
    default: []
    description: Patterns to match against for values to exclude
    items:
      type: string
    type: array
  match_all:
    default: false
    description: When True, all given patterns must match to be considered a match
      for either pattern type
    type: boolean
Example
path:
  include:
  - ^\w+\d+\s{1,3}$
  - include[_-]this
  exclude: .*i\s+am\s+a\s+regex\s+pattern.*
  match_all: true

You may define the paths as a list of lists where each part is a subdirectory within the path. These parts will then be unified by joining them with the os-specific path separator. This allows for you define os-independent configuration as needed.

include:
- ["path", "to", "folder1"]
- ["path", "to", "folder2"]
- ["path", "to", "folder3"]
exclude:
- ["path", "to", "another", "folder1"]
- ["path", "to", "another", "folder2"]
- ["path", "to", "another", "folder3"]

You may also define the parameters for include directly on the definition like below.

path: .*i\s+am\s+a\s+regex\s+pattern.*

Validations

Validations (or Terms) to apply to the resources of this contract. These enforce certain standards that must be followed in order for the contract to be fulfilled.

has_properties

Check whether the macros have properties files defined.

Note

This term does not need further configuration. Simply define the term’s name as an item in your configuration.

has_description

Check whether the macros have descriptions defined in their properties.

Note

This term does not need further configuration. Simply define the term’s name as an item in your configuration.

Arguments

You may also define arguments contracts as a child set of contracts on macros. Refer to the arguments reference for more info.