0
0
dbtdata~10 mins

Documenting models in YAML in dbt - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Documenting models in YAML
Create YAML file
Define model metadata
Add descriptions and columns
Save and run dbt docs generate
View documentation in browser
This flow shows how to write model documentation in YAML, generate docs, and view them.
Execution Sample
dbt
version: 2
models:
  - name: customers
    description: "Customer details table"
    columns:
      - name: id
        description: "Unique customer ID"
This YAML snippet documents a model named 'customers' with a description and column info.
Execution Table
StepActionYAML Contentdbt CommandResult
1Create YAML fileEmpty file named schema.ymlN/AFile created
2Add model metadataversion: 2 models: - name: customers description: "Customer details table" columns: - name: id description: "Unique customer ID"N/AYAML content added
3Save fileschema.yml savedN/AFile saved
4Run dbt docs generateN/Adbt docs generateDocumentation site generated
5Open docs siteN/Adbt docs serveDocumentation visible in browser
6ExitN/AN/AProcess complete
💡 Documentation generated and served successfully
Variable Tracker
VariableStartAfter Step 2After Step 4Final
schema.yml contentemptymodel and columns definedunchangedunchanged
dbt docs sitenot generatednot generatedgeneratedserved and visible
Key Moments - 3 Insights
Why do we need to add descriptions under 'columns' in the YAML?
Descriptions under 'columns' explain each field in the model, making docs clearer. See execution_table step 2 where columns are defined.
What happens if we forget to run 'dbt docs generate' after editing YAML?
The documentation site won't update with new info. Step 4 in execution_table shows this command is needed to generate docs.
Can we document multiple models in one YAML file?
Yes, you list multiple models under 'models:' in the YAML. This is implied in step 2 where model metadata is added.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the YAML content after step 2?
ADocumentation site generated
BEmpty file
CModel name and description with columns
DFile saved but empty
💡 Hint
Check the 'YAML Content' column in execution_table row for step 2
At which step does the documentation site become visible in the browser?
AStep 5
BStep 3
CStep 4
DStep 6
💡 Hint
Look at the 'Result' column in execution_table for step 5
If you add a new column description but skip 'dbt docs generate', what happens?
ANew description appears immediately
BDocumentation site does not show new description
CDocumentation site updates automatically
DYAML file is deleted
💡 Hint
Refer to key_moments about the importance of running 'dbt docs generate'
Concept Snapshot
Document models in YAML with:
version: 2
models:
  - name: model_name
    description: "Model description"
    columns:
      - name: column_name
        description: "Column description"
Run 'dbt docs generate' to build docs, then 'dbt docs serve' to view.
Full Transcript
This visual execution shows how to document dbt models using YAML files. First, create a YAML file named schema.yml. Then add model metadata including the model name, description, and columns with their descriptions. Save the file. Next, run the command 'dbt docs generate' to build the documentation site. Finally, run 'dbt docs serve' to open the docs in a browser. The variable tracker shows the YAML content changes and when the docs site is generated. Key moments clarify why column descriptions matter and why running 'dbt docs generate' is necessary. The quiz tests understanding of YAML content at each step and the documentation generation process.