> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Ingest Lineage from dbt | Official Documentation

> Ingest dbt lineage to build upstream and downstream traceability for models, columns, and data products.

# Ingest Lineage from dbt

Ingest the lineage information from dbt `manifest.json` file into Collate.

Collate extracts the lineage information from the `depends_on` and `compiled_query/compiled_code` keys from the manifest file.

> [!NOTE]
>
> To capture lineage, the `compiled_code` field must be present in the `manifest.json` file.
>
> * If `compiled_code` is missing, lineage will **not** be captured for that node.
> * To ensure `compiled_code` is populated in your dbt manifest, run the following commands in your dbt project:
>   * `dbt compile`
>   * `dbt docs generate`

### 1. Lineage information from dbt "depends\_on" key

Collate fetches the lineage information from the `manifest.json` file. Below is a sample `manifest.json` file node containing lineage information under `node_name->depends_on->nodes`.

```json theme={null}
"model.jaffle_shop.customers": {
  "compiled": true,
  "resource_type": "model",
  "depends_on": {
      "macros": [],
      "nodes": [
          "model.jaffle_shop.stg_customers",
          "model.jaffle_shop.stg_orders",
          "model.jaffle_shop.stg_payments"
      ]
  }
}
```

For the above case the lineage will be created as shown in below:

![dbt-lineage-customers](https://mintcdn.com/collatedocs/X_lfH8k8w6u5uqTN/public/images/features/ingestion/workflows/dbt/dbt-lineage-customers.webp?fit=max\&auto=format\&n=X_lfH8k8w6u5uqTN\&q=85\&s=f12ac445f5a8fca2d4bc1eb7b12febc5)

### 2. Lineage information from dbt queries

Collate fetches the dbt query information from the `manifest.json` file.

Below is a sample `manifest.json` file node containing dbt query information under `node_name->compiled_code` or `node_name->compiled_sql`.

```json theme={null}
"model.jaffle_shop.customers": {
  "compiled": true,
  "resource_type": "model",
  "compiled_code": "Query for the model"
}
```

The query from dbt will be parsed by the Lineage parser to extract source and target tables to create the lineage.

The lineage may not be created if the lineage parser is not able to parse the query. Please check the logs for any errors in this case.

## Map dbt Catalog Names to Collate Databases

Collate matches each model in `manifest.json` to a table using the database name that dbt writes into the manifest. That name can differ from the name the connector ingested the table under. For example, `dbt-trino` writes the Trino catalog name (`bq_catalog`) for tables that the BigQuery connector ingests under the GCP project ID (`my-gcp-project`). Without a match, Collate can't link the dbt model to the table.

Use **Catalog Mapping** in the dbt ingestion configuration to resolve this. Add one entry per catalog:

* **Key**: the database name in the dbt manifest, for example `bq_catalog`. Keys are matched ignoring case.
* **Value**: the database name in Collate, for example `my-gcp-project`.

In a YAML configuration, set `catalogMapping` under `sourceConfig.config`:

```yaml theme={null}
sourceConfig:
  config:
    type: DBT
    catalogMapping:
      bq_catalog: my-gcp-project
```

Collate looks up the tables of a mapped catalog under the mapped database in every database service, whether or not **Search Tables Across Databases Services** is enabled. If it finds no table there, it falls back to the database name in the manifest.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.