Hi,
I’m working my way through the dbt fundamentals course and I’m having a little difficulty with sources ymls.
I’m using Databricks Unity Catalog.
Within the sources yml there is a Name property and also a schema property.
When do you know which one you should reference in a source{{}} call?
There doesn’t appear to be a clear rhyme or reason within the tutorial quiz. Sometimes they use name, sometimes they use schema, even though they always declare both properties but obviously I’m just misunderstanding something.
Hey @mikej345, in the {{source()}} macro you always use the name. From the docs:
By default, schema will be the same as name . Add schema only if you want to use a source name that differs from the existing schema.
I believe in their examples, the name/schema are always the same. However, you could change the name to something different like:
version: 2
sources:
- name: my_sources_name -- Changed from jaffle_shop
database: raw
schema: jaffle_shop
tables:
- name: orders
- name: customers
- name: stripe
tables:
- name: payments
And in your models, use:
{{source('my_sources_name','orders')}}
Which would compile to:
raw.jaffle_shop.orders