About model object
model
is the dbt graph object (or node) for the current model. It can be used to:
- Access
config
settings, say, in a post-hook - Access the path to the model
For example:
{% if model.config.materialized == 'view' %}
{{ log(model.name ~ " is a view.", info=True) }}
{% endif %}
To view the contents of model
for a given model:
- CLI
- dbt Cloud IDE
If you're using the CLI, use log() to print the full contents:
{{ log(model, info=True) }}
If you're using the dbt Cloud IDE, compile the following to print the full contents:
{{ model | tojson(indent = 4) }}
Model structure and JSON schema
To view the structure of models
and their definitions:
- Refer to dbt JSON Schema for describing and consuming dbt generated artifacts
- Select the corresponding manifest version under Manifest. For example if you're on dbt v1.8, then you would select Manifest v12
- The
manifest.json
version number is related to (but not equal to) your dbt version, so you must use the correctmanifest.json
version for your dbt version. To find the correctmanifest.json
version, refer to Manifest and select the dbt version on the top navigation (such asv1.5
). This will help you find out which tags are associated with your model.
- The
- Then go to
nodes
--> Select Additional properties -->CompiledModelNode
or view other definitions/objects.
Use the following table to understand how the versioning pattern works and match the Manifest version with the dbt version:
dbt Core version | Manifest version |
---|---|
v1.8 | v12 |
v1.7 | v11 |
v1.6 | v10 |
v1.5 | v9 |
v1.4 | v8 |
v1.3 | v7 |
v1.2 | v6 |
v1.1 | v5 |
v1.0 | v4 |
Related docs
0