If you ever got a chance to play around with dbt, you'll know that after all the fun, there's always a time when you have to sort out all of your documentation YAMLs. This can get boring very quickly, especially if you have to list out all the columns within all of your models.
Thankfully, dbt has kindly created a package dbt-codegen which basically sorts out the YAMLs (and more!) within seconds!
dbt-codegen, built by dbt Labs that helps automate the generation of:
- Documentation YAMLs for your models, sources, and seeds
- Model files with SELECT* scaffolding
- Source definitions based on actual database schemas
...all that with just a single command!
So what are the options?
- generate_model_yaml - When compiled, it auto-generates a document with column names pulled directly from your data warehouse, so you can fill in descriptions without copying metadata manually.
- generate_model: Creates the basic SQL model file for you — no more starting from a blank file (just make sure you ran it first!).
- generate_source: A great tool to sort out your sources. This one scaffolds out source: blocks with tables and columns from your database, including freshness config.
So how do I get started?
1. Install the package by adding this to your packages.yml:
package: dbt-labs/codegen
version: [">=0.12.1"]
2. Run dbt deps to install.
3. Use any of the commands and compile them in the any sheet!
To earn more, check out the codegen documentation on dbts website: dbt-codegen on dbt Hub