How to run dbt models in a particular sequence?

I have two models: “transform” and “product”.

When executing dbt run --profiles-dir . my product model is running first and transform is running later.

How do I ensure that transform is executed first and then product

Hello @chronos2.03

Can you please provide the model templates.

Regards
Minhaj

If your models depend on one another, you should use the ref macro to define these dependencies. That way dbt knows to run transform before product.

1 Like

You can force dependencies between models, but why do you want transform to be executed first? Is it really necessary?

It will be more convenient if a group of models depend on one another group.
The group can be ‘stage’, ‘directory’ and etc…

Usually, when you want to run groups of models in sequence, a good practice is to use a tag to identify the models of each group and run a sequence of commands selecting by tag. (You can use the path method as well if they are grouped by path, but I still prefer tags)

dbt run --select tag:group_1
dbt run --select tag:group_2