meta
- Models
- Sources
- Seeds
- Snapshots
- Tests
- Unit tests
- Analyses
- Macros
- Exposures
- Semantic models
- Metrics
- Saved queries
models:
<resource-path>:
+meta: {<dictionary>}
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
modelsconfig in the project file (shown in previous 'models/schema.yml' example) - Under the
modelsconfig in the project file (dbt_project.yml) - in a
config()Jinja macro within a model's SQL file
See configs and properties for details.
sources:
<resource-path>:
+meta: {<dictionary>}
sources:
- name: model_name
config:
meta: {<dictionary>}
tables:
- name: table_name
config:
meta: {<dictionary>}
columns:
- name: column_name
config:
meta: {<dictionary>} # changed to config in v1.10 and backported to 1.9
seeds:
<resource-path>:
+meta: {<dictionary>}
seeds:
- name: seed_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
seedsconfig in the property file (shown in in previous 'seeds/schema.yml' example) - Under the
seedsconfig in the project file (dbt_project.yml). See configs and properties for details.
snapshots:
<resource-path>:
+meta: {<dictionary>}
snapshots:
- name: snapshot_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
snapshotsconfig in the properties file (shown in previoussnapshots/schema.ymlexample) - under the
snapshotsconfig in the project file (dbt_project.yml) - in a
config()Jinja macro within a snapshot's SQL block
See configs and properties for details.
Use the meta field to add metadata to generic or singular tests. meta accepts key-value pairs, is compiled into manifest.json, and appears in auto-generated documentation.
Generic data tests
Add meta under the config block in your properties.yml file:
models:
- name: my_model
columns:
- name: my_column
data_tests:
- unique:
config:
meta:
owner: "docs team"
Or set defaults in dbt_project.yml:
data_tests:
my_project:
+meta:
owner: "docs team"
Singular data tests
Add meta in the SQL test file using config():
{{ config(meta={'owner': 'docs team'}) }}
select * from {{ ref('my_model') }}
where my_column is null
Or document in tests/properties.yml:
data_tests:
- name: my_singular_test
config:
meta:
owner: "analytics_team"
unit_tests:
<resource-path>:
+meta: {<dictionary>}
unit_tests:
- name: <test-name>
config:
meta: {<dictionary>}
The meta config is not currently supported for analyses.
macros:
<resource-path>:
+meta: {<dictionary>}
macros:
- name: macro_name
config:
meta: {<dictionary>} # changed to config in v1.10
arguments:
- name: argument_name
exposures:
<resource-path>:
+meta: {<dictionary>}
exposures:
- name: exposure_name
config:
meta: {<dictionary>} # changed to config in v1.10
The meta config can be defined:
- Under the
semantic-modelsconfig in the properties file (as showin in previousmodels/semantic_models.ymlexample) - Under the
semantic-modelsconfig in the project file (dbt_project.yml). See configs and properties for details.
metrics:
<resource-path>:
+meta: {<dictionary>}
saved-queries:
<resource-path>:
+meta: {<dictionary>}
saved_queries:
- name: saved_query_name
config:
meta: {<dictionary>}
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
- Designate a source column as containing PII
- Configure one meta attribute for all seeds
- Override one meta attribute for a single model
- Assign owner and favorite_color in the dbt_project.yml as a config property
- Assign meta to semantic model
- Assign meta to dimensions, measures, entities
- Add meta to generic and singular data tests
- Access meta values in Python models
Designate a model owner
Additionally, indicate the maturity of a model using a model_maturity: key.
models:
- name: users
config:
meta:
owner: "@alice"
model_maturity: in dev
Designate a source column as containing PII
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
seeds:
+meta:
favorite_color: red
Override one meta attribute for a single model
{{ config(meta = {
'single_key': 'override'
}) }}
select 1 as id
Assign owner and favorite_color in the dbt_project.yml as a config property
models:
jaffle_shop:
+meta:
owner: "@alice"
favorite_color: red
Assign meta to semantic model
Assign meta to dimensions, measures, entities
Add meta to generic and singular data tests
The following examples show how to add meta to generic data tests in a properties.yml file, and to singular data tests using config(). You can also set defaults in dbt_project.yml or tests/properties.yml.
- Generic data test
- Singular data test
models:
- name: orders
columns:
- name: order_id
data_tests:
- not_null:
config:
meta:
owner: "@data_team"
{{ config(meta={'owner': '@data_team'}) }}
select *
from {{ ref('orders') }}
where order_id is null
Access meta values in Python models
To access custom meta values in Python models, use the dbt.config.meta_get() method.
For example, if you have a model named my_python_model and you want to store custom values, you can do the following:
models:
- name: my_python_model
config:
meta:
batch_size: 1000
processing_mode: "incremental"
def model(dbt, session):
# Access custom values stored in meta directly
batch_size = dbt.config.meta_get("batch_size")
processing_mode = dbt.config.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.