I have a model in dbt which has different staging tables and ref tables. I want to get a list of all the dependent models that is whatever is shown in lineage as a list. For e.g.
with vw_src1 as(
select * from {{ ref('intr_src1') }}
),
vw_src2 as(
)
select
*
from {{ ref('vw_src1') }} a
left join {{ ref('vw_src2') }} b on a.col = b.col
left join {{ ref('vw_src3') }} c on a.col2 = c.col2 ```
I want the output as
vw_src1
vw_src2
vw_src3
intr_src1 and so on that are used in each of the staging and intermediate models. Is that possible to do in dbt? Please help.
You can use the dbt ls
command:
dbt ls
[--resource-type {model,semantic_model,source,seed,snapshot,metric,test,exposure,analysis,default,all}]
[--select SELECTION_ARG [SELECTION_ARG ...]]
[--models SELECTOR [SELECTOR ...]]
[--exclude SELECTOR [SELECTOR ...]]
[--selector YML_SELECTOR_NAME]
[--output {json,name,path,selector}]
[--output-keys KEY_NAME [KEY_NAME]]
Example:
dbt ls --select +model_name+
This will output any upstream or downstream depencencies. See more details in graph operators.