Skip to content
BENIBIX Learn

dbt Source

Data⚙️ ProcessingData Transformation

Also known as dbt Sources, dbt source()

A raw table listed in dbt, so models can read it by name.

Think of it like

It is like labels on jars in a kitchen. Each recipe names the jar by its label.

Example

The raw orders table moves to a new schema. Lucy changes one line in the sources file, and all 30 models that read it still work.

Why it matters

Raw table names live in one place. The lineage graph also shows which models depend on which raw data.

Definition

A dbt source names a raw table that dbt did not build, such as one filled by a loading tool. You list sources once in a YAML file. Models then read them with the source() function instead of typing the full table name. This puts the raw tables at the start of dbt's lineage graph. dbt can also check how recently a source got new rows.

Example code

yaml
sources:
  - name: shop
    tables:
      - name: orders
      - name: customers
Listed once. A model then reads it as {{ source('shop', 'orders') }}.
The source is the raw table on the far left. Every model is built from it.

Common mistake

Typing raw table names straight into models. dbt then cannot see where the data came from.

Key takeaways

  1. 1
    Raw, not built. Sources are tables dbt did not make.
  2. 2
    Listed once. Names live in one YAML file.
  3. 3
    Start of lineage. The graph begins at the sources.