Skip to main content

About source function

select * from {{ source(source_name, table_name) }}

Definition

This function:

  • Returns a Relation for a source
  • Creates dependencies between a source and the current model, which is useful for documentation and model selection
  • Compiles to the full object name in the database

Arguments

  • source_name: The name: defined under a sources: key
  • table_name: The name: defined under a tables: key

Example

Consider a source defined as follows:

models/<filename>.yml
version: 2

sources:
- name: jaffle_shop # this is the source_name
database: raw

tables:
- name: customers # this is the table_name
- name: orders

Select from the source in a model:

models/orders.sql
select
...

from {{ source('jaffle_shop', 'customers') }}

left join {{ source('jaffle_shop', 'orders') }} using (customer_id)

0