Not too sure what a .yml file or a Table is? Be sure to check out our tutorial on Adding Tables to Lightdash for more details.
Auto-generate schema.yml
files
To make it faster to write and maintain your schema.yml
files, the Lightdash CLI will automatically generate and sync your schema.yml
files.
Inside your dbt project, open a terminal and run this command to generate the schema.yml
file for a model calledmymodel
:
schema.yml
file to add any new columns that have appeared in the database.
Auto-sync schema.yml
files after dbt run
Since the generate
command relies on your database schema to detect which columns are required, you’ll often want to run dbt run
before running generate
. You can combine dbt run
and lighdash generate
into one command which will run models and then regenerate theschema.yml
files for any models than changed:
Generating schema.yml
for multiple models
lightdash generate
supports dbt model selection syntax to generate files for a group of models:
Using doc blocks to build better .yml files
Doc blocks are markdown files defined in your dbt project that are useful for creating consistent documentation in your dbt project. For example, if I have a field calledproduct_category
that’s used a bunch of times throughout my project, I can create a doc block for this field:
product_category
(in Lightdash and in your dbt documentation) will become the doc block I’ve written above.
The Lightdash CLI will automatically add doc blocks to your .yml files
The nice thing about doc blocks is that Lightdash automatically adds these to the .yml files it generates. For example, if I had a .yml file for myproduct_sales
model that looked like this:
product_sales.yml
file would be updated to include the doc block for product_category
: