dbt's node selection syntax makes it possible to run only specific resources in a given invocation of dbt. This selection syntax is used for the following subcommands:
Nodes and resources
We use the terms "nodes" and "resources" interchangeably. These encompass all the models, tests, sources, seeds, snapshots, exposures, and analyses in your project. They are the objects that make up dbt's DAG (directed acyclic graph).
dbt run executes all of the models in the dependency graph;
dbt seed creates all seeds,
dbt snapshot performs every snapshot. The
--select flag is used to specify a subset of nodes to execute.
Before dbt v0.21, certain commands (notably
compile) used a flag called
--models instead of
--select. The two were functionally identical. Those commands still support the
--models flag for backwards compatibility.
How does selection work?
dbt gathers all the resources that are matched by one or more of the
--selectcriteria, in the order of selection methods (e.g.
tag:), then graph operators (e.g.
+), then finally set operators (unions, intersections, exclusions).
The selected resources may be models, sources, seeds, snapshots, tests. (Tests can also be selected "indirectly" via their parents; see test selection examples for details.)
dbt now has a list of still-selected resources of varying types. As a final step, it tosses away any resource that does not match the resource type of the current task. (Only seeds are kept for
dbt seed, only models for
dbt run, only tests for
dbt test, and so on.)
Select resources to build (run, test, seed, snapshot) or check freshness:
dbt run will execute all of the models in the dependency graph. During development (and deployment), it is useful to specify only a subset of models to run. Use the
--select flag with
dbt run to select a subset of models to run. Note that the following arguments (
--selector) also apply to other dbt tasks, such as
--select flag accepts one or more arguments. Each argument can be one of:
- a package name
- a model name
- a fully-qualified path to a directory of models
- a selection method (
dbt supports a shorthand language for defining subsets of nodes. This language uses the characters
As your selection logic gets more complex, and becomes unwieldly to type out as command-line arguments,
consider using a yaml selector. You can use a predefined definition with the
Note that when you're using
--selector, most other flags (namely
--exclude) will be ignored.