Skip to main content

# Methods

Selector methods return all resources that share a common property, using the syntax method:value. While it is recommended to explicitly denote the method, you can omit it (the default value will be one of path, file or fqn).

### The "tag" method​

The tag: method is used to select models that match a specified tag.

### The "path" method​

The path method is used to select models/sources defined at or under a specific path. Model definitions are in SQL/Python files (not YAML), and source definitions are in YAML files. While the path prefix is not explicitly required, it may be used to make selectors unambiguous.

# These two selectors are equivalentdbt run --select path:models/staging/githubdbt run --select models/staging/github# These two selectors are equivalentdbt run --select path:models/staging/github/stg_issues.sqldbt run --select models/staging/github/stg_issues.sql

### The "package" method​

The 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 selectors unambiguous.

# These three selectors are equivalentdbt run --select package:snowplowdbt run --select snowplowdbt run --select snowplow.*

### The "config" method​

The config method is used to select models that match a specified node config.

### The "state" method​

N.B. State-based selection is a powerful, complex feature. Read about known caveats and limitations to state comparison.

The 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.

### The "metric" method​

Changelog

The metric method is used to select parent resources of a specified metric. Use in conjunction with the + operator.

$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​

Changelog

The 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 [run, test, build, 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 + operator.

$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.

0