docs-mintlify/docs/integrations/dbt.mdx
The dbt integration is currently in preview. Reach out to your account manager or contact us to have it enabled for your Cube account.
</Note>If your team already models data in dbt, you can import those models into Cube as cubes instead of redefining them by hand. dbt Pull connects to your dbt project's Git repository, parses the project, converts each dbt model into a cube, and commits the generated files to a development branch — where you review them before they reach production.
When you run a pull, Cube:
.yml file per model).No connection to your data warehouse is made during a pull. Cube only reads your dbt project code and writes cube files — it never queries or modifies your warehouse.
dbt run) in the schema you configure
below. dbt Pull generates cube definitions that point at schema.<model>; it does
not create the underlying tables.The dbt connection is configured on your deployment's default data source.
<Steps> <Step title="Open the data source settings">Go to Settings → Data Sources and edit the default data source. Expand the dbt project (optional) section.
</Step> <Step title="Fill in the connection fields">| Field | Description |
|---|---|
| Repository URL | The HTTPS clone URL of the repo that contains your dbt project, e.g. https://github.com/your-org/your-repo.git. |
| Access token (PAT) | A personal access token with read access to the repository. Leave it unchanged to reuse the existing token. |
| Project path | The path to the dbt project inside the repository (the folder containing dbt_project.yml). Use . if the project is at the repository root. |
| dbt target schema | The schema your production dbt run builds models into (the schema of your production target in profiles.yml). Generated cubes will reference the tables in this schema. |
Click Test connection. Cube checks that the repository is reachable with your URL and token and reports the result:
Click Save dbt settings.
</Step> </Steps>The access token is stored encrypted and is never returned to the browser. Saving these settings does not restart your deployment.
Open the deployment's data model page (the IDE) and enter development mode. The dbt integration is disabled outside dev mode — the pull lands on your dev branch, never directly on production.
</Step> <Step title="Open the pull dialog">Open the Integrations menu → dbt → Pull.
</Step> <Step title="Set the output options">In the Pull from dbt Models dialog, configure how the cubes are generated:
| Option | Default | Description |
|---|---|---|
| Path | /model/cubes/dbt | Directory in the repository where the generated cube files are written. |
| Name prefix | dbt_ | Prefix added to each generated cube's name. |
| Title prefix | (dbt) | Prefix added to each generated cube's display title. |
| Model selector | (empty) | Optional dbt selector using dbt ls --select syntax to limit which models are pulled, e.g. tag:cube or marts.*. Leave empty to pull all models. |
| Auto-detect primary keys | On | Marks id / *_id columns (and columns with a dbt primary_key constraint) as the cube's primary key. |
| Only pull marts | Off | When enabled, only pulls models whose path starts with the Marts folder value (e.g. marts). |
If the output path already contains files, the dialog shows a warning with the file count: a pull overwrites generated cube files and deletes files in that folder that no longer correspond to a dbt model. See Re-running a pull.
</Warning> </Step> <Step title="Start the pull">Click Start Pull. A progress toast tracks the pull and ends with "dbt pull completed (N cubes)". The generated files appear in your file tree under the output path, on your development branch.
</Step> </Steps>Review the generated cubes, then commit and merge the branch through your normal workflow.
dbt Pull converts models and their columns. dbt metrics, semantic models, and tests are not imported.
For each dbt model in your project:
One cube is created (one .yml file per model), named
<name prefix><model name> with title <title prefix><model alias or name>.
sql_table is set to the model's fully-qualified relation,
database.schema.model (empty parts are dropped, so e.g. Postgres yields
schema.model).
Each column becomes a dimension. The dimension type is inferred from the
column's data_type where available, otherwise from the column name:
dbt data_type | Cube dimension type |
|---|---|
varchar, text, string, char | string |
integer, int, bigint, smallint, decimal, numeric, float, double, real | number |
date, datetime, timestamp, timestamptz, time | time |
boolean, bool | boolean |
Column descriptions from your dbt project are carried over to the dimensions.
A count measure is added to every cube.
total_<column> sum measures are added for numeric columns whose names suggest
an additive metric (names containing amount, price, cost, total, or value).
Models named metricflow_time_spine and any non-model resources (sources, seeds,
snapshots, etc.) are skipped.
Each generated file begins with a header noting that it's auto-generated and
recommending you don't edit it by hand — use Cube's
extends functionality to layer
customizations on top instead, so they survive the next pull.
Pulling again refreshes the cubes to match your current dbt project:
Because generated files are overwritten, manual edits to them are lost on the next
pull. Keep customizations in a separate cube that extends the generated one.
The dbt feature isn't enabled for your account. Contact Cube to enable it.
</Accordion> <Accordion title="The dbt menu item is greyed out">You're not in development mode. Enter dev mode on the data model page — dbt Pull only runs against a dev branch.
</Accordion> <Accordion title="The pull dialog says the database type is unsupported">Your deployment uses a database other than Snowflake, Redshift, or Postgres. dbt Pull isn't available for it.
</Accordion> <Accordion title="The pull dialog says dbt isn't configured">The dbt connection settings are missing or incomplete on the default data source. An account administrator can add them under Settings → Data Sources (see Connect your dbt repository). If you're not an administrator, ask someone who manages the deployment to set it up.
</Accordion> <Accordion title="Test connection fails">The message identifies the cause:
git@…) URL.The error message describes what failed. Common causes:
dbt_project.yml there).Transient failures are retried automatically; persistent errors fail with a message describing the problem.
</Accordion> <Accordion title='The pull reports "no dbt models matched"'>Your Model selector and/or Only pull marts filters excluded every model. The
pull fails (rather than generating nothing and deleting files) and names the active
filters. Adjust the selector/marts folder and try again. Confirm the selector with
dbt ls --select <your selector> locally.
dbt Pull generates cube definitions that point at schema.<model>, but it doesn't
build the tables. Make sure your production dbt run has materialized the models
into the dbt target schema you configured, and that the schema matches.
The sql_table is derived from your dbt project and the dbt target schema
setting. Verify that dbt target schema matches where your models actually land,
and that any per-model schema/database overrides in dbt are what you expect.