How do you run models in a path?

dbt Developer Hub states

The --models flag accepts one or more arguments. Each argument can be one of:
3. a path hierarchy to a models directory

dbt run --models # runs all models in a specific directory
dbt run --models* # select all models in path/to/models

For example, my project has a structure like:

  • models/base/
  • models/blue/
  • models/green/
  • models/red/

And I only want to build the models in the models/red/ folder. How would I do that?

Am I misunderstanding the documentation?

1 Like

Hey @jon-rtr - I totally agree that this syntax is confusing! In this example, you could run the models in models/red/ with:

dbt run --models red.*

The .* is actually superfluous in most cases, but I like to add it to make things explicit.

The --models flag works this way to support selecting:

  1. models by name
  2. directories
  3. packages

Since it supports selecting three different types of things, the syntax is necessarily a little weird. Hope this helps!


2 posts were split to a new topic: Select models from multiple directories

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.