I am new to DBT and I understand how to create a src.yml
where my data source in snowflake(database/schema/table) is located to be referenced by my models. But I am not sure how to do that when the data source is a model. The code below successfully references my source(data model) and it runs. but the objective is to create a src.yml
, include details of my source (data model) and other models that can reference it.
my model referencing its source: 'mark', 'A_mark_Properties'
with cats(
select "iD",
"Val",
"Set",
ROW_NUMBER()OVER ( PARTITION BY "iD" order by "Set" desc ) as num
from {{ ref('mark', 'A_mark_Properties') }} --refernece the model
)
The objective is to create a src.yml
and add details of my source data model. When creating s source file for referencing a table, it's usually this way, but I am not sure how to create something similar when it comes to data models as the source.
version: 2
sources:
- name: jaffle_shop
tables:
- name: orders
- name: customers
- name: stripe
tables:
- name: payments
You don't need to add a_mark_properties
as a source. If it is a model within the same dbt project, then all you need to do is write {{ ref('a_mark_properties') }}
from within a new model.
The way you have your ref()
written, it appears you are trying to pull a model from a package that you added to your current project (see advanced ref usage).
However, my guess is you think you have to add mark.a_mark_properties
to your src.yml
file, when you don't. I'm surprised your model ran unless you did, in fact, add a package (another dbt project) thats called mark and had a model within it called a_mark_properties.
If you actually have a table that ISN'T related to an existing dbt model, then you'd added it to your src.yml file (note: without a database added to source, the default is your target database, which would be analytics
according to the dbt tutorial)...
--src.yml
version: 2
sources:
- name: mark
tables:
- name: a_mark_properties
And you would reference it as such...
select *
from {{ source('mark','a_mark_properties') }}
Hard to answer your question when I'm not positive how you got your current work to run properly.