Guy McCombe

03/03/2023, 1:03 PM
Hey! Is there a way to add non-argument dependencies to a dbt model config? I have a dagster asset that runs a snapshot for a specific table and a model that transforms the snapshots. I’d like for the freshness policy of the downstream to run the snapshot so I was hoping I could connect them like this. :ty-spinny:
fyi this a snippet from my asset factory that generates the snapshot assets
def _asset(context) -> DbtCliOutput:
    res = context.resources.dbt.cli(f"snapshot --select {table}_snapshot")
    return res


03/03/2023, 10:41 PM
hi @Guy McCombe! interesting question -- all of the dependency information for dbt assets is loaded directly from the dbt project, so anything that is upstream of a dbt model needs to be represented as a source (see: but I think you can trick dagster into understanding that dependency by adding the snapshot as a source to the relevant dbt model. You might have to do this in a comment to avoid confusing dbt, i.e. in `my_model.sql`:
select * from foo
-- {{ source(my, snapshot) }}
but once that's done, dagster should understand that there's a dependency between my_model and my_snapshot

Guy McCombe

03/06/2023, 10:59 AM
That worked perfectly! Thanks, @owen :daggy-love: