Skip to main content

meta

dbt_project.yml
models:
<resource-path>:
+meta: {<dictionary>}

models/schema.yml

models:
- name: model_name
config:
meta: {<dictionary>}

columns:
- name: column_name
config:
meta: {<dictionary>} # changed to config in v1.10 and backported to 1.9

The meta config can be defined:

  • Under the models config in the project file (shown in previous 'models/schema.yml' example)
  • Under the models config in the project file (dbt_project.yml)
  • in a config() Jinja macro within a model's SQL file

See configs and properties for details.

Definition

The meta field can be used to set metadata for a resource and accepts any key-value pairs. This metadata is compiled into the manifest.json file generated by dbt, and is viewable in the auto-generated documentation.

Depending on the resource you're configuring, meta may be available within the config property, and/or as a top-level key. (For backwards compatibility, meta is often (but not always) supported as a top-level key, though without the capabilities of config inheritance.)

Examples

To demonstrate how to use the meta config, here are some examples:

Designate a model owner

Additionally, indicate the maturity of a model using a model_maturity: key.

models/schema.yml

models:
- name: users
config:
meta:
owner: "@alice"
model_maturity: in dev

Designate a source column as containing PII

models/schema.yml

sources:
- name: salesforce
tables:
- name: account
config:
meta:
contains_pii: true
columns:
- name: email
config:
meta: # changed to config in v1.10 and backported to 1.9
contains_pii: true

Configure one meta attribute for all seeds

dbt_project.yml
seeds:
+meta:
favorite_color: red

Override one meta attribute for a single model

models/my_model.sql
{{ config(meta = {
'single_key': 'override'
}) }}

select 1 as id

Assign owner and favorite_color in the dbt_project.yml as a config property

dbt_project.yml
models:
jaffle_shop:
+meta:
owner: "@alice"
favorite_color: red

Assign meta to semantic model

Assign meta to dimensions, measures, entities

Access meta values in Python models

To access custom meta values in Python models, first retrieve the meta object using the dbt.config.get() method, then access your custom values from it.

For example, if you have a model named my_python_model and you want to store custom values, you can do the following:

models/schema.yml
models:
- name: my_python_model
config:
meta:
batch_size: 1000
processing_mode: "incremental"
models/my_python_model.py
def model(dbt, session):
# First, get the meta object
meta = dbt.config.get("meta")

# Then access your custom values from meta
batch_size = meta.get("batch_size")
processing_mode = meta.get("processing_mode")

# Use the meta values in your model logic
df = dbt.ref("upstream_model")

if processing_mode == "incremental":
df = df.limit(batch_size)

return df

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

0