Skip to main content

Define properties

Learn how to define properties for your resources in a properties.yml file

In dbt, you can use properties.yml files to define properties for resources. You can declare properties in .yml files, in the same directory as your resources. You can name these files whatever_you_want.yml and nest them arbitrarily in sub-folders within each directory.

We highly recommend that you define properties in dedicated paths alongside the resources they're describing.

info

schema.yml files

Previous versions of the docs referred to these as schema.yml files — we've moved away from that terminology since the word schema is used to mean other things when talking about databases, and people often thought that you had to name these files schema.yml.

Instead, we now refer to these files as properties.yml files. (Of course, you're still free to name your files schema.yml)

Which properties are not also configs?

In dbt, you can define node configs in properties.yml files, in addition to config() blocks and dbt_project.yml. However, some special properties can only be defined in the .yml file and you cannot configure them using config() blocks or the dbt_project.yml file:

Certain properties are special, because:

  • They have a unique Jinja rendering context
  • They create new project resources
  • They don't make sense as hierarchical configuration
  • They're older properties that haven't yet been redefined as configs

These properties are:

Example

Here's an example that defines both sources and models for a project:

models/jaffle_shop.yml
version: 2

sources:
- name: raw_jaffle_shop
description: A replica of the postgres database used to power the jaffle_shop app.
tables:
- name: customers
columns:
- name: id
description: Primary key of the table
tests:
- unique
- not_null

- name: orders
columns:
- name: id
description: Primary key of the table
tests:
- unique
- not_null

- name: user_id
description: Foreign key to customers

- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']


models:
- name: stg_jaffle_shop__customers
config:
tags: ['pii']
columns:
- name: customer_id
tests:
- unique
- not_null

- name: stg_jaffle_shop__orders
config:
materialized: view
columns:
- name: order_id
tests:
- unique
- not_null
- name: status
tests:
- accepted_values:
values: ['placed', 'shipped', 'completed', 'return_pending', 'returned']
config:
severity: warn


You can find an exhaustive list of each supported property and config, broken down by resource type:

FAQs

Does my `.yml` file containing tests and descriptions need to be named `schema.yml`?
If I can name these files whatever I'd like, what should I name them?
Should I use separate files to declare resource properties, or one large file?
Can I add tests and descriptions in a config block?
Why do model and source yml files always start with `version: 2`?
Can I use a YAML file extension?

Troubleshooting common errors

 Invalid test config given in [model name]
 Invalid syntax in your schema.yml file
0