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 node selection
- Compiles to the full object name in the database
Related guides
Arguments
source_name
: Thename:
defined under asources:
keytable_name
: Thename:
defined under atables:
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