Selector methods return all resources that share a common property, using the
The "tag" method
tag: method is used to select models that match a specified tag.
The "source" method
source method is used to select models that select from a specified source. Use in conjunction with the
The "path" method
path method is used to select models located at or under a specific path.
path prefix is not explicitly required, it may be used to make
The "package" method
package method is used to select models defined within the root project
or an installed dbt package. While the
package: prefix is not explicitly required, it may be used to make
The "config" method
config method is used to select models that match a specified node config.
The "test_type" method
test_type method is used to select tests based on their type,
The "test_name" method
test_name method is used to select tests based on the name of the generic test
that defines it. For more information about how generic tests are defined, read about
The "state" method
N.B. State-based selection is a powerful, complex feature. Read about known caveats and limitations to state comparison.
state method is used to select nodes by comparing them against a previous version of the same project, which is represented by a manifest. The file path of the comparison manifest must be specified via the
--state flag or
DBT_ARTIFACT_STATE_PATH environment variable.
state:new: There is no node with the same
unique_id in the comparison manifest
state:modified: All new nodes, plus any changes to existing nodes.
Because state comparison is complex, and everyone's project is different, dbt supports subselectors that include a subset of the full
state:modified.body: Changes to node body (e.g. model SQL, seed values)
state:modified.configs: Changes to any node configs, excluding
state:modified.relation: Changes to
alias(the database representation of this node), irrespective of
state:modified.persisted_descriptions: Changes to relation- or column-level
description, if and only if
persist_docsis enabled at each level
state:modified.macros: Changes to upstream macros (whether called directly or indirectly by another macro)
state:modified includes all of the criteria above, as well as some extra resource-specific criteria, such as modifying a source's
quoting rules or an exposure's
maturity property. (View the source code for the full set of checks used when comparing sources, exposures, and executable nodes.)
The "exposure" method
exposure method is used to select parent resources of a specified exposure. Use in conjunction with the
The "metric" method
metric method is used to select parent resources of a specified metric. Use in conjunction with the
$ dbt build --select +metric:weekly_active_users # build all resources upstream of weekly_active_users metric
$ dbt ls --select +metric:* --resource-type source # list all source tables upstream of all metrics
The "result" method
result method is related to the
state method described above, and can be used to select resources based on their result status from a prior run. Note that one of the dbt commands [
seed] must have been performed in order to create the result on which a result selector operates. You can use
result selectors in conjunction with the
$ dbt run --select result:error # run all models that generated errors on the prior invocation of dbt run
$ dbt test --select result:fail # run all tests that failed on the prior invocation of dbt test
$ dbt build --select 1+result:fail # run all the models associated with failed tests from the prior invocation of dbt build
$ dbt seed --select result:error # run all seeds that generated errors on the prior invocation of dbt seed.