---
title: "dbt"
canonical: "https://docs.vaultspeed.com/space/VPD/3364192387/dbt"
format: markdown
---
VaultSpeed supports [https://www.getdbt.com/](https://www.getdbt.com/) as a target platform for the ELT generation.

When this target is selected, all the DDL code will still be in SQL. Views and ELT mappings will be models in dbt.

> Macro (toc)

## Limitations

- dbt can only be generated for Snowflake and Databricks databases at the moment. More will be added later.
- Only merges are supported. Separate updates and inserts are not possible with dbt.
- When creating templates with VaultSpeed Studio, make sure only one target template exists for each object. Note that it is possible to have different templates for the initial and incremental load.

## Project Configuration

In your dbt project configuration, make sure to enable quoting and add the variables like below:

```
quoting:
  database: true
  schema: true
  identifier: true

# variable values should be added here in order to be able to generate docs
# the values of these do not matter, the complete lineage will be generated independent of these parameter values
vars:
  load_type: dummy
  source: dummy
```

## Structure of the generated code

The code generated by VaultSpeed is structured differently for dbt generation compared to other generations.  
The zip file contains two directories, a ‘macros’ and a ‘models’ folder.

The ‘macros’ directory contains the necessary macros to make the generated models work properly.

The ‘models' directory contains subfolders per layer. Each of these contains all the models for the objects of that layer. The ‘models’ directory also contains some 'sources’ files, one per source and one for the raw data vault.

The generated models are all linked with references, meaning that the dbt documentation will contain the full lineage.

![image](media://79670277-dbb6-457d-98a5-e8ca649f1c9a)

![image](media://f4c95cfb-628b-4e96-a524-efd98b143a06)


## Deployment

**Recommended Method:** Use Git for deployment.

- **Step 1:** Push the generated code to your Git repository (this can also be GitHub). Refer to the [Git Deployment Documentation](https://docs.vaultspeed.com/space/VPD/3013148700/GIT+Deployment) for detailed instructions.
- **Step 2:** Deploy into the same repository that is connected to your dbt environment.
- **Step 3:** Once you have committed the changes from VaultSpeed, you can pull from the remote repository into your dbt environment to complete the deployment process.

## FMC

With dbt, the supported FMC technologies are Airflow and the Generic FMC.

### Airflow

Airflow with dbt requires two connections to be defined in the VaultSpeed FMC flows:

- The ‘Data Vault Connection Name’ is the name of the connection to your target database, in this case, Snowflake.
- The	‘ETL Connection Name’ is the name for your dbt connection.

With the VaultSpeed plugin for Airflow (ensure you have the latest version), you can define two types of dbt connections in Airflow:

- `dbt Cloud` This allows you to connect to a dbt cloud instance and run the models as jobs there. These connections can have the following properties:
  - **Tenant** (optional): Your dbt tenant name. The default is ‘cloud’.
  - **Account** **name**: Your account name.
  - **Project name**: The name of the dbt project.
  - **environment id**: The environment id can be found by navigating to the correct environment in the cloud UI and getting the last number from the URL: [https://cloud.getdbt.com/next/deploy/](https://cloud.getdbt.com/next/deploy/)<account_id>/projects/<project_id>/environments/<environment_id>.
  - **API Token**: An API Token to access the dbt cloud API.
  - **threads**: The maximum number of models to run in parallel in a single dbt run.
  - **polling interval** (optional): How often the job status should be checked in seconds. The default is 10s.
- `dbt CLI` This allows you to run the dbt models locally with the dbt CLI run command. These connections can have the following properties:
  - **Path to dbt project**: the path to the local dbt project (has to be initialized and have a valid connection to Snowflake).
  - **dbt binary**:  The path of the dbt CLI binary, the default is 'dbt' which requires it to be in the PATH.
  - **CLI flags** (optional): Additional flags that will be added to the run commands, such as changing which profile to use.

> ℹ️ When Using dbt with Databricks, the `cluster_id` for Databricks should be added in the extra field of the Databricks connection in Airflow instead of in the `ETL Connection Name` property of the Flow.

### Generic fmc

To execute dbt models with the Generic FMC, you have to use the mapping name from the FMC mapping metadata JSON file as a model selection tag and add a variable “load_type”, which contains the load type (“INIT” or “INCR”) and for FL flows also add a variable “source“ which contains the source name.  
The load type and the source name can be found in the info JSON file as “load_type” and “src_name”, respectively.

```
dbt run --select tag:<mapping_name> --vars "{load_type: <load_type>, source: <src_name>}"
```

Each mapping can consist of multiple models.