dbt Fundamentals#
Main files#
filename |
description |
---|---|
|
The main file for project configuration. The project name is defined here, and folder paths for specific functions and models from the transform folder are defined here as well. Additionally, hookups that can e.g. grant permissions on schemas are set up here. |
|
Connection to the database is set up here including schema. |
|
YAML definition file for models. This can have the same name as subfolder inside transform folder. Used for documenting each table and most importantly setting up tests on these tables. |
|
YAML definition of source tables. Raw database/schema is defined here. |
Main dbt commands#
command |
description |
---|---|
|
Initiate compilation and run of model DAGs |
|
Initiate testing on current models. Needs to run on existing tables/views so need to be run after at least one |
|
Runs compilations only. Good for testing before changing anything. Compiled SQL can be run against DB. |
|
Generates documentation from |
|
Starts webserver to provide documentation on localhost. |
|
Takes .csv files from folder |
|
A new command to do |
Main jinja functions#
Note
jinja is web template engine for Python that uses curly brackets to define it’s variables.
{%- for item in item_list %}
<li>{{ item }}</li>
{%- endfor %}
<li>1</li>
<li>2</li>
<li>3</li>
function |
description |
---|---|
|
A jinja function to reference previous models. It doesn’t need path inside, filename is enough. |
|
A jinja function to reference source tables defined in |
Model settings#
setting |
value |
description |
---|---|---|
materialization |
|
Default materialization that only |
materialization |
|
This uses sql |
materialization |
|
This creates the model in a temporary table in the session. These are used as middle-step models to fill dependent tables that do not necessarily need to be materialized for other use cases. |
materialization |
|
Most difficult to set up but can help optimizing compute. This creates temporary table on the incremental part of source. Defined via jinja statement |
schema |
|
Schema for development. This is set via |
schema |
|
Schema for production, usually behind BI tool. |